Skip to content

Instantly share code, notes, and snippets.

@mlconnor
Created October 31, 2013 20:28
Show Gist options
  • Save mlconnor/7256549 to your computer and use it in GitHub Desktop.
Save mlconnor/7256549 to your computer and use it in GitHub Desktop.
Async example calling exec
for ( var i = 0; i < total_tiles; i++ ) {
var filename = "tiles_" + i + ".png"; // current filename
var target = "map_" + column + "_" + row + ".png" // new filename
var cmd = "file " + i + " cmd> cp -f gen/" + filename + " mappy/" + target;
console.log(cmd);
//taskList.push(async.apply(child_process.exec, cmd));
taskList.push(function(command) {
return function(callback) {
console.log('calling cmd ' + command);
child_process.exec(command, callback);
};
}(cmd));
//child_process.exec(cmd);
// work out next step
column++;
if ( column >= tiles_per_column ) {
column = 0;
row++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment