Skip to content

Commit 3ef8d0a

Browse files
authored
Upgrade Node.js version and dependencies (#19)
1 parent 92a572f commit 3ef8d0a

File tree

4 files changed

+34
-23
lines changed

4 files changed

+34
-23
lines changed

.github/workflows/main.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13-
- 16
13+
- 22
14+
- 18
1415
steps:
1516
- uses: actions/checkout@v4
1617
- uses: actions/setup-node@v4

index.test-d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import process from 'node:process';
22
import {expectType, expectError} from 'tsd';
3-
import {npmRunPath, npmRunPathEnv, ProcessEnv} from './index.js';
3+
import {npmRunPath, npmRunPathEnv, type ProcessEnv} from './index.js';
44

55
const fileUrl = new URL('file:///foo');
66

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"types": "./index.d.ts",
1616
"sideEffects": false,
1717
"engines": {
18-
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
18+
"node": ">=18"
1919
},
2020
"scripts": {
2121
"test": "xo && ava && tsd"
@@ -42,8 +42,8 @@
4242
"path-key": "^4.0.0"
4343
},
4444
"devDependencies": {
45-
"ava": "^3.15.0",
46-
"tsd": "^0.17.0",
47-
"xo": "^0.45.0"
45+
"ava": "^6.1.2",
46+
"tsd": "^0.31.0",
47+
"xo": "^0.58.0"
4848
}
4949
}

test.js

+27-17
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ import {npmRunPath, npmRunPathEnv} from './index.js';
66

77
const __dirname = path.dirname(fileURLToPath(import.meta.url));
88

9-
const testLocalDir = (t, addExecPath, preferLocal, expectedResult) => {
9+
const testLocalDirectory = (t, addExecPath, preferLocal, expectedResult) => {
1010
t.is(
1111
npmRunPath({path: '', addExecPath, preferLocal}).split(path.delimiter)[0] === path.join(__dirname, 'node_modules/.bin'),
1212
expectedResult,
1313
);
1414
};
1515

16-
test('Adds node_modules/.bin - npmRunPath()', testLocalDir, undefined, undefined, true);
17-
test('"addExecPath: false" still adds node_modules/.bin - npmRunPath()', testLocalDir, false, undefined, true);
18-
test('"preferLocal: false" does not add node_modules/.bin - npmRunPath()', testLocalDir, undefined, false, false);
19-
test('"preferLocal: false", "addExecPath: false" does not add node_modules/.bin - npmRunPath()', testLocalDir, false, false, false);
16+
test('Adds node_modules/.bin - npmRunPath()', testLocalDirectory, undefined, undefined, true);
17+
test('"addExecPath: false" still adds node_modules/.bin - npmRunPath()', testLocalDirectory, false, undefined, true);
18+
test('"preferLocal: false" does not add node_modules/.bin - npmRunPath()', testLocalDirectory, undefined, false, false);
19+
test('"preferLocal: false", "addExecPath: false" does not add node_modules/.bin - npmRunPath()', testLocalDirectory, false, false, false);
2020

21-
const testLocalDirEnv = (t, addExecPath, preferLocal, expectedResult) => {
21+
const testLocalDirectoryEnv = (t, addExecPath, preferLocal, expectedResult) => {
2222
t.is(
2323
npmRunPathEnv({env: {PATH: 'foo'}, addExecPath, preferLocal}).PATH.split(path.delimiter)[0] === path.join(__dirname, 'node_modules/.bin'),
2424
expectedResult,
2525
);
2626
};
2727

28-
test('Adds node_modules/.bin - npmRunPathEnv()', testLocalDirEnv, undefined, undefined, true);
29-
test('"addExecPath: false" still adds node_modules/.bin - npmRunPathEnv()', testLocalDirEnv, false, undefined, true);
30-
test('"preferLocal: false" does not add node_modules/.bin - npmRunPathEnv()', testLocalDirEnv, undefined, false, false);
31-
test('"preferLocal: false", "addExecPath: false" does not add node_modules/.bin - npmRunPathEnv()', testLocalDirEnv, false, false, false);
28+
test('Adds node_modules/.bin - npmRunPathEnv()', testLocalDirectoryEnv, undefined, undefined, true);
29+
test('"addExecPath: false" still adds node_modules/.bin - npmRunPathEnv()', testLocalDirectoryEnv, false, undefined, true);
30+
test('"preferLocal: false" does not add node_modules/.bin - npmRunPathEnv()', testLocalDirectoryEnv, undefined, false, false);
31+
test('"preferLocal: false", "addExecPath: false" does not add node_modules/.bin - npmRunPathEnv()', testLocalDirectoryEnv, false, false, false);
3232

3333
test('the `cwd` option changes the current directory', t => {
3434
t.is(
@@ -46,12 +46,17 @@ test('the `cwd` option can be a file URL', t => {
4646

4747
test('push `execPath` later in the PATH', t => {
4848
const pathEnv = npmRunPath({path: ''}).split(path.delimiter);
49-
t.is(pathEnv[pathEnv.length - 2], path.dirname(process.execPath));
49+
t.is(pathEnv.at(-2), path.dirname(process.execPath));
5050
});
5151

5252
const testExecPath = (t, preferLocal, addExecPath, expectedResult) => {
53-
const pathEnv = npmRunPath({path: '', execPath: 'test/test', preferLocal, addExecPath}).split(path.delimiter);
54-
t.is(pathEnv[pathEnv.length - 2] === path.resolve('test'), expectedResult);
53+
const pathEnv = npmRunPath({
54+
path: '',
55+
execPath: 'test/test',
56+
preferLocal,
57+
addExecPath,
58+
}).split(path.delimiter);
59+
t.is(pathEnv.at(-2) === path.resolve('test'), expectedResult);
5560
};
5661

5762
test('can change `execPath` with the `execPath` option - npmRunPath()', testExecPath, undefined, undefined, true);
@@ -60,8 +65,13 @@ test('"addExecPath: false" does not add execPath - npmRunPath()', testExecPath,
6065
test('"addExecPath: false", "preferLocal: false" does not add execPath - npmRunPath()', testExecPath, false, false, false);
6166

6267
const testExecPathEnv = (t, preferLocal, addExecPath, expectedResult) => {
63-
const pathEnv = npmRunPathEnv({env: {PATH: 'foo'}, execPath: 'test/test', preferLocal, addExecPath}).PATH.split(path.delimiter);
64-
t.is(pathEnv[pathEnv.length - 2] === path.resolve('test'), expectedResult);
68+
const pathEnv = npmRunPathEnv({
69+
env: {PATH: 'foo'},
70+
execPath: 'test/test',
71+
preferLocal,
72+
addExecPath,
73+
}).PATH.split(path.delimiter);
74+
t.is(pathEnv.at(-2) === path.resolve('test'), expectedResult);
6575
};
6676

6777
test('can change `execPath` with the `execPath` option - npmRunPathEnv()', testExecPathEnv, undefined, undefined, true);
@@ -71,7 +81,7 @@ test('"addExecPath: false", "preferLocal: false" does not add execPath - npmRunP
7181

7282
test('the `execPath` option can be a file URL', t => {
7383
const pathEnv = npmRunPath({path: '', execPath: pathToFileURL('test/test')}).split(path.delimiter);
74-
t.is(pathEnv[pathEnv.length - 2], path.resolve('test'));
84+
t.is(pathEnv.at(-2), path.resolve('test'));
7585
});
7686

7787
test('the `execPath` option is relative to the `cwd` option', t => {
@@ -80,5 +90,5 @@ test('the `execPath` option is relative to the `cwd` option', t => {
8090
execPath: 'test/test',
8191
cwd: '/dir',
8292
}).split(path.delimiter);
83-
t.is(pathEnv[pathEnv.length - 2], path.normalize('/dir/test'));
93+
t.is(pathEnv.at(-2), path.normalize('/dir/test'));
8494
});

0 commit comments

Comments
 (0)