Skip to content

Instantly share code, notes, and snippets.

@musubu
Created April 1, 2012 12:35
Show Gist options
  • Save musubu/2275092 to your computer and use it in GitHub Desktop.
Save musubu/2275092 to your computer and use it in GitHub Desktop.
simple queue in node
var async = require('async')
, childProcess = require('child_process');
var commands = ['ls -l', 'echo hello'];
async.forEachSeries(commands, function(command, cb) {
childProcess.exec(command, function(err, stdout, stderr) {
if (!err) {
console.log(stdout);
console.log(stderr);
cb();
} else {
console.log(err);
cb();
}
})
}, function(err) {
console.log('all done');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment