Skip to content

Commit 4d9318c

Browse files
authored
Merge pull request #77 from joliss/dep
Update dependencies, and require Node >= 20
2 parents 64f7f08 + 7a38716 commit 4d9318c

6 files changed

Lines changed: 1731 additions & 1677 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,8 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
node: ['10', '12', '14', '16', '18', '20', '22', '24']
20+
node: ['20', '22', '24']
2121
os: [ubuntu, macOS]
22-
exclude:
23-
- os: macOS
24-
node: '10'
25-
- os: macOS
26-
node: '12'
27-
- os: macOS
28-
node: '14'
2922

3023
steps:
3124
- uses: actions/checkout@v4

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# master
22

3+
* Upgrade dependencies, in particular minimatch 10
4+
* Require Node version 20 or newer
5+
36
# 3.0.0
47

58
* [BREAKING] drop node 8

index.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import fsNode = require('fs');
44
import * as MatcherCollection from 'matcher-collection';
5+
import { Minimatch, type MinimatchOptions } from 'minimatch';
56
import ensurePosix = require('ensure-posix-path');
67
import path = require('path');
7-
import { IMinimatch, IOptions as MinimatchOptions, Minimatch } from 'minimatch';
88

9-
function walkSync(baseDir: string, inputOptions?: walkSync.Options | (string|IMinimatch)[]) {
9+
function walkSync(baseDir: string, inputOptions?: walkSync.Options | (string|Minimatch)[]) {
1010
const options = handleOptions(inputOptions);
1111

1212
let mapFunct: (arg: walkSync.Entry) => string;
@@ -28,27 +28,27 @@ function getStat(path: string, fs: walkSync.Options['fs'] = fsNode) {
2828
try {
2929
return fs.statSync(path);
3030
} catch(error) {
31-
if (error !== null && typeof error === 'object' && (error.code === 'ENOENT' || error.code === 'ENOTDIR' || error.code === 'EPERM')) {
31+
if (error !== null && typeof error === 'object' && ['ENOENT', 'ENOTDIR', 'EPERM'].includes((error as any).code)) {
3232
return;
3333
}
3434
throw error;
3535
}
3636
}
3737

3838
namespace walkSync {
39-
export function entries(baseDir: string, inputOptions?: Options | (string|IMinimatch)[]) {
39+
export function entries(baseDir: string, inputOptions?: Options | (string|Minimatch)[]) {
4040
const options = handleOptions(inputOptions);
4141

4242
return _walkSync(ensurePosix(baseDir), options, null, []);
4343
};
4444

4545
export interface Options {
4646
includeBasePath?: boolean,
47-
globs?: (string|IMinimatch)[],
48-
ignore?: (string|IMinimatch)[],
49-
directories?: boolean,
50-
fs?: typeof fsNode,
51-
globOptions?: MinimatchOptions,
47+
globs?: (string|Minimatch)[],
48+
ignore?: (string|Minimatch)[],
49+
directories?: boolean,
50+
fs?: typeof fsNode,
51+
globOptions?: MinimatchOptions,
5252
}
5353

5454
export class Entry {
@@ -80,7 +80,7 @@ function isDefined<T>(val: T | undefined) : val is T {
8080
return typeof val !== 'undefined';
8181
}
8282

83-
function handleOptions(_options?: walkSync.Options | (string|IMinimatch)[]) : walkSync.Options {
83+
function handleOptions(_options?: walkSync.Options | (string|Minimatch)[]) : walkSync.Options {
8484
let options: walkSync.Options = {};
8585

8686
if (Array.isArray(_options)) {
@@ -92,7 +92,7 @@ function handleOptions(_options?: walkSync.Options | (string|IMinimatch)[]) : wa
9292
return options;
9393
}
9494

95-
function applyGlobOptions(globs: (string|IMinimatch)[] | undefined, options: MinimatchOptions) {
95+
function applyGlobOptions(globs: (string|Minimatch)[] | undefined, options: MinimatchOptions) {
9696
return globs?.map(glob => {
9797
if (typeof glob === 'string') {
9898
return new Minimatch(glob, options);
@@ -146,11 +146,13 @@ function _walkSync(baseDir: string, options: walkSync.Options, _relativePath: st
146146
let results: walkSync.Entry[] = [];
147147

148148
if (ignorePatterns) {
149-
ignoreMatcher = new MatcherCollection(ignorePatterns);
149+
// matcher-collection's published types expect the legacy IMinimatch from older minimatch
150+
// versions. Cast to any to bridge the mismatch with minimatch@10's types.
151+
ignoreMatcher = new MatcherCollection(ignorePatterns as any[]);
150152
}
151153

152154
if (globs) {
153-
globMatcher = new MatcherCollection(globs);
155+
globMatcher = new MatcherCollection(globs as any[]);
154156
}
155157

156158
if (globMatcher && !globMatcher.mayContain(relativePath)) {

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"types": "dist/index.d.ts",
88
"license": "MIT",
99
"engines": {
10-
"node": "10.* || >= 12.*"
10+
"node": ">= 20.*"
1111
},
1212
"repository": {
1313
"type": "git",
@@ -17,20 +17,20 @@
1717
"dist/"
1818
],
1919
"dependencies": {
20-
"@types/minimatch": "^3.0.4",
21-
"ensure-posix-path": "^1.1.0",
20+
"@types/minimatch": "^5.1.2",
21+
"ensure-posix-path": "^1.1.1",
2222
"matcher-collection": "^2.0.1",
23-
"minimatch": "^3.0.4"
23+
"minimatch": "^10.0.3"
2424
},
2525
"devDependencies": {
26-
"@types/jest": "^26.0.23",
27-
"@types/node": "^15.12.2",
28-
"glob": "^7.1.7",
29-
"jest": "^27.0.4",
30-
"memfs": "^3.2.2",
31-
"rimraf": "^3.0.2",
32-
"ts-jest": "^27.0.3",
33-
"typescript": "~4.3.2"
26+
"@types/jest": "^30.0.0",
27+
"@types/node": "^24.3.0",
28+
"glob": "^11.0.3",
29+
"jest": "^30.1.3",
30+
"memfs": "^4.38.2",
31+
"rimraf": "^6.0.1",
32+
"ts-jest": "^29.4.1",
33+
"typescript": "^5.9.2"
3434
},
3535
"scripts": {
3636
"prepare": "yarn run build",

test/test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function safeUnlink(path:string) {
2626
try {
2727
fs.unlinkSync(path);
2828
} catch (e) {
29-
if (typeof e === 'object' && e !== null && e.code === 'ENOENT') {
29+
if (typeof e === 'object' && e !== null && 'code' in e && (e as { code?: string }).code === 'ENOENT') {
3030
// handle
3131
} else {
3232
throw e;
@@ -38,7 +38,12 @@ function safeRmdir(path:string) {
3838
try {
3939
fs.rmdirSync(path);
4040
} catch (e) {
41-
if (typeof e === 'object' && e !== null && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) {
41+
if (
42+
typeof e === 'object' &&
43+
e !== null &&
44+
'code' in e &&
45+
(((e as { code?: string }).code === 'ENOENT') || ((e as { code?: string }).code === 'ENOTDIR'))
46+
) {
4247
// handle
4348
} else {
4449
throw e;

0 commit comments

Comments
 (0)