To avoid callback hell and weird tricks, async module is recommended.
Example:
var exec = require("child_process").exec;
async.parallel([
async.apply(exec, 'git rev-parse HEAD'),
async.apply(exec, 'git symbolic-ref --short HEAD')
],
function (err, results) {
console.log(results);
});
From: http://syskall.com/executing-multiple-shell-commands-cleanly-in-node-dot-js-with-async/
Async module: https://github.com/caolan/async
shelljs can be used to execute ordered commands
// Run external tool synchronously
if (exec('git commit -am "Auto-commit"').code !== 0) {
echo('Error: Git commit failed');
exit(1);
}
https://github.com/arturadib/shelljs
Each supported versionning system must be splitted into different files (git.js, hg.js, svn.js)