Skip to content

Instantly share code, notes, and snippets.

@jakub-g

jakub-g/execSync.js

Created Oct 19, 2015
Embed
What would you like to do?
NodeJS synchronous exec: printing output to console vs returning output from function
function execSyncPrintOutput(command, env) {
env = env || process.env;
try {
return require('child_process').execSync((command), {
stdio: 'inherit',
env: env
});
} catch (e) {
__handleExecFailure(command);
}
}
function execSyncReturnOutput(command, env) {
env = env || process.env;
try {
return require('child_process').execSync((command), {
stdio: 'pipe',
env: env
}).toString();
} catch (e) {
__handleExecFailure(command);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment