import { type FileSystemAdapter } from 'fast-glob'; export interface StatsOptions { /** * When true exceptions of stats are propagated to the caller; when false undefined is returned when stats throws an exception. */ throws?: boolean; } export interface WriteOptions { /** * Overwrite the file when it already exists. * If set to false, an exception is thrown when the file already exists. Otherwise the file is overwritten (default) * @default true */ overwrite?: boolean; /** * Append to the file instead of overwriting it when it already exists. */ append?: boolean; } export interface OutputOptions extends WriteOptions { /** * Encoding to use when writing strings to a file */ encoding?: BufferEncoding; } export interface FindOptions extends WriteOptions { /** * Single or multiple Working directories to use when searching. If not specified the current working directory is used. */ cwd?: string | string[]; /** * Glob patterns of natches to exclude from the search */ exclude?: GlobPatterns; /** * Maximum number of results to return after which the search is stopped. */ limit?: number; /** * Type of items to find, either files or directories or both. * By default only files are returned. */ findType?: FindType | 'directory' | 'file'; /** * Maximum depth to search in the directory structure. */ depth?: number; /** * When true the search is case insensitive, otherwise case sensitive. * Defaults to case insensitive matching. */ noCase?: boolean; } type GlobPatterns = string | string[]; export declare enum FindType { file = 1, directory = 2 } export interface FileInfo { /** * Returns `true` if the `fs.Dirent` object describes a regular file. */ isFile(): boolean; /** * Returns `true` if the `fs.Dirent` object describes a file system directory. */ isDirectory(): boolean; /** * The file name that this `DirectoryEntry` object refers to. */ readonly name: string; } export interface FileStat extends FileInfo { /** * The file name that this `DirectoryEntry` object refers to. */ readonly name: string; /** * The creation timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC. */ readonly ctime: number; /** * The modification timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC. * * *Note:* If the file changed, it is important to provide an updated `mtime` that advanced * from the previous value. Otherwise there may be optimizations in place that will not show * the updated file contents in an editor for example. */ readonly mtime: number; /** * The size in bytes. * * *Note:* If the file changed, it is important to provide an updated `size`. Otherwise there * may be optimizations in place that will not show the updated file contents in an editor for * example. */ readonly size: number; } /** * Basic representation of a read-only file system for reading files, checking file existence and reading directory contents. */ export declare abstract class FileSystem { /** * Returns true if the path exists and is a file, returns false when the path does not exists or is not a file. * @param path Path to check */ isFile(path: string): Promise; /** * Returns true if the path exists and is a folder, returns false when the path does not exists or is not a folder. * @param path Path to check */ isDirectory(path: string): Promise; /** * Checks if the specified path exists on the file system * @param path Path to check */ pathExists(path: string): Promise; /** * Read a file and returns the file body as String */ readFileAsString(path: string, encoding?: BufferEncoding): Promise; /** * Write a file to the file system, when the directory does not exists it will be created. * @param path path to the file to read * @param body body to write to the file * @param options write options */ outputFile(path: string, body?: Buffer | string, options?: OutputOptions): Promise; /** * Find files and or folders matching the specified glob pattern as an async iterable. If the result is not iterated completely, the search is stopped. * When you need the results as an array, use the `Iterable.spreadAsync` method to convert the async iterable into an array. * * By default the current working directory is used as the base directory for the search. * * You can specify multiple glob patterns to match by specifying an array of glob patterns. * * When a limit is specified, the search is stopped after the specified number of results is reached. * * When a depth is specified, the search does not go deeper than the specified depth. * * @param patterns Glob patterns to match * @param options find options * @returns Async iterable of matching files and or folders * @example * ```typescript * for await (const file of fs.find('*.ts')) { * console.log(file); * } * ``` */ find(patterns: GlobPatterns, options?: FindOptions): AsyncGenerator; private normalizePath; /** * Append data to an existing file to the file system, when the directory does not exists it will be created. * @param path path to the file to read * @param body body to write to the file * @param options write options */ appendFile(path: string, body: Buffer | string, options?: OutputOptions): Promise; /** * Write a file to the file system, when the directory does not exists it will be created. * @param path path to the file to read * @param data data to write to the file * @param options write options */ abstract writeFile(path: string, data: Buffer, options?: WriteOptions): Promise; /** * Create a new directory at the specified path. No error should be thrown when the directory already exists. * Operations should be idempotent and recursive, so when creating a directory /a/b/c and /a or /a/b do not exists, these should be created as well. * @param path path to the directory to create */ abstract createDirectory(path: string): Promise; /** * Get file statistics; returns undefined when the file does not exists * @param path Path to check */ abstract stat(path: string, options?: StatsOptions): Promise; /** * Reads the specified file path into a NodeJS Buffer object * @param path path to the file to read */ abstract readFile(path: string): Promise; /** * Read the contents of a directs; returns an array with the files and folders contained in the specified directory. * @param path Directory */ abstract readDirectory(path: string): Promise; /** * Find files matching the specified glob pattern(s) * @param globPatterns Glob patterns to match files with */ findFiles(globPatterns: string | string[]): Promise; protected globFs?(): Partial; } export {}; //# sourceMappingURL=fileSystem.d.ts.map