/** * The MIT License (MIT) * Copyright (c) 2014-present, Jon Schlinkert. */ import type { PicomatchOptions } from 'picomatch'; /** * 文件路径匹配器的配置选项 * * @example * // 基本用法 * const options: MatchOptions = { * failglob: true, * dot: true, * onResult: (state) => console.log('匹配结果:', state.output) * }; */ interface MatchOptions extends PicomatchOptions { /** * 如果没有找到任何匹配项,是否抛出错误 * * - `true`: 抛出 Error,消息为 "No matches found" * - `false` (默认): 返回空数组 * * 这个选项在 shell 脚本中很常见,用于确保模式至少匹配一个文件。 * * @default false * * @example * // 如果目录中没有 .js 文件,会抛出错误 * matchPath(files, ['*.js'], { failglob: true }); */ failglob?: boolean; /** * 如果没有匹配项时是否返回原始模式(不匹配的字面值) * * 当没有找到匹配项时,这个选项会让函数返回原始的模式字符串, * 而不是空数组。这在某些需要保持参数原样的场景中很有用。 * * @default false * * @example * // 如果没有匹配项,返回 ['*.pdf'] * const result = matchPath(files, ['*.pdf'], { nonull: true }); */ nonull?: boolean; /** * 类似于 nonull 但更符合 shell 的 nullglob 行为 * * 如果没有匹配项,返回空数组而不是原始模式。 * 当 nonull 和 nullglob 都设置时,nonull 优先。 * * @default false */ nullglob?: boolean; } declare function matchPath(list: string, patterns: string, options?: MatchOptions): string[]; declare function matchPath(list: string[], patterns: string, options?: MatchOptions): string[]; declare function matchPath(list: string, patterns: string[], options?: MatchOptions): string[]; declare function matchPath(list: string[], patterns: string[], options?: MatchOptions): string[]; export { matchPath }; export type { MatchOptions };