Skip to content
Myr

Improve validation of `execaSync()` options (#940)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent 8f97132 · Browse files · 5 files+54 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+54 added−6 removed

  • tests:+26 added−2 removed
  • other:+28 added−4 removed

5 files+54 added−6 removed

modified:lib/stdio/sync.js+14 added-2 removed
modified:lib/sync.js+14 added-2 removed
modified:test/exit/cancel.js+8 added-1 removed
78 unmodified lines
7980test('Throws when using the former "signal" option name', t => {81 const abortController = new AbortController();82 t.throws(() => {83 execa('noop.js', {signal: abortController.signal});83 execa('empty.js', {signal: abortController.signal});84 }, {message: /renamed to "cancelSignal"/});85});8687test('Cannot use cancelSignal, sync', t => {88 const abortController = new AbortController();89 t.throws(() => {90 execaSync('empty.js', {cancelSignal: abortController.signal});91 }, {message: /The "cancelSignal" option cannot be used/});92});
modified:test/exit/cleanup.js+7 added-1 removed
1 unmodified line
2import {setTimeout} from 'node:timers/promises';3import test from 'ava';4import {pEvent} from 'p-event';5import isRunning from 'is-running';6import {execa} from '../../index.js';6import {execa, execaSync} from '../../index.js';7import {setFixtureDir} from '../helpers/fixtures-dir.js';89setFixtureDir();10
75 unmodified lines
86 t.true(isRunning(pid));8788 process.kill(pid, 'SIGKILL');89});9091test('Cannot use "detached" option, sync', t => {92 t.throws(() => {93 execaSync('empty.js', {detached: true});94 }, {message: /The "detached: true" option cannot be used/});95});
modified:test/stdio/handle.js+11 added
61 unmodified lines
62test('stdio[*] can be ["inherit"]', testNoPipeOption, ['inherit'], 3);63test('stdio[*] can be 3', testNoPipeOption, 3, 3);64test('stdio[*] can be [3]', testNoPipeOption, [3], 3);6566const testNoIpcSync = (t, fdNumber) => {67 t.throws(() => {68 execaSync('empty.js', getStdio(fdNumber, 'ipc'));69 }, {message: /cannot be "ipc" in sync mode/});70};7172test('stdin cannot be "ipc", sync', testNoIpcSync, 0);73test('stdout cannot be "ipc", sync', testNoIpcSync, 1);74test('stderr cannot be "ipc", sync', testNoIpcSync, 2);75test('stdio[*] cannot be "ipc", sync', testNoIpcSync, 3);7677const testInvalidArrayValue = (t, invalidStdio, fdNumber, execaMethod) => {78 t.throws(() => {79 execaMethod('empty.js', getStdio(fdNumber, ['pipe', invalidStdio]));80 }, {message: /must not include/});
18 unmodified lines