node.js
This file
Path
test/methods/node.js
307 lines · 16.3 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
The walk stopped after 200 commits: lines older than 08eb743 point at it.
TweaksSindre Sorhusbefore adoption698a1b8
line 1why, one step back1import assert from 'node:assert/strict';Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0
line 2why, one step back2import path from 'node:path';Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 3–4why, one step back3import process, {version} from 'node:process';4import {pathToFileURL} from 'node:url';TweaksSindre Sorhusbefore adoption698a1b8
line 5why, one step back5import test from 'node:test';Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 6why, one step back6import getNode from 'get-node';TweaksSindre Sorhusbefore adoption698a1b8
line 7why, one step back7import {assertThrows, assertRejects} from '../helpers/assert.js';Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 8–11why, one step back8import {execa, execaSync, execaNode} from '../../index.js';9import {FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';10import {identity, fullStdio} from '../helpers/stdio.js';11import {foobarString} from '../helpers/input.js';Fix deno node:process execPath compatibility (#1160)CJbefore adoptionf3a1bf3
line 12why, one step back12import {getDenoNodePath} from '../helpers/file-path.js';Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 13–23why, one step back1314process.chdir(FIXTURES_DIRECTORY);1516const runWithNodeOption = (file, commandArguments, options) => Array.isArray(commandArguments)17 ? execa(file, commandArguments, {...options, node: true})18 : execa(file, {...options, node: true});19const runWithNodeOptionSync = (file, commandArguments, options) => Array.isArray(commandArguments)20 ? execaSync(file, commandArguments, {...options, node: true})21 : execaSync(file, {...options, node: true});22const runWithIpc = (file, options) => execa('node', [file], {...options, ipc: true});23TweaksSindre Sorhusbefore adoption698a1b8
line 24why, one step back24const testNodeSuccess = async execaMethod => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 25why, one step back25 const {exitCode, stdout} = await execaMethod('noop.js', [foobarString]);TweaksSindre Sorhusbefore adoption698a1b8
lines 26–27why, one step back26 assert.equal(exitCode, 0);27 assert.equal(stdout, foobarString);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 28–29why, one step back28};29TweaksSindre Sorhusbefore adoption698a1b8
lines 30–32why, one step back30test('execaNode() succeeds', () => testNodeSuccess(execaNode));31test('The "node" option succeeds', () => testNodeSuccess(runWithNodeOption));32test('The "node" option succeeds - sync', () => testNodeSuccess(runWithNodeOptionSync));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 33why, one step back33TweaksSindre Sorhusbefore adoption698a1b8
line 34why, one step back34test('execaNode(options) succeeds', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 35why, one step back35 const {stdout} = await execaNode({stripFinalNewline: false})('noop.js', [foobarString]);TweaksSindre Sorhusbefore adoption698a1b8
line 36why, one step back36 assert.equal(stdout, `${foobarString}\n`);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 37–38why, one step back37});38TweaksSindre Sorhusbefore adoption698a1b8
line 39why, one step back39test('execaNode`...` succeeds', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 40why, one step back40 const {stdout} = await execaNode`noop.js ${foobarString}`;TweaksSindre Sorhusbefore adoption698a1b8
line 41why, one step back41 assert.equal(stdout, foobarString);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 42–43why, one step back42});43TweaksSindre Sorhusbefore adoption698a1b8
line 44why, one step back44test('execaNode().pipe(execaNode()) succeeds', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 45why, one step back45 const {stdout} = await execaNode('noop.js').pipe(execaNode('--version'));TweaksSindre Sorhusbefore adoption698a1b8
line 46why, one step back46 assert.equal(stdout, version);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 47–48why, one step back47});48TweaksSindre Sorhusbefore adoption698a1b8
lines 49–50why, one step back49test('execaNode().pipe(execa()) requires using "node"', async () => {50 await assertRejects(execaNode('noop.js').pipe(execa('--version')));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 51–52why, one step back51});52TweaksSindre Sorhusbefore adoption698a1b8
lines 53–54why, one step back53test('execaNode().pipe(...) requires using "node"', async () => {54 await assertRejects(execaNode('noop.js').pipe('--version'));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 55–56why, one step back55});56TweaksSindre Sorhusbefore adoption698a1b8
lines 57–58why, one step back57test('execaNode().pipe`...` requires using "node"', async () => {58 await assertRejects(execaNode('noop.js').pipe`--version`);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 59–60why, one step back59});60TweaksSindre Sorhusbefore adoption698a1b8
lines 61–62why, one step back61test('execaNode() cannot set the "node" option to false', () => {62 assertThrows(() => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 63–66why, one step back63 execaNode('empty.js', {node: false});64 }, {message: /The "node" option cannot be false/});65});66TweaksSindre Sorhusbefore adoption698a1b8
lines 67–68why, one step back67const testDoubleNode = (nodePath, execaMethod) => {68 assertThrows(() => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 69–72why, one step back69 execaMethod(nodePath, ['noop.js']);70 }, {message: /does not need to be "node"/});71};72TweaksSindre Sorhusbefore adoption698a1b8
lines 73–81why, one step back73test('Cannot use "node" as binary - execaNode()', () => testDoubleNode('node', execaNode));74test('Cannot use "node" as binary - "node" option', () => testDoubleNode('node', runWithNodeOption));75test('Cannot use "node" as binary - "node" option sync', () => testDoubleNode('node', runWithNodeOptionSync));76test('Cannot use path to "node" as binary - execaNode()', () => testDoubleNode(process.execPath, execaNode));77test('Cannot use path to "node" as binary - "node" option', () => testDoubleNode(process.execPath, runWithNodeOption));78test('Cannot use path to "node" as binary - "node" option sync', () => testDoubleNode(process.execPath, runWithNodeOptionSync));79test('Cannot use deno style nodePath as binary - execaNode()', () => testDoubleNode(getDenoNodePath(), execaNode));80test('Cannot use deno style nodePath as binary - "node" option', () => testDoubleNode(getDenoNodePath(), runWithNodeOption));81test('Cannot use deno style nodePath as binary - "node" option sync', () => testDoubleNode(getDenoNodePath(), runWithNodeOptionSync));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 82–89why, one step back8283const getNodePath = async () => {84 const {path} = await getNode(TEST_NODE_VERSION);85 return path;86};8788const TEST_NODE_VERSION = '16.0.0';89TweaksSindre Sorhusbefore adoption698a1b8
lines 90–94why, one step back90// `nodeOptions` defaults to `process.execArgv`, which `node --test` fills with its own flags.91// Those flags are unknown to the Node.js version downloaded by `getNode()`, so they are not forwarded.92const downloadedNodeOptions = {nodeOptions: []};9394const testNodePath = async (execaMethod, mapPath) => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 95why, one step back95 const nodePath = mapPath(await getNodePath());TweaksSindre Sorhusbefore adoption698a1b8
lines 96–97why, one step back96 const {stdout} = await execaMethod('--version', [], {nodePath, ...downloadedNodeOptions});97 assert.equal(stdout, `v${TEST_NODE_VERSION}`);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 98–99why, one step back98};99TweaksSindre Sorhusbefore adoption698a1b8
lines 100–105why, one step back100test('The "nodePath" option can be used - execaNode()', () => testNodePath(execaNode, identity));101test('The "nodePath" option can be a file URL - execaNode()', () => testNodePath(execaNode, pathToFileURL));102test('The "nodePath" option can be used - "node" option', () => testNodePath(runWithNodeOption, identity));103test('The "nodePath" option can be a file URL - "node" option', () => testNodePath(runWithNodeOption, pathToFileURL));104test('The "nodePath" option can be used - "node" option sync', () => testNodePath(runWithNodeOptionSync, identity));105test('The "nodePath" option can be a file URL - "node" option sync', () => testNodePath(runWithNodeOptionSync, pathToFileURL));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 106why, one step back106TweaksSindre Sorhusbefore adoption698a1b8
line 107why, one step back107const testNodePathDefault = async execaMethod => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 108why, one step back108 const {stdout} = await execaMethod('--version');TweaksSindre Sorhusbefore adoption698a1b8
line 109why, one step back109 assert.equal(stdout, process.version);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 110–111why, one step back110};111TweaksSindre Sorhusbefore adoption698a1b8
lines 112–114why, one step back112test('The "nodePath" option defaults to the current Node.js binary - execaNode()', () => testNodePathDefault(execaNode));113test('The "nodePath" option defaults to the current Node.js binary - "node" option', () => testNodePathDefault(runWithNodeOption));114test('The "nodePath" option defaults to the current Node.js binary - "node" option sync', () => testNodePathDefault(runWithNodeOptionSync));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 115why, one step back115TweaksSindre Sorhusbefore adoption698a1b8
lines 116–117why, one step back116const testNodePathInvalid = execaMethod => {117 assertThrows(() => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 118–121why, one step back118 execaMethod('noop.js', [], {nodePath: true});119 }, {message: /The "nodePath" option must be a string or a file URL/});120};121TweaksSindre Sorhusbefore adoption698a1b8
lines 122–124why, one step back122test('The "nodePath" option must be a string or URL - execaNode()', () => testNodePathInvalid(execaNode));123test('The "nodePath" option must be a string or URL - "node" option', () => testNodePathInvalid(runWithNodeOption));124test('The "nodePath" option must be a string or URL - "node" option sync', () => testNodePathInvalid(runWithNodeOptionSync));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 125why, one step back125TweaksSindre Sorhusbefore adoption698a1b8
lines 126–127why, one step back126const testFormerNodePath = execaMethod => {127 assertThrows(() => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 128–131why, one step back128 execaMethod('noop.js', [], {execPath: process.execPath});129 }, {message: /The "execPath" option has been removed/});130};131TweaksSindre Sorhusbefore adoption698a1b8
lines 132–134why, one step back132test('The "execPath" option cannot be used - execaNode()', () => testFormerNodePath(execaNode));133test('The "execPath" option cannot be used - "node" option', () => testFormerNodePath(runWithNodeOption));134test('The "execPath" option cannot be used - "node" option sync', () => testFormerNodePath(runWithNodeOptionSync));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 135–137why, one step back135136const nodePathArguments = ['-p', ['process.env.Path || process.env.PATH']];137TweaksSindre Sorhusbefore adoption698a1b8
line 138why, one step back138const testSubprocessNodePath = async (execaMethod, mapPath) => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 139why, one step back139 const nodePath = mapPath(await getNodePath());TweaksSindre Sorhusbefore adoption698a1b8
lines 140–141why, one step back140 const {stdout} = await execaMethod(...nodePathArguments, {nodePath, ...downloadedNodeOptions});141 assert.ok(stdout.includes(TEST_NODE_VERSION));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 142–143why, one step back142};143TweaksSindre Sorhusbefore adoption698a1b8
lines 144–146why, one step back144test('The "nodePath" option impacts the subprocess - execaNode()', () => testSubprocessNodePath(execaNode, identity));145test('The "nodePath" option impacts the subprocess - "node" option', () => testSubprocessNodePath(runWithNodeOption, identity));146test('The "nodePath" option impacts the subprocess - "node" option sync', () => testSubprocessNodePath(runWithNodeOptionSync, identity));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 147why, one step back147TweaksSindre Sorhusbefore adoption698a1b8
line 148why, one step back148const testSubprocessNodePathDefault = async execaMethod => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 149why, one step back149 const {stdout} = await execaMethod(...nodePathArguments);TweaksSindre Sorhusbefore adoption698a1b8
line 150why, one step back150 assert.ok(stdout.includes(path.dirname(process.execPath)));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 151–152why, one step back151};152TweaksSindre Sorhusbefore adoption698a1b8
lines 153–155why, one step back153test('The "nodePath" option defaults to the current Node.js binary in the subprocess - execaNode()', () => testSubprocessNodePathDefault(execaNode));154test('The "nodePath" option defaults to the current Node.js binary in the subprocess - "node" option', () => testSubprocessNodePathDefault(runWithNodeOption));155test('The "nodePath" option defaults to the current Node.js binary in the subprocess - "node" option sync', () => testSubprocessNodePathDefault(runWithNodeOptionSync));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 156why, one step back156TweaksSindre Sorhusbefore adoption698a1b8
line 157why, one step back157test('The "nodePath" option requires "node: true" to impact the subprocess', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 158–159why, one step back158 const nodePath = await getNodePath();159 const {stdout} = await execa('node', nodePathArguments.flat(), {nodePath});TweaksSindre Sorhusbefore adoption698a1b8
line 160why, one step back160 assert.ok(!stdout.includes(TEST_NODE_VERSION));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 161–162why, one step back161});162TweaksSindre Sorhusbefore adoption698a1b8
line 163why, one step back163const testSubprocessNodePathCwd = async execaMethod => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 164why, one step back164 const nodePath = await getNodePath();Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0
lines 165–166why, one step back165 const cwd = path.dirname(path.dirname(nodePath));166 const relativeExecPath = path.relative(cwd, nodePath);TweaksSindre Sorhusbefore adoption698a1b8
lines 167–168why, one step back167 const {stdout} = await execaMethod(...nodePathArguments, {nodePath: relativeExecPath, cwd, ...downloadedNodeOptions});168 assert.ok(stdout.includes(TEST_NODE_VERSION));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 169–170why, one step back169};170TweaksSindre Sorhusbefore adoption698a1b8
lines 171–173why, one step back171test('The "nodePath" option is relative to "cwd" when used in the subprocess - execaNode()', () => testSubprocessNodePathCwd(execaNode));172test('The "nodePath" option is relative to "cwd" when used in the subprocess - "node" option', () => testSubprocessNodePathCwd(runWithNodeOption));173test('The "nodePath" option is relative to "cwd" when used in the subprocess - "node" option sync', () => testSubprocessNodePathCwd(runWithNodeOptionSync));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 174why, one step back174TweaksSindre Sorhusbefore adoption698a1b8
line 175why, one step back175const testCwdNodePath = async execaMethod => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 176why, one step back176 const nodePath = await getNodePath();Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0
lines 177–178why, one step back177 const cwd = path.dirname(path.dirname(nodePath));178 const relativeExecPath = path.relative(cwd, nodePath);TweaksSindre Sorhusbefore adoption698a1b8
lines 179–180why, one step back179 const {stdout} = await execaMethod('--version', [], {nodePath: relativeExecPath, cwd, ...downloadedNodeOptions});180 assert.equal(stdout, `v${TEST_NODE_VERSION}`);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 181–182why, one step back181};182TweaksSindre Sorhusbefore adoption698a1b8
lines 183–185why, one step back183test('The "nodePath" option is relative to "cwd" - execaNode()', () => testCwdNodePath(execaNode));184test('The "nodePath" option is relative to "cwd" - "node" option', () => testCwdNodePath(runWithNodeOption));185test('The "nodePath" option is relative to "cwd" - "node" option sync', () => testCwdNodePath(runWithNodeOptionSync));Fix deno node:process execPath compatibility (#1160)CJbefore adoptionf3a1bf3
line 186why, one step back186TweaksSindre Sorhusbefore adoption698a1b8
line 187why, one step back187const testDenoExecPath = async execaMethod => {Fix deno node:process execPath compatibility (#1160)CJbefore adoptionf3a1bf3
line 188why, one step back188 const {exitCode, stdout} = await execaMethod('noop.js', [], {nodePath: getDenoNodePath()});TweaksSindre Sorhusbefore adoption698a1b8
lines 189–190why, one step back189 assert.equal(exitCode, 0);190 assert.equal(stdout, foobarString);Fix deno node:process execPath compatibility (#1160)CJbefore adoptionf3a1bf3
lines 191–192why, one step back191};192TweaksSindre Sorhusbefore adoption698a1b8
lines 193–195why, one step back193test('The deno style "nodePath" option can be used - execaNode()', () => testDenoExecPath(execaNode));194test('The deno style "nodePath" option can be used - "node" option', () => testDenoExecPath(runWithNodeOption));195test('The deno style "nodePath" option can be used - "node" option sync', () => testDenoExecPath(runWithNodeOptionSync));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 196why, one step back196TweaksSindre Sorhusbefore adoption698a1b8
line 197why, one step back197const testNodeOptions = async execaMethod => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 198why, one step back198 const {stdout} = await execaMethod('empty.js', [], {nodeOptions: ['--version']});TweaksSindre Sorhusbefore adoption698a1b8
line 199why, one step back199 assert.equal(stdout, process.version);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 200–201why, one step back200};201TweaksSindre Sorhusbefore adoption698a1b8
lines 202–204why, one step back202test('The "nodeOptions" option can be used - execaNode()', () => testNodeOptions(execaNode));203test('The "nodeOptions" option can be used - "node" option', () => testNodeOptions(runWithNodeOption));204test('The "nodeOptions" option can be used - "node" option sync', () => testNodeOptions(runWithNodeOptionSync));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 205–211why, one step back205206const spawnNestedExecaNode = (realExecArgv, fakeExecArgv, execaMethod, nodeOptions) => execa(207 'node',208 [...realExecArgv, 'nested-node.js', fakeExecArgv, execaMethod, nodeOptions, 'noop.js', foobarString],209 {...fullStdio, cwd: FIXTURES_DIRECTORY},210);211TweaksSindre Sorhusbefore adoption698a1b8
line 212why, one step back212const testInspectRemoval = async (fakeExecArgv, execaMethod) => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 213why, one step back213 const {stdout, stdio} = await spawnNestedExecaNode([], fakeExecArgv, execaMethod, '');TweaksSindre Sorhusbefore adoption698a1b8
lines 214–215why, one step back214 assert.equal(stdout, foobarString);215 assert.equal(stdio[3], '');Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 216–217why, one step back216};217TweaksSindre Sorhusbefore adoption698a1b8
lines 218–225why, one step back218test('The "nodeOptions" option removes --inspect without a port when defined by current process - execaNode()', () => testInspectRemoval('--inspect', 'execaNode'));219test('The "nodeOptions" option removes --inspect without a port when defined by current process - "node" option', () => testInspectRemoval('--inspect', 'nodeOption'));220test('The "nodeOptions" option removes --inspect with a port when defined by current process - execaNode()', () => testInspectRemoval('--inspect=9222', 'execaNode'));221test('The "nodeOptions" option removes --inspect with a port when defined by current process - "node" option', () => testInspectRemoval('--inspect=9222', 'nodeOption'));222test('The "nodeOptions" option removes --inspect-brk without a port when defined by current process - execaNode()', () => testInspectRemoval('--inspect-brk', 'execaNode'));223test('The "nodeOptions" option removes --inspect-brk without a port when defined by current process - "node" option', () => testInspectRemoval('--inspect-brk', 'nodeOption'));224test('The "nodeOptions" option removes --inspect-brk with a port when defined by current process - execaNode()', () => testInspectRemoval('--inspect-brk=9223', 'execaNode'));225test('The "nodeOptions" option removes --inspect-brk with a port when defined by current process - "node" option', () => testInspectRemoval('--inspect-brk=9223', 'nodeOption'));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 226why, one step back226TweaksSindre Sorhusbefore adoption698a1b8
line 227why, one step back227const testInspectDifferentPort = async execaMethod => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 228why, one step back228 const {stdout, stdio} = await spawnNestedExecaNode(['--inspect=9225'], '', execaMethod, '--inspect=9224');TweaksSindre Sorhusbefore adoption698a1b8
lines 229–230why, one step back229 assert.equal(stdout, foobarString);230 assert.ok(stdio[3].includes('Debugger listening'));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 231–232why, one step back231};232TweaksSindre Sorhusbefore adoption698a1b8
lines 233–234why, one step back233test('The "nodeOptions" option allows --inspect with a different port even when defined by current process - execaNode()', () => testInspectDifferentPort('execaNode'));234test('The "nodeOptions" option allows --inspect with a different port even when defined by current process - "node" option', () => testInspectDifferentPort('nodeOption'));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 235why, one step back235TweaksSindre Sorhusbefore adoption698a1b8
line 236why, one step back236const testInspectSamePort = async execaMethod => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 237why, one step back237 const {stdout, stdio} = await spawnNestedExecaNode(['--inspect=9226'], '', execaMethod, '--inspect=9226');TweaksSindre Sorhusbefore adoption698a1b8
lines 238–239why, one step back238 assert.equal(stdout, foobarString);239 assert.ok(stdio[3].includes('address already in use'));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 240–241why, one step back240};241TweaksSindre Sorhusbefore adoption698a1b8
lines 242–243why, one step back242test('The "nodeOptions" option forbids --inspect with the same port when defined by current process - execaNode()', () => testInspectSamePort('execaNode'));243test('The "nodeOptions" option forbids --inspect with the same port when defined by current process - "node" option', () => testInspectSamePort('nodeOption'));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 244why, one step back244TweaksSindre Sorhusbefore adoption698a1b8
line 245why, one step back245const testIpc = async (execaMethod, options) => {Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 246–247why, one step back246 const subprocess = execaMethod('ipc-echo.js', [], options);247Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 248why, one step back248 await subprocess.sendMessage(foobarString);TweaksSindre Sorhusbefore adoption698a1b8
line 249why, one step back249 assert.equal(await subprocess.getOneMessage(), foobarString);Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 250–251why, one step back250251 const {stdio} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
lines 252–253why, one step back252 assert.equal(stdio.length, 4);253 assert.equal(stdio[3], undefined);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 254–255why, one step back254};255TweaksSindre Sorhusbefore adoption698a1b8
lines 256–261why, one step back256test('execaNode() adds an ipc channel', () => testIpc(execaNode, {}));257test('The "node" option adds an ipc channel', () => testIpc(runWithNodeOption, {}));258test('The "ipc" option adds an ipc channel', () => testIpc(runWithIpc, {}));259test('The "ipc" option works with "stdio: \'pipe\'"', () => testIpc(runWithIpc, {stdio: 'pipe'}));260test('The "ipc" option works with "stdio: [\'pipe\', \'pipe\', \'pipe\']"', () => testIpc(runWithIpc, {stdio: ['pipe', 'pipe', 'pipe']}));261test('The "ipc" option works with "stdout: \'pipe\'"', () => testIpc(runWithIpc, {stdout: 'pipe'}));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 262why, one step back262Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 263–264why, one step back263const NO_SEND_MESSAGE = 'sendMessage() can only be used';264TweaksSindre Sorhusbefore adoption698a1b8
lines 265–268why, one step back265test('No ipc channel is added by default', async () => {266 const {message, stdio} = await assertRejects(execa('node', ['ipc-send.js']));267 assert.ok(message.includes(NO_SEND_MESSAGE));268 assert.equal(stdio.length, 3);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 269–270why, one step back269});270TweaksSindre Sorhusbefore adoption698a1b8
line 271why, one step back271const testDisableIpc = async execaMethod => {Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 272why, one step back272 const {failed, message, stdio} = await execaMethod('ipc-send.js', [], {ipc: false, reject: false});TweaksSindre Sorhusbefore adoption698a1b8
lines 273–275why, one step back273 assert.equal(failed, true);274 assert.ok(message.includes(NO_SEND_MESSAGE));275 assert.equal(stdio.length, 3);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 276–277why, one step back276};277TweaksSindre Sorhusbefore adoption698a1b8
lines 278–280why, one step back278test('Can disable "ipc" - execaNode()', () => testDisableIpc(execaNode));279test('Can disable "ipc" - "node" option', () => testDisableIpc(runWithNodeOption));280test('Can disable "ipc" - "node" option sync', () => testDisableIpc(runWithNodeOptionSync));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 281–283why, one step back281282const NO_IPC_MESSAGE = /The "ipc: true" option cannot be used/;283TweaksSindre Sorhusbefore adoption698a1b8
lines 284–285why, one step back284const testNoIpcSync = node => {285 assertThrows(() => {Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 286why, one step back286 execaSync('node', ['ipc-send.js'], {ipc: true, node});Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 287–289why, one step back287 }, {message: NO_IPC_MESSAGE});288};289TweaksSindre Sorhusbefore adoption698a1b8
lines 290–291why, one step back290test('Cannot use "ipc: true" with execaSync()', () => testNoIpcSync(undefined));291test('Cannot use "ipc: true" with execaSync() - "node: false"', () => testNoIpcSync(false));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 292why, one step back292TweaksSindre Sorhusbefore adoption698a1b8
lines 293–294why, one step back293test('Cannot use "ipc: true" with execaSync() - "node: true"', () => {294 assertThrows(() => {Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 295why, one step back295 execaSync('ipc-send.js', {ipc: true, node: true});Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 296–298why, one step back296 }, {message: NO_IPC_MESSAGE});297});298TweaksSindre Sorhusbefore adoption698a1b8
line 299why, one step back299const testNoShell = async execaMethod => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 300why, one step back300 const {failed, message} = await execaMethod('node --version', [], {shell: true, reject: false});TweaksSindre Sorhusbefore adoption698a1b8
lines 301–302why, one step back301 assert.equal(failed, true);302 assert.ok(message.includes('MODULE_NOT_FOUND'));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 303–304why, one step back303};304TweaksSindre Sorhusbefore adoption698a1b8
lines 305–307why, one step back305test('Cannot use "shell: true" - execaNode()', () => testNoShell(execaNode));306test('Cannot use "shell: true" - "node" option', () => testNoShell(runWithNodeOption));307test('Cannot use "shell: true" - "node" option sync', () => testNoShell(runWithNodeOptionSync));