feat: wrapper to a single entrypoint to the stress test

This commit is contained in:
Sérgio Salgado 2021-01-14 17:17:22 +00:00 committed by Josh Harvey
parent 7794b91d20
commit 722a3d2853
4 changed files with 34 additions and 10 deletions

View file

@ -1,4 +1,4 @@
const exec = require('child_process')
const exec = require('child_process').exec
/**
* Execute simple shell command (async wrapper).
@ -7,15 +7,25 @@ const exec = require('child_process')
*/
async function execCommand (cmd) {
return new Promise(function (resolve, reject) {
exec.exec(cmd, (err, stdout, stderr) => {
const proc = exec(cmd, (err, stdout, stderr) => {
if (err) {
reject(err)
} else {
console.log(stdout)
console.error(stderr)
resolve({ stdout, stderr })
}
})
proc.stdout.on('data', data => {
console.log(data)
})
proc.stderr.on('data', data => {
console.log(data)
})
proc.on('exit', code => {
console.log('child process exited with code ' + code.toString())
})
})
}