| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 801e61a commit 556ebab
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -574,8 +574,7 @@ function checkExecSyncError(ret, args, cmd) { | |||
| 574 | 574 | err = new Error(msg); | |
| 575 | 575 | } | |
| 576 | 576 | if (err) { | |
| 577 | - err.status = ret.status < 0 ? errname(ret.status) : ret.status; | ||
| 578 | - err.signal = ret.signal; | ||
| 577 | + Object.assign(err, ret); | ||
| 579 | 578 | } | |
| 580 | 579 | return err; | |
| 581 | 580 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,7 @@ | |||
| 23 | 23 | const common = require('../common'); | |
| 24 | 24 | const assert = require('assert'); | |
| 25 | 25 | ||
| 26 | - const { execFileSync, execSync } = require('child_process'); | ||
| 26 | + const { execFileSync, execSync, spawnSync } = require('child_process'); | ||
| 27 | 27 | ||
| 28 | 28 | const TIMER = 200; | |
| 29 | 29 | const SLEEP = 2000; | |
@@ -112,6 +112,16 @@ assert.strictEqual(ret, `${msg}\n`); | |||
| 112 | 112 | // Verify the execFileSync() behavior when the child exits with a non-zero code. | |
| 113 | 113 | { | |
| 114 | 114 | const args = ['-e', 'process.exit(1)']; | |
| 115 | + const spawnSyncResult = spawnSync(process.execPath, args); | ||
| 116 | + const spawnSyncKeys = Object.keys(spawnSyncResult).sort(); | ||
| 117 | + assert.deepStrictEqual(spawnSyncKeys, [ | ||
| 118 | + 'output', | ||
| 119 | + 'pid', | ||
| 120 | + 'signal', | ||
| 121 | + 'status', | ||
| 122 | + 'stderr', | ||
| 123 | + 'stdout' | ||
| 124 | + ]); | ||
| 115 | 125 | ||
| 116 | 126 | assert.throws(() => { | |
| 117 | 127 | execFileSync(process.execPath, args); | |
@@ -121,6 +131,11 @@ assert.strictEqual(ret, `${msg}\n`); | |||
| 121 | 131 | assert(err instanceof Error); | |
| 122 | 132 | assert.strictEqual(err.message, msg); | |
| 123 | 133 | assert.strictEqual(err.status, 1); | |
| 134 | + assert.strictEqual(typeof err.pid, 'number'); | ||
| 135 | + spawnSyncKeys.forEach((key) => { | ||
| 136 | + if (key === 'pid') return; | ||
| 137 | + assert.deepStrictEqual(err[key], spawnSyncResult[key]); | ||
| 138 | + }); | ||
| 124 | 139 | return true; | |
| 125 | 140 | }); | |
| 126 | 141 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments