Skip to content

Commit a09cbc0

Browse files
authored
Drop support for Node 12 (#497)
1 parent fa9cc05 commit a09cbc0

File tree

9 files changed

+27
-46
lines changed

9 files changed

+27
-46
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13+
- 18
1314
- 16
1415
- 14
15-
- 12
1616
os:
1717
- ubuntu-latest
1818
- macos-latest
1919
# - windows-latest
2020
steps:
21-
- uses: actions/checkout@v2
22-
- uses: actions/setup-node@v2
21+
- uses: actions/checkout@v3
22+
- uses: actions/setup-node@v3
2323
with:
2424
node-version: ${{ matrix.node-version }}
2525
- run: npm install
2626
- run: npm test
2727
- uses: codecov/codecov-action@v2
28-
if: matrix.os == 'ubuntu-latest' && matrix.node-version == 16
28+
if: matrix.os == 'ubuntu-latest' && matrix.node-version == 18
2929
with:
3030
fail_ci_if_error: true

index.d.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {Stream, Readable as ReadableStream} from 'node:stream';
44

55
export type StdioOption =
66
| 'pipe'
7+
| 'overlapped'
78
| 'ipc'
89
| 'ignore'
910
| 'inherit'
@@ -33,8 +34,6 @@ export interface CommonOptions<EncodingType> {
3334
/**
3435
Preferred path to find locally installed binaries in (use with `preferLocal`).
3536
36-
Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above.
37-
3837
@default process.cwd()
3938
*/
4039
readonly localDir?: string | URL;
@@ -113,8 +112,6 @@ export interface CommonOptions<EncodingType> {
113112
/**
114113
Current working directory of the child process.
115114
116-
Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above.
117-
118115
@default process.cwd()
119116
*/
120117
readonly cwd?: string | URL;
@@ -136,15 +133,13 @@ export interface CommonOptions<EncodingType> {
136133
137134
@default 'pipe'
138135
*/
139-
readonly stdio?: 'pipe' | 'ignore' | 'inherit' | readonly StdioOption[];
136+
readonly stdio?: 'pipe' | 'overlapped' | 'ignore' | 'inherit' | readonly StdioOption[];
140137

141138
/**
142139
Specify the kind of serialization used for sending messages between processes when using the `stdio: 'ipc'` option or `execaNode()`:
143140
- `json`: Uses `JSON.stringify()` and `JSON.parse()`.
144141
- `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)
145142
146-
Requires Node.js `13.2.0` or later.
147-
148143
[More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)
149144
150145
@default 'json'

index.test-d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,23 @@ execa('unicorns', {input: ''});
9797
execa('unicorns', {input: Buffer.from('')});
9898
execa('unicorns', {input: process.stdin});
9999
execa('unicorns', {stdin: 'pipe'});
100+
execa('unicorns', {stdin: 'overlapped'});
100101
execa('unicorns', {stdin: 'ipc'});
101102
execa('unicorns', {stdin: 'ignore'});
102103
execa('unicorns', {stdin: 'inherit'});
103104
execa('unicorns', {stdin: process.stdin});
104105
execa('unicorns', {stdin: 1});
105106
execa('unicorns', {stdin: undefined});
106107
execa('unicorns', {stdout: 'pipe'});
108+
execa('unicorns', {stdout: 'overlapped'});
107109
execa('unicorns', {stdout: 'ipc'});
108110
execa('unicorns', {stdout: 'ignore'});
109111
execa('unicorns', {stdout: 'inherit'});
110112
execa('unicorns', {stdout: process.stdout});
111113
execa('unicorns', {stdout: 1});
112114
execa('unicorns', {stdout: undefined});
113115
execa('unicorns', {stderr: 'pipe'});
116+
execa('unicorns', {stderr: 'overlapped'});
114117
execa('unicorns', {stderr: 'ipc'});
115118
execa('unicorns', {stderr: 'ignore'});
116119
execa('unicorns', {stderr: 'inherit'});
@@ -127,10 +130,11 @@ execa('unicorns', {cwd: new URL('file:///test')});
127130
execa('unicorns', {env: {PATH: ''}});
128131
execa('unicorns', {argv0: ''});
129132
execa('unicorns', {stdio: 'pipe'});
133+
execa('unicorns', {stdio: 'overlapped'});
130134
execa('unicorns', {stdio: 'ignore'});
131135
execa('unicorns', {stdio: 'inherit'});
132136
execa('unicorns', {
133-
stdio: ['pipe', 'ipc', 'ignore', 'inherit', process.stdin, 1, undefined],
137+
stdio: ['pipe', 'overlapped', 'ipc', 'ignore', 'inherit', process.stdin, 1, undefined],
134138
});
135139
execa('unicorns', {serialization: 'advanced'});
136140
execa('unicorns', {detached: true});

lib/stream.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import mergeStream from 'merge-stream';
44

55
// `input` option
66
export const handleInput = (spawned, input) => {
7-
// Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852
8-
// @todo remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0
9-
if (input === undefined || spawned.stdin === undefined) {
7+
if (input === undefined) {
108
return;
119
}
1210

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"type": "module",
1414
"exports": "./index.js",
1515
"engines": {
16-
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
16+
"node": "^14.18.0 || ^16.14.0 || >=18.0.0"
1717
},
1818
"scripts": {
1919
"test": "xo && c8 ava && tsd"
@@ -58,7 +58,6 @@
5858
"get-node": "^12.0.0",
5959
"is-running": "^2.1.0",
6060
"p-event": "^5.0.1",
61-
"semver": "^7.3.5",
6261
"tempfile": "^4.0.0",
6362
"tsd": "^0.19.1",
6463
"xo": "^0.48.0"

readme.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,6 @@ Default: `process.cwd()`
361361

362362
Preferred path to find locally installed binaries in (use with `preferLocal`).
363363

364-
Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above.
365-
366364
#### execPath
367365

368366
Type: `string`\
@@ -452,8 +450,6 @@ Default: `process.cwd()`
452450

453451
Current working directory of the child process.
454452

455-
Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above.
456-
457453
#### env
458454

459455
Type: `object`\
@@ -483,8 +479,6 @@ Specify the kind of serialization used for sending messages between processes wh
483479
- `json`: Uses `JSON.stringify()` and `JSON.parse()`.
484480
- `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)
485481

486-
Requires Node.js `13.2.0` or later.
487-
488482
[More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)
489483

490484
#### detached

test/error.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ test('error.shortMessage does not contain stdout/stderr', async t => {
7979

8080
test('Original error.message is kept', async t => {
8181
const {originalMessage} = await t.throwsAsync(execa('noop.js', {cwd: 1}));
82-
// On Node >=14.18.0, the error message is
83-
// `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'));
85-
t.true(originalMessage.includes('. Received type number'));
82+
t.true(originalMessage.startsWith('The "options.cwd" property must be of type string or an instance of Buffer or URL. Received type number'));
8683
});
8784

8885
test('failed is false on success', async t => {

test/override-promise.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import process from 'node:process';
33
import {fileURLToPath} from 'node:url';
44
import test from 'ava';
55
// The helper module overrides Promise on import so has to be imported before `execa`.
6-
// Can't use top-level await (TLA) + `import(…)` since Node.js 12 doesn't support TLA.
76
import {restorePromise} from './helpers/override-promise.js';
87
// eslint-disable-next-line import/order
98
import {execa} from '../index.js';

test/test.js

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {fileURLToPath, pathToFileURL} from 'node:url';
44
import test from 'ava';
55
import isRunning from 'is-running';
66
import getNode from 'get-node';
7-
import semver from 'semver';
87
import {execa, execaSync} from '../index.js';
98

109
process.env.PATH = fileURLToPath(new URL('fixtures', import.meta.url)) + path.delimiter + process.env.PATH;
@@ -167,9 +166,7 @@ if (process.platform !== 'win32') {
167166
});
168167

169168
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/});
173170
});
174171
}
175172

@@ -207,21 +204,19 @@ test('can use `options.cwd` as a string', async t => {
207204
t.is(path.toNamespacedPath(stdout), path.toNamespacedPath(cwd));
208205
});
209206

210-
if (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-
});
207+
test('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+
});
217213

218-
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-
}
214+
test('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+
});
225220

226221
test('can use `options.shell: true`', async t => {
227222
const {stdout} = await execa('node test/fixtures/noop.js foo', {shell: true});

0 commit comments

Comments
 (0)