Created
October 31, 2013 20:28
-
-
Save mlconnor/7256549 to your computer and use it in GitHub Desktop.
Async example calling exec
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
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