22import fs from 'node:fs'
33import path from 'node:path'
44import * as url from 'node:url'
5- import { globby , Options as GlobbyOptions } from 'globby '
5+ import { glob , GlobOptions } from 'tinyglobby '
66import { debug } from './utils/debug'
77import { getStdin } from './utils/stdin'
88import { generateTmpName } from './utils/tmp'
@@ -51,6 +51,11 @@ export enum FileType {
5151 Null ,
5252}
5353
54+ export interface FindPathOptions {
55+ ignore ?: GlobOptions [ 'ignore' ]
56+ files : string [ ]
57+ }
58+
5459export class File {
5560 buffer ?: Buffer
5661 inputDir ?: string
@@ -176,7 +181,7 @@ export class File {
176181 private static stdinBuffer ?: Buffer
177182
178183 static async findPath (
179- opts : GlobbyOptions ,
184+ opts : FindPathOptions ,
180185 ...paths : string [ ]
181186 ) : Promise < string [ ] > {
182187 const filepaths = new Set < string > ( )
@@ -203,12 +208,22 @@ export class File {
203208 globs . push ( p . split ( path . sep ) . join ( '/' ) )
204209 }
205210
206- // Find remaining path through globby
207- const gOpts = { absolute : true , ignore : [ '**/node_modules' ] , ...opts }
208- ; ( await globby ( globs , gOpts ) ) . forEach ( ( p ) => filepaths . add ( p ) )
211+ const { files, ignore } = opts
212+ const gOpts = {
213+ absolute : true ,
214+ ignore : [ '**/node_modules' , ...( ignore ?? [ ] ) ] ,
215+ } satisfies GlobOptions
216+
217+ // Find remaining path through glob patterns
218+ ; ( await glob ( globs , gOpts ) ) . forEach ( ( p ) => filepaths . add ( p ) )
209219
210220 for ( const cwd of dirs ) {
211- ; ( await globby ( '.' , { cwd, ...gOpts } ) ) . forEach ( ( p ) => filepaths . add ( p ) )
221+ ; (
222+ await glob (
223+ files . map ( ( pattern ) => `**/${ pattern } ` ) ,
224+ { ...gOpts , cwd }
225+ )
226+ ) . forEach ( ( p ) => filepaths . add ( p ) )
212227 }
213228
214229 return [ ...filepaths . values ( ) ] . map ( ( p ) => path . normalize ( p ) )
@@ -217,12 +232,7 @@ export class File {
217232 static async find ( ...paths : string [ ] ) : Promise < File [ ] > {
218233 return (
219234 await this . findPath (
220- {
221- expandDirectories : {
222- extensions : [ ] ,
223- files : markdownExtensions . map ( ( ext ) => `*.${ ext } ` ) ,
224- } ,
225- } ,
235+ { files : markdownExtensions . map ( ( ext ) => `*.${ ext } ` ) } ,
226236 ...paths
227237 )
228238 ) . map ( ( p ) => new File ( p ) )
0 commit comments