-
-
Save m00zi/920b8253502a0813d9ad76edb1d6505f to your computer and use it in GitHub Desktop.
Node.js run command in child process promise
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
const exec = require('child_process').exec; | |
const cmd = 'echo "hello"'; | |
function echo() { | |
return new Promise((resolve, reject) => { | |
exec(cmd, (error, stdout, stderr) => { | |
if (error) return resolve(false); | |
if (stderr) return resolve(false); | |
resolve(true); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment