- Version:
v8.9.4
- Platform:
Ubuntu 16.04
I'm having trouble promisifying child_process.exec. When I run with error or without, the promise is rejected. I've followed the docs and wrote this:
const { promisify } = require('util');
const execCallback = require('child_process').exec;
const exec = promisify(execCallback);
const fooBar = () => {
const dir = `engine/Users/${user}`;
const fileOne = `${process.cwd()}/${dir}/myFileOne.txt`;
const fileTwo = `${process.cwd()}/${dir}/myFileTwo.txt`;
const command = `diff --unchanged-group-format="" ${fileOne} ${fileTwo}`;
return run(command)
.then((stdout, stderr) => {
console.log('ran diff');
return stdout;
})
.catch(error => console.log('got error running diff'));
};
fooBar goes through the catch block with this error:
{
killed: false,
code: 1,
signal: null,
cmd: /*the correct diff cmd*/,
stdout: /*the correct diff stdout*/,
stderr: ''
}
An actual error (or at least a 'no such file') gives me code: 2, stdout: '', stderr: no such file error string
v8.9.4
Ubuntu 16.04
I'm having trouble
promisifyingchild_process.exec. When I run with error or without, the promise is rejected. I've followed the docs and wrote this:fooBargoes through thecatchblock with thiserror:An actual error (or at least a 'no such file') gives me
code: 2,stdout: '',stderr: no such file error string