UNPKG

path-to-glob-pattern

Version:

Convert file/directory path to glob pattern.

23 lines 1.17 kB
export type PathToGlobPatternOptions = { extensions: string[]; cwd: string; }; /** * Checks if a provided path is a directory and returns a glob string matching * all files under that directory if so, the path itself otherwise. * * Reason for this is that `glob` needs `/**` to collect all the files under a * directory where as our previous implementation without `glob` simply walked * a directory that is passed. So this is to maintain backwards compatibility. * * Also makes sure all path separators are POSIX style for `glob` compatibility. * * @param {Object} [options] An options object * @param {string[]} [options.extensions=[]] An array of accepted extensions * @param {string} [options.cwd=process.cwd()] The cwd to use to resolve relative pathnames * @returns {Function} A function that takes a pathname and returns a glob that * matches all files with the provided extensions if * pathname is a directory. */ export declare function pathToGlobPattern(options: PathToGlobPatternOptions): (filePath: string) => string; //# sourceMappingURL=path-to-glob-pattern.d.ts.map