Created
January 8, 2014 14:29
-
-
Save dignifiedquire/8317598 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cp = require('child_process'); | |
var async = require('async'); | |
function discover(opts, callback) { | |
var listOfItems = [1,2,3,4,5]; | |
async.map(listOfItems, function (item, cb) { | |
// Gets executed for every item in the list | |
// when exec is done it calls the cb | |
cp.exec(cmd(item), cb) | |
}, function (error, results) { | |
// results is an array with all stdouts of the commands you ran. | |
// do stuff to it here. | |
// And return using the callback that was used in the beginning. | |
callback(error, results) | |
}) | |
} | |
function cmd(item) { | |
return 'my awesome cmd ' + item; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, I really appreciate your help. The updated file is here if your interested in the implementation.