Skip to content

Commit

Permalink
Require Node.js 16 (#569)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
  • Loading branch information
ehmicky and sindresorhus authored Aug 5, 2023
1 parent db58085 commit 65992b4
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
fail-fast: false
matrix:
node-version:
- 20
- 18
- 16
- 14
os:
- ubuntu-latest
- macos-latest
Expand All @@ -25,6 +25,6 @@ jobs:
- run: npm install
- run: npm test
- uses: codecov/codecov-action@v2
if: matrix.os == 'ubuntu-latest' && matrix.node-version == 18
if: matrix.os == 'ubuntu-latest' && matrix.node-version == 20
with:
fail_ci_if_error: true
2 changes: 0 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ export type CommonOptions<EncodingType> = {
When `AbortController.abort()` is called, [`.isCanceled`](https://github.com/sindresorhus/execa#iscanceled) becomes `false`.
*Requires Node.js 16 or later.*
@example
```
import {execa} from 'execa';
Expand Down
7 changes: 3 additions & 4 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ const normalizeArgs = (file, args = []) => {
};

const NO_ESCAPE_REGEXP = /^[\w.-]+$/;
const DOUBLE_QUOTES_REGEXP = /"/g;

const escapeArg = arg => {
if (typeof arg !== 'string' || NO_ESCAPE_REGEXP.test(arg)) {
return arg;
}

return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`;
return `"${arg.replaceAll('"', '\\"')}"`;
};

export const joinCommand = (file, args) => normalizeArgs(file, args).join(' ');
Expand All @@ -31,7 +30,7 @@ export const parseCommand = command => {
const tokens = [];
for (const token of command.trim().split(SPACES_REGEXP)) {
// Allow spaces to be escaped by a backslash if not meant as a delimiter
const previousToken = tokens[tokens.length - 1];
const previousToken = tokens.at(-1);
if (previousToken && previousToken.endsWith('\\')) {
// Merge previous token with current one
tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;
Expand Down Expand Up @@ -80,7 +79,7 @@ const concatTokens = (tokens, nextTokens, isNew) => isNew || tokens.length === 0
? [...tokens, ...nextTokens]
: [
...tokens.slice(0, -1),
`${tokens[tokens.length - 1]}${nextTokens[0]}`,
`${tokens.at(-1)}${nextTokens[0]}`,
...nextTokens.slice(1),
];

Expand Down
23 changes: 13 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"engines": {
"node": "^14.18.0 || ^16.14.0 || >=18.0.0"
"node": ">=16.17"
},
"scripts": {
"test": "xo && c8 ava && tsd"
Expand Down Expand Up @@ -44,7 +47,7 @@
"dependencies": {
"cross-spawn": "^7.0.3",
"get-stream": "^6.0.1",
"human-signals": "^4.3.0",
"human-signals": "^5.0.0",
"is-stream": "^3.0.0",
"merge-stream": "^2.0.0",
"npm-run-path": "^5.1.0",
Expand All @@ -53,16 +56,16 @@
"strip-final-newline": "^3.0.0"
},
"devDependencies": {
"@types/node": "^18.13.0",
"@types/node": "^20.4.0",
"ava": "^5.2.0",
"c8": "^7.12.0",
"get-node": "^13.5.0",
"c8": "^8.0.1",
"get-node": "^14.2.0",
"is-running": "^2.1.0",
"p-event": "^5.0.1",
"p-event": "^6.0.0",
"path-key": "^4.0.0",
"tempfile": "^4.0.0",
"tsd": "^0.25.0",
"xo": "^0.54.2"
"tempfile": "^5.0.0",
"tsd": "^0.28.1",
"xo": "^0.55.0"
},
"c8": {
"reporter": [
Expand Down
2 changes: 0 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,6 @@ You can abort the spawned process using [`AbortController`](https://developer.mo

When `AbortController.abort()` is called, [`.isCanceled`](#iscanceled) becomes `false`.

*Requires Node.js 16 or later.*

#### windowsVerbatimArguments

Type: `boolean`\
Expand Down
2 changes: 1 addition & 1 deletion test/pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test('pipeAll() can pipe stdout to streams', pipeToStream, 'noop.js', 'pipeAll',
test('pipeAll() can pipe stderr to streams', pipeToStream, 'noop-err.js', 'pipeAll', 'stderr');

const pipeToFile = async (t, fixtureName, funcName, streamName) => {
const file = tempfile('.txt');
const file = tempfile({extension: '.txt'});
const result = await execa(fixtureName, ['test'], {all: true})[funcName](file);
t.is(result[streamName], 'test');
t.is(await readFile(file, 'utf8'), 'test\n');
Expand Down
4 changes: 2 additions & 2 deletions test/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ test('buffer', async t => {
});

test('pass `stdout` to a file descriptor', async t => {
const file = tempfile('.txt');
const file = tempfile({extension: '.txt'});
await execa('noop.js', ['foo bar'], {stdout: fs.openSync(file, 'w')});
t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');
});

test('pass `stderr` to a file descriptor', async t => {
const file = tempfile('.txt');
const file = tempfile({extension: '.txt'});
await execa('noop-err.js', ['foo bar'], {stderr: fs.openSync(file, 'w')});
t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');
});
Expand Down
2 changes: 1 addition & 1 deletion test/verbose.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {setFixtureDir} from './helpers/fixtures-dir.js';

setFixtureDir();

const normalizeTimestamp = output => output.replace(/\d/g, '0');
const normalizeTimestamp = output => output.replaceAll(/\d/g, '0');
const testTimestamp = '[00:00:00.000]';

test('Prints command when "verbose" is true', async t => {
Expand Down

0 comments on commit 65992b4

Please sign in to comment.