Skip to content
Myr

Drop support for Node 12 (#497)

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

authored by ehmicky · committed by GitHub · parent fa9cc05 · Browse files · 9 files+27 added−46 removed
This commit

State

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

Diff stats

9 files+27 added−46 removed

  • tests:+14 added−23 removed
  • other:+13 added−23 removed

9 files+27 added−46 removed

modified:.github/workflows/main.yml+4 added-4 removed
modified:lib/stream.js+1 added-3 removed
modified:test/error.js+1 added-4 removed
77 unmodified lines
78});7980test('Original error.message is kept', async t => {81 const {originalMessage} = await t.throwsAsync(execa('noop.js', {cwd: 1}));82 // On Node >=14.18.0, the error message is83 // `The "options.cwd" property must be of type string or an instance of Buffer or URL. Received type number (1)`84 t.true(originalMessage.startsWith('The "options.cwd" property must be of type string'));82 t.true(originalMessage.startsWith('The "options.cwd" property must be of type string or an instance of Buffer or URL. Received type number'));85 t.true(originalMessage.includes('. Received type number'));83});8485test('failed is false on success', async t => {86 const {failed} = await execa('noop.js', ['foo']);
129 unmodified lines
modified:test/override-promise.js-1 removed
modified:test/test.js+13 added-18 removed
2 unmodified lines
3import {fileURLToPath, pathToFileURL} from 'node:url';4import test from 'ava';5import isRunning from 'is-running';6import getNode from 'get-node';7import semver from 'semver';7import {execa, execaSync} from '../index.js';89process.env.PATH = fileURLToPath(new URL('fixtures', import.meta.url)) + path.delimiter + process.env.PATH;10process.env.FOO = 'foo';
154 unmodified lines
165 await t.throwsAsync(subprocess);166 });167168 test('execa() rejects with correct error and doesn\'t throw if running non-executable with input', async t => {170 // On Node <12.6.0, `EACCESS` is emitted on `childProcess`.171 // On Node >=12.6.0, `EPIPE` is emitted on `childProcess.stdin`.172 await t.throwsAsync(execa('non-executable.js', {input: 'Hey!'}), {message: /EACCES|EPIPE/});169 await t.throwsAsync(execa('non-executable.js', {input: 'Hey!'}), {message: /EACCES/});170 });171}172173if (process.platform !== 'win32') {
29 unmodified lines
203 const {stdout} = await execa('node', ['-p', 'process.cwd()'], {cwd});204 t.is(path.toNamespacedPath(stdout), path.toNamespacedPath(cwd));205});206210if (semver.satisfies(process.version, '^14.18.0 || >=16.4.0')) {211 test('localDir option can be a URL', async t => {212 const command = process.platform === 'win32' ? 'echo %PATH%' : 'echo $PATH';213 const {stdout} = await execa(command, {shell: true, preferLocal: true, localDir: pathToFileURL('/test')});214 const envPaths = stdout.split(path.delimiter);215 t.true(envPaths.some(envPath => envPath.endsWith('.bin')));216 });207test('localDir option can be a URL', async t => {208 const command = process.platform === 'win32' ? 'echo %PATH%' : 'echo $PATH';209 const {stdout} = await execa(command, {shell: true, preferLocal: true, localDir: pathToFileURL('/test')});210 const envPaths = stdout.split(path.delimiter);211 t.true(envPaths.some(envPath => envPath.endsWith('.bin')));212});213218 test('can use `options.cwd` as a URL', async t => {219 const cwd = '/';220 const cwdUrl = pathToFileURL(cwd);221 const {stdout} = await execa('node', ['-p', 'process.cwd()'], {cwd: cwdUrl});222 t.is(path.toNamespacedPath(stdout), path.toNamespacedPath(cwd));223 });224}214test('can use `options.cwd` as a URL', async t => {215 const cwd = '/';216 const cwdUrl = pathToFileURL(cwd);217 const {stdout} = await execa('node', ['-p', 'process.cwd()'], {cwd: cwdUrl});218 t.is(path.toNamespacedPath(stdout), path.toNamespacedPath(cwd));219});220221test('can use `options.shell: true`', async t => {222 const {stdout} = await execa('node test/fixtures/noop.js foo', {shell: true});223 t.is(stdout, 'foo');
24 unmodified lines
modified:index.d.ts+2 added-7 removed
2 unmodified lines
3import {Stream, Readable as ReadableStream} from 'node:stream';45export type StdioOption =6 | 'pipe'7 | 'overlapped'8 | 'ipc'9 | 'ignore'10 | 'inherit'11 | Stream
21 unmodified lines
3334 /**35 Preferred path to find locally installed binaries in (use with `preferLocal`).3636 Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above.3737 @default process.cwd()38 */39 readonly localDir?: string | URL;40
70 unmodified lines
111112 /**113 Current working directory of the child process.114116 Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above.117115 @default process.cwd()116 */117 readonly cwd?: string | URL;118
13 unmodified lines
132 Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.133134 @default 'pipe'135 */139 readonly stdio?: 'pipe' | 'ignore' | 'inherit' | readonly StdioOption[];136 readonly stdio?: 'pipe' | 'overlapped' | 'ignore' | 'inherit' | readonly StdioOption[];137138 /**139 Specify the kind of serialization used for sending messages between processes when using the `stdio: 'ipc'` option or `execaNode()`:140 - `json`: Uses `JSON.stringify()` and `JSON.parse()`.141 - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)142146 Requires Node.js `13.2.0` or later.147143 [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)144145 @default 'json'146 */
435 unmodified lines
modified:index.test-d.ts+5 added-1 removed
95 unmodified lines
96execa('unicorns', {input: ''});97execa('unicorns', {input: Buffer.from('')});98execa('unicorns', {input: process.stdin});99execa('unicorns', {stdin: 'pipe'});100execa('unicorns', {stdin: 'overlapped'});101execa('unicorns', {stdin: 'ipc'});102execa('unicorns', {stdin: 'ignore'});103execa('unicorns', {stdin: 'inherit'});104execa('unicorns', {stdin: process.stdin});105execa('unicorns', {stdin: 1});106execa('unicorns', {stdin: undefined});107execa('unicorns', {stdout: 'pipe'});108execa('unicorns', {stdout: 'overlapped'});109execa('unicorns', {stdout: 'ipc'});110execa('unicorns', {stdout: 'ignore'});111execa('unicorns', {stdout: 'inherit'});112execa('unicorns', {stdout: process.stdout});113execa('unicorns', {stdout: 1});114execa('unicorns', {stdout: undefined});115execa('unicorns', {stderr: 'pipe'});116execa('unicorns', {stderr: 'overlapped'});117execa('unicorns', {stderr: 'ipc'});118execa('unicorns', {stderr: 'ignore'});119execa('unicorns', {stderr: 'inherit'});120execa('unicorns', {stderr: process.stderr});
8 unmodified lines
129// eslint-disable-next-line @typescript-eslint/naming-convention130execa('unicorns', {env: {PATH: ''}});131execa('unicorns', {argv0: ''});132execa('unicorns', {stdio: 'pipe'});133execa('unicorns', {stdio: 'overlapped'});134execa('unicorns', {stdio: 'ignore'});135execa('unicorns', {stdio: 'inherit'});136execa('unicorns', {133 stdio: ['pipe', 'ipc', 'ignore', 'inherit', process.stdin, 1, undefined],137 stdio: ['pipe', 'overlapped', 'ipc', 'ignore', 'inherit', process.stdin, 1, undefined],138});139execa('unicorns', {serialization: 'advanced'});140execa('unicorns', {detached: true});141execa('unicorns', {uid: 0});
71 unmodified lines
modified:package.json+1 added-2 removed
11 unmodified lines
12 },13 "type": "module",14 "exports": "./index.js",15 "engines": {16 "node": "^12.20.0 || ^14.13.1 || >=16.0.0"16 "node": "^14.18.0 || ^16.14.0 || >=18.0.0"17 },18 "scripts": {19 "test": "xo && c8 ava && tsd"20 },
36 unmodified lines
57 "c8": "^7.11.0",58 "get-node": "^12.0.0",59 "is-running": "^2.1.0",60 "p-event": "^5.0.1",61 "semver": "^7.3.5",61 "tempfile": "^4.0.0",62 "tsd": "^0.19.1",63 "xo": "^0.48.0"64 },
18 unmodified lines
modified:readme.md-6 removed
359 unmodified lines
360Default: `process.cwd()`361362Preferred path to find locally installed binaries in (use with `preferLocal`).363364Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above.365364#### execPath365366Type: `string`\367Default: `process.execPath` (Current Node.js executable)
81 unmodified lines
449Default: `process.cwd()`450451Current working directory of the child process.452455Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above.456453#### env454455Type: `object`\456Default: `process.env`
21 unmodified lines
478Specify the kind of serialization used for sending messages between processes when using the [`stdio: 'ipc'`](#stdio) option or [`execaNode()`](#execanodescriptpath-arguments-options):479 - `json`: Uses `JSON.stringify()` and `JSON.parse()`.480 - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)481486Requires Node.js `13.2.0` or later.487482[More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)483484#### detached485
176 unmodified lines