diff --git a/lib/child_process.js b/lib/child_process.js index afdc5ae551a..a108cba0201 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -483,7 +483,7 @@ function checkExecSyncError(ret) { if (!err) { var msg = 'Command failed: '; msg += ret.cmd || ret.args.join(' '); - if (ret.stderr) + if (ret.stderr && ret.stderr.length > 0) msg += '\n' + ret.stderr.toString(); err = new Error(msg); } diff --git a/test/sequential/test-child-process-execsync.js b/test/sequential/test-child-process-execsync.js index 137ddbda425..e40651dacff 100644 --- a/test/sequential/test-child-process-execsync.js +++ b/test/sequential/test-child-process-execsync.js @@ -98,7 +98,7 @@ assert.strictEqual(ret, msg + '\n', const msg = `Command failed: ${process.execPath} ${args.join(' ')}`; assert(err instanceof Error); - assert.strictEqual(err.message.trim(), msg); + assert.strictEqual(err.message, msg); assert.strictEqual(err.status, 1); return true; });