/// /// /// /// /// import { EventEmitter } from 'events'; import { Dirent as NodeDirent, ReadStream } from 'fs'; import { Stats as NodeStats, WriteStream } from 'fs'; import { NoParamCallback, BigIntStats as NodeBigIntStats } from 'fs'; import { LinkStrategy } from './algorithms/copyPromise'; import { FSPath, Path, PortablePath, PathUtils, Filename } from './path'; export type Stats = NodeStats & { crc?: number; }; export type BigIntStats = NodeBigIntStats & { crc?: number; }; export type Dirent = Exclude & { name: Filename; }; export type Dir

= { readonly path: P; [Symbol.asyncIterator](): AsyncIterableIterator; close(): Promise; close(cb: NoParamCallback): void; closeSync(): void; read(): Promise; read(cb: (err: NodeJS.ErrnoException | null, dirent: Dirent | null) => void): void; readSync(): Dirent | null; }; export type OpendirOptions = Partial<{ bufferSize: number; }>; export type CreateReadStreamOptions = Partial<{ encoding: string; fd: number; }>; export type CreateWriteStreamOptions = Partial<{ encoding: string; fd: number; flags: 'a'; }>; export type MkdirOptions = Partial<{ recursive: boolean; mode: number; }>; export type RmdirOptions = Partial<{ maxRetries: number; recursive: boolean; retryDelay: number; }>; export type WriteFileOptions = Partial<{ encoding: string; mode: number; flag: string; }> | string; export type WatchOptions = Partial<{ persistent: boolean; recursive: boolean; encoding: string; }> | string; export type WatchFileOptions = Partial<{ bigint: boolean; persistent: boolean; interval: number; }>; export type ChangeFileOptions = Partial<{ automaticNewlines: boolean; mode: number; }>; export type WatchCallback = (eventType: string, filename: string) => void; export type Watcher = { on: any; close: () => void; }; export type WatchFileCallback = (current: Stats, previous: Stats) => void; export type StatWatcher = EventEmitter & { ref?: () => StatWatcher; unref?: () => StatWatcher; }; export type ExtractHintOptions = { relevantExtensions: Set; }; export type SymlinkType = 'file' | 'dir' | 'junction'; export interface StatOptions { bigint?: boolean | undefined; } export interface StatSyncOptions extends StatOptions { throwIfNoEntry?: boolean | undefined; } export declare abstract class FakeFS

{ readonly pathUtils: PathUtils

; protected constructor(pathUtils: PathUtils

); /** * @deprecated: Moved to jsInstallUtils */ abstract getExtractHint(hints: ExtractHintOptions): boolean; abstract getRealPath(): P; abstract resolve(p: P): P; abstract opendirPromise(p: P, opts?: OpendirOptions): Promise>; abstract opendirSync(p: P, opts?: OpendirOptions): Dir

; abstract openPromise(p: P, flags: string, mode?: number): Promise; abstract openSync(p: P, flags: string, mode?: number): number; abstract readPromise(fd: number, buffer: Buffer, offset?: number, length?: number, position?: number | null): Promise; abstract readSync(fd: number, buffer: Buffer, offset?: number, length?: number, position?: number | null): number; abstract writePromise(fd: number, buffer: Buffer, offset?: number, length?: number, position?: number): Promise; abstract writePromise(fd: number, buffer: string, position?: number): Promise; abstract writeSync(fd: number, buffer: Buffer, offset?: number, length?: number, position?: number): number; abstract writeSync(fd: number, buffer: string, position?: number): number; abstract closePromise(fd: number): Promise; abstract closeSync(fd: number): void; abstract createWriteStream(p: P | null, opts?: CreateWriteStreamOptions): WriteStream; abstract createReadStream(p: P | null, opts?: CreateReadStreamOptions): ReadStream; abstract realpathPromise(p: P): Promise

; abstract realpathSync(p: P): P; abstract readdirPromise(p: P): Promise>; abstract readdirPromise(p: P, opts: { withFileTypes: false; } | null): Promise>; abstract readdirPromise(p: P, opts: { withFileTypes: true; }): Promise>; abstract readdirPromise(p: P, opts: { withFileTypes: boolean; }): Promise | Array>; abstract readdirSync(p: P): Array; abstract readdirSync(p: P, opts: { withFileTypes: false; } | null): Array; abstract readdirSync(p: P, opts: { withFileTypes: true; }): Array; abstract readdirSync(p: P, opts: { withFileTypes: boolean; }): Array | Array; abstract existsPromise(p: P): Promise; abstract existsSync(p: P): boolean; abstract accessPromise(p: P, mode?: number): Promise; abstract accessSync(p: P, mode?: number): void; abstract statPromise(p: P): Promise; abstract statPromise(p: P, opts: (StatOptions & { bigint?: false | undefined; }) | undefined): Promise; abstract statPromise(p: P, opts: StatOptions & { bigint: true; }): Promise; abstract statPromise(p: P, opts?: StatOptions): Promise; abstract statSync(p: P): Stats; abstract statSync(p: P, opts?: StatSyncOptions & { bigint?: false | undefined; throwIfNoEntry: false; }): Stats | undefined; abstract statSync(p: P, opts: StatSyncOptions & { bigint: true; throwIfNoEntry: false; }): BigIntStats | undefined; abstract statSync(p: P, opts?: StatSyncOptions & { bigint?: false | undefined; }): Stats; abstract statSync(p: P, opts: StatSyncOptions & { bigint: true; }): BigIntStats; abstract statSync(p: P, opts: StatSyncOptions & { bigint: boolean; throwIfNoEntry?: false | undefined; }): Stats | BigIntStats; abstract statSync(p: P, opts?: StatSyncOptions): Stats | BigIntStats | undefined; abstract fstatPromise(fd: number): Promise; abstract fstatPromise(fd: number, opts: { bigint: true; }): Promise; abstract fstatPromise(fd: number, opts?: { bigint: boolean; }): Promise; abstract fstatSync(fd: number): Stats; abstract fstatSync(fd: number, opts: { bigint: true; }): BigIntStats; abstract fstatSync(fd: number, opts?: { bigint: boolean; }): BigIntStats | Stats; abstract lstatPromise(p: P): Promise; abstract lstatPromise(p: P, opts: (StatOptions & { bigint?: false | undefined; }) | undefined): Promise; abstract lstatPromise(p: P, opts: StatOptions & { bigint: true; }): Promise; abstract lstatPromise(p: P, opts?: StatOptions): Promise; abstract lstatSync(p: P): Stats; abstract lstatSync(p: P, opts?: StatSyncOptions & { bigint?: false | undefined; throwIfNoEntry: false; }): Stats | undefined; abstract lstatSync(p: P, opts: StatSyncOptions & { bigint: true; throwIfNoEntry: false; }): BigIntStats | undefined; abstract lstatSync(p: P, opts?: StatSyncOptions & { bigint?: false | undefined; }): Stats; abstract lstatSync(p: P, opts: StatSyncOptions & { bigint: true; }): BigIntStats; abstract lstatSync(p: P, opts: StatSyncOptions & { bigint: boolean; throwIfNoEntry?: false | undefined; }): Stats | BigIntStats; abstract lstatSync(p: P, opts?: StatSyncOptions): Stats | BigIntStats | undefined; abstract chmodPromise(p: P, mask: number): Promise; abstract chmodSync(p: P, mask: number): void; abstract fchmodPromise(fd: number, mask: number): Promise; abstract fchmodSync(fd: number, mask: number): void; abstract fchownPromise(fd: number, uid: number, gid: number): Promise; abstract fchownSync(fd: number, uid: number, gid: number): void; abstract chownPromise(p: P, uid: number, gid: number): Promise; abstract chownSync(p: P, uid: number, gid: number): void; abstract mkdirPromise(p: P, opts?: MkdirOptions): Promise; abstract mkdirSync(p: P, opts?: MkdirOptions): string | undefined; abstract rmdirPromise(p: P, opts?: RmdirOptions): Promise; abstract rmdirSync(p: P, opts?: RmdirOptions): void; abstract linkPromise(existingP: P, newP: P): Promise; abstract linkSync(existingP: P, newP: P): void; abstract symlinkPromise(target: P, p: P, type?: SymlinkType): Promise; abstract symlinkSync(target: P, p: P, type?: SymlinkType): void; abstract renamePromise(oldP: P, newP: P): Promise; abstract renameSync(oldP: P, newP: P): void; abstract copyFilePromise(sourceP: P, destP: P, flags?: number): Promise; abstract copyFileSync(sourceP: P, destP: P, flags?: number): void; abstract appendFilePromise(p: FSPath

, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): Promise; abstract appendFileSync(p: FSPath

, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): void; abstract writeFilePromise(p: FSPath

, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): Promise; abstract writeFileSync(p: FSPath

, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): void; abstract unlinkPromise(p: P): Promise; abstract unlinkSync(p: P): void; abstract utimesPromise(p: P, atime: Date | string | number, mtime: Date | string | number): Promise; abstract utimesSync(p: P, atime: Date | string | number, mtime: Date | string | number): void; lutimesPromise?(p: P, atime: Date | string | number, mtime: Date | string | number): Promise; lutimesSync?(p: P, atime: Date | string | number, mtime: Date | string | number): void; abstract readFilePromise(p: FSPath

, encoding: 'utf8'): Promise; abstract readFilePromise(p: FSPath

, encoding?: string): Promise; abstract readFileSync(p: FSPath

, encoding: 'utf8'): string; abstract readFileSync(p: FSPath

, encoding?: string): Buffer; abstract readlinkPromise(p: P): Promise

; abstract readlinkSync(p: P): P; abstract ftruncatePromise(fd: number, len?: number): Promise; abstract ftruncateSync(fd: number, len?: number): void; abstract truncatePromise(p: P, len?: number): Promise; abstract truncateSync(p: P, len?: number): void; abstract watch(p: P, cb?: WatchCallback): Watcher; abstract watch(p: P, opts: WatchOptions, cb?: WatchCallback): Watcher; abstract watchFile(p: P, cb: WatchFileCallback): StatWatcher; abstract watchFile(p: P, opts: WatchFileOptions, cb: WatchFileCallback): StatWatcher; abstract unwatchFile(p: P, cb?: WatchFileCallback): void; genTraversePromise(init: P, { stableSort }?: { stableSort?: boolean; }): AsyncGenerator; removePromise(p: P, { recursive, maxRetries }?: { recursive?: boolean; maxRetries?: number; }): Promise; removeSync(p: P, { recursive }?: { recursive?: boolean; }): void; mkdirpPromise(p: P, { chmod, utimes }?: { chmod?: number; utimes?: [Date | string | number, Date | string | number]; }): Promise; mkdirpSync(p: P, { chmod, utimes }?: { chmod?: number; utimes?: [Date | string | number, Date | string | number]; }): string | undefined; copyPromise(destination: P, source: P, options?: { baseFs?: undefined; overwrite?: boolean; stableSort?: boolean; stableTime?: boolean; linkStrategy?: LinkStrategy; }): Promise; copyPromise(destination: P, source: P2, options: { baseFs: FakeFS; overwrite?: boolean; stableSort?: boolean; stableTime?: boolean; linkStrategy?: LinkStrategy; }): Promise; /** @deprecated Prefer using `copyPromise` instead */ copySync(destination: P, source: P, options?: { baseFs?: undefined; overwrite?: boolean; }): void; copySync(destination: P, source: P2, options: { baseFs: FakeFS; overwrite?: boolean; }): void; changeFilePromise(p: P, content: Buffer): Promise; changeFilePromise(p: P, content: string, opts?: ChangeFileOptions): Promise; private changeFileBufferPromise; private changeFileTextPromise; changeFileSync(p: P, content: Buffer): void; changeFileSync(p: P, content: string, opts?: ChangeFileOptions): void; private changeFileBufferSync; private changeFileTextSync; movePromise(fromP: P, toP: P): Promise; moveSync(fromP: P, toP: P): void; lockPromise(affectedPath: P, callback: () => Promise): Promise; readJsonPromise(p: P): Promise; readJsonSync(p: P): any; writeJsonPromise(p: P, data: any): Promise; writeJsonSync(p: P, data: any): void; preserveTimePromise(p: P, cb: () => Promise

): Promise; preserveTimeSync(p: P, cb: () => P | void): Promise; } export declare abstract class BasePortableFakeFS extends FakeFS { protected constructor(); } export declare function normalizeLineEndings(originalContent: string, newContent: string): string;