UNPKG

@rushstack/heft

Version:

Build all your JavaScript projects the same way: A way that works.

88 lines 3.29 kB
import type * as fs from 'fs'; import { type FileSystemAdapter } from 'fast-glob'; import type { IWatchFileSystemAdapter, IWatchedFileState } from '../utilities/WatchFileSystemAdapter'; /** * Used to specify a selection of one or more files. * * @public */ export interface IFileSelectionSpecifier { /** * Absolute path to the target. The provided sourcePath can be to a file or a folder. If * fileExtensions, excludeGlobs, or includeGlobs are specified, the sourcePath is assumed * to be a folder. If it is not a folder, an error will be thrown. */ sourcePath?: string; /** * File extensions that should be included from the source folder. Only supported when the sourcePath * is a folder. */ fileExtensions?: string[]; /** * Globs that should be explicitly excluded. This takes precedence over globs listed in "includeGlobs" and * files that match the file extensions provided in "fileExtensions". Only supported when the sourcePath * is a folder. */ excludeGlobs?: string[]; /** * Globs that should be explicitly included. Only supported when the sourcePath is a folder. */ includeGlobs?: string[]; } /** * A supported subset of options used when globbing files. * * @public */ export interface IGlobOptions { /** * Current working directory that the glob pattern will be applied to. */ cwd?: string; /** * Whether or not the returned file paths should be absolute. * * @defaultValue false */ absolute?: boolean; /** * Patterns to ignore when globbing. */ ignore?: string[]; /** * Whether or not to include dot files when globbing. * * @defaultValue false */ dot?: boolean; } export interface IGetFileSelectionSpecifierPathsOptions { fileGlobSpecifier: IFileSelectionSpecifier; includeFolders?: boolean; fileSystemAdapter?: FileSystemAdapter; } /** * Glob a set of files and return a list of paths that match the provided patterns. * * @param patterns - Glob patterns to match against. * @param options - Options that are used when globbing the set of files. * * @public */ export type GlobFn = (pattern: string | string[], options?: IGlobOptions | undefined) => Promise<string[]>; /** * Glob a set of files and return a map of paths that match the provided patterns to their current state in the watcher. * * @param patterns - Glob patterns to match against. * @param options - Options that are used when globbing the set of files. * * @public */ export type WatchGlobFn = (pattern: string | string[], options?: IGlobOptions | undefined) => Promise<Map<string, IWatchedFileState>>; export interface IWatchGlobOptions extends IGlobOptions { fs: IWatchFileSystemAdapter; } export declare function watchGlobAsync(pattern: string | string[], options: IWatchGlobOptions): Promise<Map<string, IWatchedFileState>>; export declare function getFileSelectionSpecifierPathsAsync(options: IGetFileSelectionSpecifierPathsOptions): Promise<Map<string, fs.Dirent>>; export declare function asAbsoluteFileSelectionSpecifier<TSpecifier extends IFileSelectionSpecifier>(rootPath: string, fileGlobSpecifier: TSpecifier): TSpecifier; //# sourceMappingURL=FileGlobSpecifier.d.ts.map