Skip to content

Commit 2d7d7cb

Browse files
committed
Require Node.js 18
Closes #11
1 parent 8085369 commit 2d7d7cb

File tree

7 files changed

+41
-39
lines changed

7 files changed

+41
-39
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13-
- 14
14-
- 12
13+
- 22
14+
- 20
15+
- 18
1516
os:
1617
- macos-latest
1718
- ubuntu-latest
1819
steps:
19-
- uses: actions/checkout@v2
20-
- uses: actions/setup-node@v1
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-node@v4
2122
with:
2223
node-version: ${{ matrix.node-version }}
2324
- run: npm install

index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import fs, {promises as fsPromises} from 'fs';
1+
import fs from 'node:fs';
2+
import fsPromises from 'node:fs/promises';
23

34
async function isType(fsStatType, statsMethodName, filePath) {
45
if (typeof filePath !== 'string') {
@@ -33,9 +34,9 @@ function isTypeSync(fsStatType, statsMethodName, filePath) {
3334
}
3435
}
3536

36-
export const isFile = isType.bind(null, 'stat', 'isFile');
37-
export const isDirectory = isType.bind(null, 'stat', 'isDirectory');
38-
export const isSymlink = isType.bind(null, 'lstat', 'isSymbolicLink');
39-
export const isFileSync = isTypeSync.bind(null, 'statSync', 'isFile');
40-
export const isDirectorySync = isTypeSync.bind(null, 'statSync', 'isDirectory');
41-
export const isSymlinkSync = isTypeSync.bind(null, 'lstatSync', 'isSymbolicLink');
37+
export const isFile = isType.bind(undefined, 'stat', 'isFile');
38+
export const isDirectory = isType.bind(undefined, 'stat', 'isDirectory');
39+
export const isSymlink = isType.bind(undefined, 'lstat', 'isSymbolicLink');
40+
export const isFileSync = isTypeSync.bind(undefined, 'statSync', 'isFile');
41+
export const isDirectorySync = isTypeSync.bind(undefined, 'statSync', 'isDirectory');
42+
export const isSymlinkSync = isTypeSync.bind(undefined, 'lstatSync', 'isSymbolicLink');

index.test-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
isSymlink,
66
isFileSync,
77
isDirectorySync,
8-
isSymlinkSync
8+
isSymlinkSync,
99
} from './index.js';
1010

1111
expectType<Promise<boolean>>(isFile('package.json'));

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
"url": "https://sindresorhus.com"
1212
},
1313
"type": "module",
14-
"exports": "./index.js",
14+
"exports": {
15+
"types": "./index.d.ts",
16+
"default": "./index.js"
17+
},
18+
"sideEffects": false,
1519
"engines": {
16-
"node": ">=12"
20+
"node": ">=18"
1721
},
1822
"scripts": {
1923
"test": "xo && nyc ava && tsd"
@@ -39,9 +43,9 @@
3943
"filesystem"
4044
],
4145
"devDependencies": {
42-
"ava": "^3.15.0",
43-
"nyc": "^15.1.0",
44-
"tsd": "^0.14.0",
45-
"xo": "^0.37.1"
46+
"ava": "^6.1.3",
47+
"nyc": "^17.0.0",
48+
"tsd": "^0.31.1",
49+
"xo": "^0.59.2"
4650
}
4751
}

readme.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
55
## Install
66

7-
```
8-
$ npm install path-type
7+
```sh
8+
npm install path-type
99
```
1010

1111
## Usage
@@ -60,15 +60,3 @@ Returns a `boolean`.
6060
Synchronously check whether the passed `path` is a symlink.
6161

6262
Returns a `boolean`.
63-
64-
---
65-
66-
<div align="center">
67-
<b>
68-
<a href="https://tidelift.com/subscription/pkg/npm-path-type?utm_source=npm-path-type&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
69-
</b>
70-
<br>
71-
<sub>
72-
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
73-
</sub>
74-
</div>

test/eacces.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs, {promises as fsPromises} from 'fs';
1+
import fs, {promises as fsPromises} from 'node:fs';
22
import test from 'ava';
33
import {isFile, isFileSync} from '../index.js';
44

@@ -12,21 +12,21 @@ Object.defineProperties(fsPromises, {
1212
stat: {
1313
value(filePath, callback) {
1414
callback(fakeError(filePath));
15-
}
16-
}
15+
},
16+
},
1717
});
1818

1919
Object.defineProperties(fs, {
2020
stat: {
2121
value(filePath, callback) {
2222
callback(fakeError(filePath));
23-
}
23+
},
2424
},
2525
statSync: {
2626
value(filePath) {
2727
throw fakeError(filePath);
28-
}
29-
}
28+
},
29+
},
3030
});
3131

3232
test('throws on EACCES error - async', async t => {

test/nominal.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
import process from 'node:process';
12
import test from 'ava';
2-
import {isDirectory, isDirectorySync, isFile, isFileSync, isSymlink, isSymlinkSync} from '../index.js';
3+
import {
4+
isDirectory,
5+
isDirectorySync,
6+
isFile,
7+
isFileSync,
8+
isSymlink,
9+
isSymlinkSync,
10+
} from '../index.js';
311

412
test('.file()', async t => {
513
t.true(await isFile('package.json'));

0 commit comments

Comments
 (0)