Last active
June 17, 2022 20:47
-
-
Save jrichardsz/17e78731353c9abc97d6026ea2e28d58 to your computer and use it in GitHub Desktop.
nodejs shell exec
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
// scriptString = scriptString.replace(new RegExp('\n$'), ''); | |
// scriptString = scriptString.replace(/\n/g, " && "); | |
// if (process.env.ENABLE_LOG === "true") { | |
// console.log(scriptString); | |
// } | |
// | |
// var child = require('child_process').exec(scriptString) | |
// // child.stdout.pipe(process.stdout) | |
// | |
// child.stdout.on('data', (data) => { | |
// console.log (">>>"+data) | |
// }); | |
// | |
// child.stderr.on('data', (data) => { | |
// console.log (data) | |
// }); | |
// | |
// child.on('close', () => { | |
// console.log ('exit!') | |
// }); | |
// await child.on('exit') | |
// try { | |
// const { | |
// stdout, | |
// stderr, | |
// err | |
// } = await execute(scriptString, { | |
// env: { | |
// ...variables, | |
// PATH: process.env.PATH | |
// } | |
// }) | |
// return { | |
// stdout: stdout, | |
// stderr: stderr, | |
// err: err | |
// } | |
// } catch (e) { | |
// //@TODO append to stacktrace | |
// return e | |
// } | |
https://stackoverflow.com/questions/35896006/promise-resolving-to-child-stream-stdout-and-rejecting-child-stream-stderr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment