Created
July 4, 2020 07:03
-
-
Save amitsingh-007/77beee2f0056bcb21ab224626b1d6556 to your computer and use it in GitHub Desktop.
Execute command to run jest command
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
/* | |
* Use spawn instead of exec for large ouput buffer | |
* https://www.hacksparrow.com/nodejs/difference-between-spawn-and-exec-of-node-js-child-rocess.html | |
*/ | |
const liveOuput = (command, args) => { | |
const childProcess = spawn(command, args, { shell: true }); | |
childProcess.stdout.on("data", data => { | |
console.log(data.toString()); | |
}); | |
childProcess.stderr.on("data", data => { | |
console.log(data.toString()); | |
}); | |
childProcess.on("exit", code => { | |
console.log("[EXIT CODE]: " + code.toString()); | |
process.exit(code); | |
}); | |
childProcess.on("error", err => { | |
console.log("[ERROR]: ", err); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment