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
Provenance
- Commit
a09cbc0- Tree
071a0ee- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
fa9cc05
9 files changed+27 added−46 removed
modified:.github/workflows/main.yml+4 added-4 removed
8 unmodified lines9101112131415151617181920212221222324252627282829308 unmodified lines strategy: fail-fast: false matrix: node-version: - 18 - 16 - 14 - 12 os: - ubuntu-latest - macos-latest # - windows-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test - uses: codecov/codecov-action@v2 if: matrix.os == 'ubuntu-latest' && matrix.node-version == 16 if: matrix.os == 'ubuntu-latest' && matrix.node-version == 18 with: fail_ci_if_error: truemodified:lib/stream.js+1 added-3 removed
2 unmodified lines3456789789101175 unmodified lines2 unmodified linesimport mergeStream from 'merge-stream';
// `input` optionexport const handleInput = (spawned, input) => { // Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852 // @todo remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0 if (input === undefined || spawned.stdin === undefined) { if (input === undefined) { return; }
if (isStream(input)) {75 unmodified linesmodified:test/error.js+1 added-4 removed
77 unmodified lines78 });79 80 test('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 });84 85 test('failed is false on success', async t => {86 const {failed} = await execa('noop.js', ['foo']);129 unmodified linesmodified:test/override-promise.js-1 removed
12345667898 unmodified linesimport path from 'node:path';import process from 'node:process';import {fileURLToPath} from 'node:url';import test from 'ava';// The helper module overrides Promise on import so has to be imported before `execa`.// Can't use top-level await (TLA) + `import(…)` since Node.js 12 doesn't support TLA.import {restorePromise} from './helpers/override-promise.js';// eslint-disable-next-line import/orderimport {execa} from '../index.js';
8 unmodified linesmodified:test/test.js+13 added-18 removed
2 unmodified lines3 import {fileURLToPath, pathToFileURL} from 'node:url';4 import test from 'ava';5 import isRunning from 'is-running';6 import getNode from 'get-node';7-import semver from 'semver';7 import {execa, execaSync} from '../index.js';8 9 process.env.PATH = fileURLToPath(new URL('fixtures', import.meta.url)) + path.delimiter + process.env.PATH;10 process.env.FOO = 'foo';154 unmodified lines165 await t.throwsAsync(subprocess);166 });167 168 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 }172 173 if (process.platform !== 'win32') {29 unmodified lines203 const {stdout} = await execa('node', ['-p', 'process.cwd()'], {cwd});204 t.is(path.toNamespacedPath(stdout), path.toNamespacedPath(cwd));205 });206 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+});213 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+});220 221 test('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 linesmodified:index.d.ts+2 added-7 removed
2 unmodified lines3 import {Stream, Readable as ReadableStream} from 'node:stream';4 5 export type StdioOption =6 | 'pipe'7+ | 'overlapped'8 | 'ipc'9 | 'ignore'10 | 'inherit'11 | Stream21 unmodified lines33 34 /**35 Preferred path to find locally installed binaries in (use with `preferLocal`).36 36- Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above.37-37 @default process.cwd()38 */39 readonly localDir?: string | URL;40 70 unmodified lines111 112 /**113 Current working directory of the child process.114 116- Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above.117-115 @default process.cwd()116 */117 readonly cwd?: string | URL;118 13 unmodified lines132 Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.133 134 @default 'pipe'135 */139- readonly stdio?: 'pipe' | 'ignore' | 'inherit' | readonly StdioOption[];136+ readonly stdio?: 'pipe' | 'overlapped' | 'ignore' | 'inherit' | readonly StdioOption[];137 138 /**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)142 146- Requires Node.js `13.2.0` or later.147-143 [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)144 145 @default 'json'146 */435 unmodified linesmodified:index.test-d.ts+5 added-1 removed
95 unmodified lines96 execa('unicorns', {input: ''});97 execa('unicorns', {input: Buffer.from('')});98 execa('unicorns', {input: process.stdin});99 execa('unicorns', {stdin: 'pipe'});100+execa('unicorns', {stdin: 'overlapped'});101 execa('unicorns', {stdin: 'ipc'});102 execa('unicorns', {stdin: 'ignore'});103 execa('unicorns', {stdin: 'inherit'});104 execa('unicorns', {stdin: process.stdin});105 execa('unicorns', {stdin: 1});106 execa('unicorns', {stdin: undefined});107 execa('unicorns', {stdout: 'pipe'});108+execa('unicorns', {stdout: 'overlapped'});109 execa('unicorns', {stdout: 'ipc'});110 execa('unicorns', {stdout: 'ignore'});111 execa('unicorns', {stdout: 'inherit'});112 execa('unicorns', {stdout: process.stdout});113 execa('unicorns', {stdout: 1});114 execa('unicorns', {stdout: undefined});115 execa('unicorns', {stderr: 'pipe'});116+execa('unicorns', {stderr: 'overlapped'});117 execa('unicorns', {stderr: 'ipc'});118 execa('unicorns', {stderr: 'ignore'});119 execa('unicorns', {stderr: 'inherit'});120 execa('unicorns', {stderr: process.stderr});8 unmodified lines129 // eslint-disable-next-line @typescript-eslint/naming-convention130 execa('unicorns', {env: {PATH: ''}});131 execa('unicorns', {argv0: ''});132 execa('unicorns', {stdio: 'pipe'});133+execa('unicorns', {stdio: 'overlapped'});134 execa('unicorns', {stdio: 'ignore'});135 execa('unicorns', {stdio: 'inherit'});136 execa('unicorns', {133- stdio: ['pipe', 'ipc', 'ignore', 'inherit', process.stdin, 1, undefined],137+ stdio: ['pipe', 'overlapped', 'ipc', 'ignore', 'inherit', process.stdin, 1, undefined],138 });139 execa('unicorns', {serialization: 'advanced'});140 execa('unicorns', {detached: true});141 execa('unicorns', {uid: 0});71 unmodified linesmodified:package.json+1 added-2 removed
11 unmodified lines12 },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 lines57 "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 linesmodified:readme.md-6 removed
359 unmodified lines360 Default: `process.cwd()`361 362 Preferred path to find locally installed binaries in (use with `preferLocal`).363 364-Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above.365-364 #### execPath365 366 Type: `string`\367 Default: `process.execPath` (Current Node.js executable)81 unmodified lines449 Default: `process.cwd()`450 451 Current working directory of the child process.452 455-Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above.456-453 #### env454 455 Type: `object`\456 Default: `process.env`21 unmodified lines478 Specify 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)481 486-Requires Node.js `13.2.0` or later.487-482 [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)483 484 #### detached485 176 unmodified lines