-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Closed
Labels
child_processIssues and PRs related to the child_process subsystem.Issues and PRs related to the child_process subsystem.promisesIssues and PRs related to ECMAScript promises.Issues and PRs related to ECMAScript promises.
Description
- 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
Metadata
Metadata
Assignees
Labels
child_processIssues and PRs related to the child_process subsystem.Issues and PRs related to the child_process subsystem.promisesIssues and PRs related to ECMAScript promises.Issues and PRs related to ECMAScript promises.