diff --git a/lib/command.js b/lib/command.js index 46930cd..22aa7e3 100644 --- a/lib/command.js +++ b/lib/command.js @@ -161,7 +161,18 @@ module.exports = function (proto) { return this.stream(format, function (err, stdout) { if (err) return callback(err); - streamToUnemptyBuffer(stdout, callback); + streamToUnemptyBuffer(stdout, (err, buffer) => { + if (err) { + // if we have an error, we want to include stderr + const stdErrOutput = Buffer.from(stderr.read()).toString('utf8') + if (stdErrOutput) { + err.message += `\n${stdErrOutput}` + } + return callback(err); + } + + callback(null, buffer); + }) }) }