Created
May 11, 2015 09:20
-
-
Save gamell/984e651e08225374ecb7 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
function executeCommand(command, callback){ | |
console.log("*** Executing command: " + command); | |
var options = { | |
encoding: 'utf8', | |
timeout: 600000000, | |
maxBuffer: 10 * 1024 * 2048, | |
killSignal: 'SIGTERM', | |
cwd: null, | |
env: null | |
}; | |
// we execute the command | |
var child = exec(command, options); | |
// set all the handlers to display the output in the console | |
child.stdout.on('data', function (data) { | |
console.log(data.trim()); | |
}); | |
child.stderr.on('data', function (data) { | |
console.log("ERROR: " + data.trim()); | |
}); | |
child.on('error', function () { | |
console.log("ERROR: " + data.trim()); | |
}); | |
child.on('close', function () { | |
process.exit(); | |
if(!!callback){ | |
callback.call(this, child); | |
} | |
}); | |
child.on('exit', function () { | |
if(!!callback){ | |
callback(this, child); | |
} | |
}); | |
return child; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment