-
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
103 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#!/usr/bin/env node | ||
import {once} from 'node:events'; | ||
import {getCancelSignal} from 'execa'; | ||
|
||
const cancelSignal = await getCancelSignal(); | ||
once(cancelSignal, 'abort'); | ||
cancelSignal.addEventListener('abort', () => {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import {version} from 'node:process'; | ||
|
||
export const majorNodeVersion = Number(version.split('.')[0].slice(1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import test from 'ava'; | ||
import {execa, execaSync} from '../../index.js'; | ||
import {getStdio} from '../helpers/stdio.js'; | ||
import {noopGenerator} from '../helpers/generator.js'; | ||
import {generatorsMap} from '../helpers/map.js'; | ||
import {setFixtureDirectory} from '../helpers/fixtures-directory.js'; | ||
|
||
setFixtureDirectory(); | ||
|
||
const testInvalidGenerator = (t, fdNumber, stdioOption, execaMethod) => { | ||
t.throws(() => { | ||
execaMethod('empty.js', getStdio(fdNumber, {...noopGenerator(), ...stdioOption})); | ||
}, {message: 'final' in stdioOption ? /must be a generator/ : /must be a generator, a Duplex stream or a web TransformStream/}); | ||
}; | ||
|
||
test('Cannot use invalid "transform" with stdin', testInvalidGenerator, 0, {transform: true}, execa); | ||
test('Cannot use invalid "transform" with stdout', testInvalidGenerator, 1, {transform: true}, execa); | ||
test('Cannot use invalid "transform" with stderr', testInvalidGenerator, 2, {transform: true}, execa); | ||
test('Cannot use invalid "transform" with stdio[*]', testInvalidGenerator, 3, {transform: true}, execa); | ||
test('Cannot use invalid "final" with stdin', testInvalidGenerator, 0, {final: true}, execa); | ||
test('Cannot use invalid "final" with stdout', testInvalidGenerator, 1, {final: true}, execa); | ||
test('Cannot use invalid "final" with stderr', testInvalidGenerator, 2, {final: true}, execa); | ||
test('Cannot use invalid "final" with stdio[*]', testInvalidGenerator, 3, {final: true}, execa); | ||
test('Cannot use invalid "transform" with stdin, sync', testInvalidGenerator, 0, {transform: true}, execaSync); | ||
test('Cannot use invalid "transform" with stdout, sync', testInvalidGenerator, 1, {transform: true}, execaSync); | ||
test('Cannot use invalid "transform" with stderr, sync', testInvalidGenerator, 2, {transform: true}, execaSync); | ||
test('Cannot use invalid "transform" with stdio[*], sync', testInvalidGenerator, 3, {transform: true}, execaSync); | ||
test('Cannot use invalid "final" with stdin, sync', testInvalidGenerator, 0, {final: true}, execaSync); | ||
test('Cannot use invalid "final" with stdout, sync', testInvalidGenerator, 1, {final: true}, execaSync); | ||
test('Cannot use invalid "final" with stderr, sync', testInvalidGenerator, 2, {final: true}, execaSync); | ||
test('Cannot use invalid "final" with stdio[*], sync', testInvalidGenerator, 3, {final: true}, execaSync); | ||
|
||
// eslint-disable-next-line max-params | ||
const testInvalidBinary = (t, fdNumber, optionName, type, execaMethod) => { | ||
t.throws(() => { | ||
execaMethod('empty.js', getStdio(fdNumber, {...generatorsMap[type].uppercase(), [optionName]: 'true'})); | ||
}, {message: /a boolean/}); | ||
}; | ||
|
||
test('Cannot use invalid "binary" with stdin', testInvalidBinary, 0, 'binary', 'generator', execa); | ||
test('Cannot use invalid "binary" with stdout', testInvalidBinary, 1, 'binary', 'generator', execa); | ||
test('Cannot use invalid "binary" with stderr', testInvalidBinary, 2, 'binary', 'generator', execa); | ||
test('Cannot use invalid "binary" with stdio[*]', testInvalidBinary, 3, 'binary', 'generator', execa); | ||
test('Cannot use invalid "objectMode" with stdin, generators', testInvalidBinary, 0, 'objectMode', 'generator', execa); | ||
test('Cannot use invalid "objectMode" with stdout, generators', testInvalidBinary, 1, 'objectMode', 'generator', execa); | ||
test('Cannot use invalid "objectMode" with stderr, generators', testInvalidBinary, 2, 'objectMode', 'generator', execa); | ||
test('Cannot use invalid "objectMode" with stdio[*], generators', testInvalidBinary, 3, 'objectMode', 'generator', execa); | ||
test('Cannot use invalid "binary" with stdin, sync', testInvalidBinary, 0, 'binary', 'generator', execaSync); | ||
test('Cannot use invalid "binary" with stdout, sync', testInvalidBinary, 1, 'binary', 'generator', execaSync); | ||
test('Cannot use invalid "binary" with stderr, sync', testInvalidBinary, 2, 'binary', 'generator', execaSync); | ||
test('Cannot use invalid "binary" with stdio[*], sync', testInvalidBinary, 3, 'binary', 'generator', execaSync); | ||
test('Cannot use invalid "objectMode" with stdin, generators, sync', testInvalidBinary, 0, 'objectMode', 'generator', execaSync); | ||
test('Cannot use invalid "objectMode" with stdout, generators, sync', testInvalidBinary, 1, 'objectMode', 'generator', execaSync); | ||
test('Cannot use invalid "objectMode" with stderr, generators, sync', testInvalidBinary, 2, 'objectMode', 'generator', execaSync); | ||
test('Cannot use invalid "objectMode" with stdio[*], generators, sync', testInvalidBinary, 3, 'objectMode', 'generator', execaSync); | ||
test('Cannot use invalid "objectMode" with stdin, duplexes', testInvalidBinary, 0, 'objectMode', 'duplex', execa); | ||
test('Cannot use invalid "objectMode" with stdout, duplexes', testInvalidBinary, 1, 'objectMode', 'duplex', execa); | ||
test('Cannot use invalid "objectMode" with stderr, duplexes', testInvalidBinary, 2, 'objectMode', 'duplex', execa); | ||
test('Cannot use invalid "objectMode" with stdio[*], duplexes', testInvalidBinary, 3, 'objectMode', 'duplex', execa); | ||
test('Cannot use invalid "objectMode" with stdin, webTransforms', testInvalidBinary, 0, 'objectMode', 'webTransform', execa); | ||
test('Cannot use invalid "objectMode" with stdout, webTransforms', testInvalidBinary, 1, 'objectMode', 'webTransform', execa); | ||
test('Cannot use invalid "objectMode" with stderr, webTransforms', testInvalidBinary, 2, 'objectMode', 'webTransform', execa); | ||
test('Cannot use invalid "objectMode" with stdio[*], webTransforms', testInvalidBinary, 3, 'objectMode', 'webTransform', execa); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters