I have working code that does exactly what I want but I'm not happy with the method I've used because it doesn't scale well.
Say I want to execute 4 commands, one after the other, to clone a repo and checkout a release to a local folder:
//shell command
var cmd = "cd /Users/xxxx/Documents/DESIGN" +
" && git clone https://github.com/xxxx/xxxx.git testing" +
" && cd testing" +
" && git checkout 4.0";
//execute shell command
var exec = require("child_process").exec;
exec(cmd, function(err, stdout, stderr){
if (err) console.log(err);
console.log(stdout);
});
Is there a way to cleanly execute multiple commands and make this more scalable without just adding more to the original command string with the && to join them?