Skip to content

Commit dc6c964

Browse files
committed
Require Node.js 18
Fixes #22
1 parent f74c53f commit dc6c964

File tree

6 files changed

+31
-34
lines changed

6 files changed

+31
-34
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13-
- 16
14-
- 14
15-
- 12
13+
- 20
14+
- 18
1615
os:
1716
- ubuntu-latest
1817
- macos-latest
1918
- windows-latest
2019
steps:
21-
- uses: actions/checkout@v2
22-
- uses: actions/setup-node@v2
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-node@v4
2322
with:
2423
node-version: ${{ matrix.node-version }}
2524
- run: npm install

api.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export default function replaceInFiles(
22
path: string | string[],
33
options: {
4-
find: Array<string | RegExp>,
5-
replacement: string,
6-
ignoreCase?: boolean,
7-
glob?: boolean
4+
find: Array<string | RegExp>;
5+
replacement: string;
6+
ignoreCase?: boolean;
7+
glob?: boolean;
88
},
99
): Promise<void>;

api.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ export default async function replaceInFiler(filePaths, {find, replacement, igno
2828

2929
// Replace the replacement string with the string unescaped (only one backslash) if it's escaped
3030
replacement = replacement
31-
.replace(/\\n/g, '\n')
32-
.replace(/\\r/g, '\r')
33-
.replace(/\\t/g, '\t');
31+
.replaceAll('\\n', '\n')
32+
.replaceAll('\\r', '\r')
33+
.replaceAll('\\t', '\t');
3434

35-
// TODO: Drop the `normalizePath` call when https://github.com/mrmlnc/fast-glob/issues/240 is fixed.
35+
// TODO: Drop the `normalizePath` call when `convertPathToPattern` from `fast-glob` is added to globby.
3636
filePaths = glob ? await globby(filePaths.map(filePath => normalizePath(filePath))) : [...new Set(filePaths.map(filePath => normalizePath(path.resolve(filePath))))];
3737

3838
find = find.map(element => {

cli.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,12 @@ if (!cli.flags.regex && !cli.flags.string) {
5656
process.exit(1);
5757
}
5858

59-
(async () => {
60-
await replaceInFiles(cli.input, {
61-
find: [
62-
...cli.flags.string,
63-
...cli.flags.regex.map(regexString => new RegExp(regexString, 'g')),
64-
],
65-
replacement: cli.flags.replacement,
66-
ignoreCase: cli.flags.ignoreCase,
67-
glob: cli.flags.glob,
68-
});
69-
})();
59+
await replaceInFiles(cli.input, {
60+
find: [
61+
...cli.flags.string,
62+
...cli.flags.regex.map(regexString => new RegExp(regexString, 'g')),
63+
],
64+
replacement: cli.flags.replacement,
65+
ignoreCase: cli.flags.ignoreCase,
66+
glob: cli.flags.glob,
67+
});

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
"bin": {
1919
"replace-in-files": "./cli.js"
2020
},
21+
"sideEffects": false,
2122
"engines": {
22-
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
23+
"node": ">=18"
2324
},
2425
"scripts": {
25-
"//test": "xo && ava",
26-
"test": "ava"
26+
"test": "xo && ava"
2727
},
2828
"files": [
2929
"cli.js",
@@ -50,15 +50,15 @@
5050
],
5151
"dependencies": {
5252
"escape-string-regexp": "^5.0.0",
53-
"globby": "^12.0.2",
54-
"meow": "^10.1.1",
53+
"globby": "^14.0.1",
54+
"meow": "^13.2.0",
5555
"normalize-path": "^3.0.0",
56-
"write-file-atomic": "^3.0.3"
56+
"write-file-atomic": "^5.0.1"
5757
},
5858
"devDependencies": {
59-
"ava": "^3.15.0",
60-
"execa": "^5.1.1",
59+
"ava": "^6.1.3",
60+
"execa": "^9.3.0",
6161
"temp-write": "^5.0.0",
62-
"xo": "^0.46.4"
62+
"xo": "^0.58.0"
6363
}
6464
}

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'node:fs';
22
import path from 'node:path';
33
import process from 'node:process';
44
import test from 'ava';
5-
import execa from 'execa';
5+
import {execa} from 'execa';
66
import tempWrite from 'temp-write';
77

88
test('--string', async t => {

0 commit comments

Comments
 (0)