22
33import fsNode = require( 'fs' ) ;
44import * as MatcherCollection from 'matcher-collection' ;
5+ import { Minimatch , type MinimatchOptions } from 'minimatch' ;
56import ensurePosix = require( 'ensure-posix-path' ) ;
67import 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
3838namespace 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 ) ) {
0 commit comments