reverseproxy: use async exec
This commit is contained in:
10
src/shell.js
10
src/shell.js
@@ -29,20 +29,26 @@ function exec(tag, cmd, options, callback) {
|
||||
|
||||
debug(`${tag} exec: ${cmd}`);
|
||||
|
||||
child_process.exec(cmd, options, function (error, stdout, stderr) {
|
||||
const cp = child_process.exec(cmd, options, function (error, stdout, stderr) {
|
||||
let e = null;
|
||||
if (error) {
|
||||
e = new BoxError(BoxError.SHELL_ERROR, `${tag} errored with code ${error.code} message ${error.message}`);
|
||||
e.stdout = stdout; // when promisified, this is the way to get stdout
|
||||
e.stderr = stderr; // when promisified, this is the way to get stderr
|
||||
|
||||
debug(e.message);
|
||||
debug(`${tag}: ${cmd} errored`, error);
|
||||
}
|
||||
|
||||
callback(e, stdout);
|
||||
});
|
||||
|
||||
if (options.input) {
|
||||
cp.stdin.write(options.input);
|
||||
cp.stdin.end();
|
||||
}
|
||||
}
|
||||
|
||||
// use this when you are afraid of how arguments will split up
|
||||
function spawn(tag, file, args, options, callback) {
|
||||
assert.strictEqual(typeof tag, 'string');
|
||||
assert.strictEqual(typeof file, 'string');
|
||||
|
||||
Reference in New Issue
Block a user