mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
doc, lib, test: do not re-require needlessly
Backport-PR-URL: https://github.com/nodejs/node/pull/14524 Backport-Reviewed-By: Anna Henningsen <anna@addaleax.net> PR-URL: https://github.com/nodejs/node/pull/14244 Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
This commit is contained in:
1 parent
c704c02290
commit
eb023ef7df
22 files changed
+67
-74
No files matched your search
@@ -83,22 +83,23 @@ function child5() {
|
||||
}
|
||||
|
||||
function parent() {
|
||||
const { spawn } = require('child_process');
|
||||
const node = process.execPath;
|
||||
const f = __filename;
|
||||
const option = { stdio: [ 0, 1, 'ignore' ] };
|
||||
|
||||
const test = (arg, exit) => {
|
||||
spawn(node, [f, arg], option).on('exit', (code) => {
|
||||
assert.strictEqual(
|
||||
code, exit,
|
||||
`wrong exit for ${arg}\nexpected:${exit} but got:${code}`);
|
||||
console.log('ok - %s exited with %d', arg, exit);
|
||||
});
|
||||
};
|
||||
|
||||
test('child1', 42);
|
||||
test('child2', 42);
|
||||
test('child3', 0);
|
||||
test('child4', 1);
|
||||
test('child5', 99);
|
||||
}
|
||||
|
||||
function test(arg, exit) {
|
||||
const spawn = require('child_process').spawn;
|
||||
const node = process.execPath;
|
||||
const f = __filename;
|
||||
const option = { stdio: [ 0, 1, 'ignore' ] };
|
||||
spawn(node, [f, arg], option).on('exit', function(code) {
|
||||
assert.strictEqual(
|
||||
code, exit,
|
||||
`wrong exit for ${arg}\nexpected:${exit} but got:${code}`);
|
||||
console.log('ok - %s exited with %d', arg, exit);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user