Created
October 8, 2015 00:38
-
-
Save beatak/a22c0f49b9443b03dd3f to your computer and use it in GitHub Desktop.
This file contains 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 wrap_spawn = function (arg_spawn, cb_on_close) { | |
var child = spawn.apply(null, arg_spawn); | |
var stdout = []; | |
var stderr = []; | |
child.stdout.on('data', function (data) { | |
stdout.push(data.toString()); | |
}); | |
child.stderr.on('data', function (data) { | |
stderr.push(data.toString()); | |
}); | |
child.once('close', function (code) { | |
cb_on_close(code, stdout.join(''), stderr.join('')); | |
child.stdout.removeAllListeners(); | |
child.stderr.removeAllListeners(); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment