util.promisify custom implementation of child_process.exec throws away stdout and stderr in case of error

  • Version: v8.0.0
  • Platform: MacOS
  • Subsystem: child_process

Wrapping child_process.exec-s in util.promisify returns a function that returns stdout and stderr in case there is no error (which is good), but does not return stdout and stderr in case of an error.

This means that if the command fails (with exit code != 0) then we have no access to the stdout and stderr (well, we can access stderr in a hackish way through exc.toString(), but that's hackish and still stdout can't be reached).

I suggest attaching stdout and stderr properties to the error returned by the rejected promise. If this is OK with everybody, I can fix it and create a pull request for this.