Skip to content
Myr

node.js

This file

Path

test/node.js

100 lines · 2.3 KiB · JavaScript

Last changed by

Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64

History of this file

Take it

Fix lintingehmickybefore adoption2752f49

line 1why, one step back
1import path from 'path';

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

lines 2–7why, one step back
2import test from 'ava';
3import pEvent from 'p-event';4import execa from '..';56process.env.PATH = path.join(__dirname, 'fixtures') + path.delimiter + process.env.PATH;7

Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64

lines 8–24why, one step back
8async function inspectMacro(t, input) {
9 const originalArgv = process.execArgv;10 process.execArgv = [input, '-e'];11 try {12 const subprocess = execa.node('console.log("foo")', {13 reject: false14 });1516 const {stdout, stderr} = await subprocess;1718 t.is(stdout, 'foo');19 t.is(stderr, '');20 } finally {21 process.execArgv = originalArgv;22 }23}24

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

lines 25–41why, one step back
25test('node()', async t => {
26 const {exitCode} = await execa.node('test/fixtures/noop');27 t.is(exitCode, 0);28});2930test('node pipe stdout', async t => {31 const {stdout} = await execa.node('test/fixtures/noop', ['foo'], {32 stdout: 'pipe'33 });3435 t.is(stdout, 'foo');36});3738test('node correctly use nodePath', async t => {39 const {stdout} = await execa.node(process.platform === 'win32' ? 'hello.cmd' : 'hello.sh', {40 stdout: 'pipe',41 nodePath: process.platform === 'win32' ? 'cmd.exe' : 'bash',

Rename `nodeArguments` to `nodeOptions` (#299)ehmickybefore adoptionb979534

line 42why, one step back
42 nodeOptions: process.platform === 'win32' ? ['/c'] : []

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

lines 43–47why, one step back
43 });
4445 t.is(stdout, 'Hello World');46});47

Rename `nodeArguments` to `nodeOptions` (#299)ehmickybefore adoptionb979534

line 48why, one step back
48test('node pass on nodeOptions', async t => {

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

lines 49–50why, one step back
49 const {stdout} = await execa.node('console.log("foo")', {
50 stdout: 'pipe',

Rename `nodeArguments` to `nodeOptions` (#299)ehmickybefore adoptionb979534

line 51why, one step back
51 nodeOptions: ['-e']

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

lines 52–55why, one step back
52 });
5354 t.is(stdout, 'foo');55});

Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64

lines 56–92why, one step back
56
57test.serial(58 'node removes --inspect from nodeOptions when defined by parent process',59 inspectMacro,60 '--inspect'61);6263test.serial(64 'node removes --inspect=9222 from nodeOptions when defined by parent process',65 inspectMacro,66 '--inspect=9222'67);6869test.serial(70 'node removes --inspect-brk from nodeOptions when defined by parent process',71 inspectMacro,72 '--inspect-brk'73);7475test.serial(76 'node removes --inspect-brk=9222 from nodeOptions when defined by parent process',77 inspectMacro,78 '--inspect-brk=9222'79);8081test.serial(82 'node should not remove --inspect when passed through nodeOptions',83 async t => {84 const {stdout, stderr} = await execa.node('console.log("foo")', {85 reject: false,86 nodeOptions: ['--inspect', '-e']87 });8889 t.is(stdout, 'foo');90 t.true(stderr.includes('Debugger listening'));91 }92);

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

lines 93–100why, one step back
93
94test('node\'s forked script has a communication channel', async t => {95 const subprocess = execa.node('test/fixtures/send');96 subprocess.send('ping');9798 const message = await pEvent(subprocess, 'message');99 t.is(message, 'pong');100});