Skip to content

Instantly share code, notes, and snippets.

@Xstasy
Created February 9, 2015 19:29
Show Gist options
  • Save Xstasy/8de8e2065eaaf888ebff to your computer and use it in GitHub Desktop.
Save Xstasy/8de8e2065eaaf888ebff to your computer and use it in GitHub Desktop.
var spawn = require('child_process').spawn;
var Run = require('./Run');
module.exports = {
Tool: function(tool, args) {
try {
console.log("Tool ("+tool+") spawn: " + tool + " " + args.split(" ").toString());
var proc = spawn('tools\\' +tool, args.split(" "));
proc.stdout.on('data', function (data) {
console.log("Tool ("+tool+") : " + data);
});
proc.stderr.on('data', function (data) {
console.log("Tool ("+tool+") error: " + data);
});
proc.on('close', function (code) {
console.log("Tool ("+tool+") exit: " + code);
});
} catch (e) {
console.log("Tool ("+tool+") fatal: " + code);
}
}
};
Output
###################################################################
Tool (MediaInfo.exe) spawn: MediaInfo.exe --Version
Tool (MediaInfo.exe) : MediaInfo Command line,
MediaInfoLib - v0.7.72
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn OK
at errnoException (child_process.js:1011:11)
at Process.ChildProcess._handle.onexit (child_process.js:802:34)
Process finished with exit code 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment