UNPKG

@yarnpkg/pnpify

Version:
230 lines (229 loc) 11.3 kB
import { BigIntStats, DirentNoPath, Stats } from '@yarnpkg/fslib'; import { Dirent, Filename, MkdirOptions, ExtractHintOptions, WatchFileCallback, WatchFileOptions, StatWatcher, OpendirOptions, Dir } from '@yarnpkg/fslib'; import { RmdirOptions, RmOptions } from '@yarnpkg/fslib'; import { FSPath, NativePath, PortablePath } from '@yarnpkg/fslib'; import { WatchOptions, WatchCallback, Watcher } from '@yarnpkg/fslib'; import { FakeFS, WriteFileOptions, ProxiedFS } from '@yarnpkg/fslib'; import { CreateReadStreamOptions, CreateWriteStreamOptions } from '@yarnpkg/fslib'; import { NodeModulesTreeOptions } from '@yarnpkg/nm'; import { PnpApi } from '@yarnpkg/pnp'; import fs from 'fs'; export type NodeModulesFSOptions = { realFs?: typeof fs; pnpifyFs?: boolean; }; export declare class NodeModulesFS extends ProxiedFS<NativePath, PortablePath> { protected readonly baseFs: FakeFS<PortablePath>; constructor(pnp: PnpApi, { realFs, pnpifyFs }?: NodeModulesFSOptions); protected mapFromBase(path: PortablePath): NativePath; protected mapToBase(path: NativePath): PortablePath; } export interface PortableNodeModulesFSOptions extends NodeModulesTreeOptions { baseFs?: FakeFS<PortablePath>; pnpifyFs?: boolean; } export declare class PortableNodeModulesFS extends FakeFS<PortablePath> { private readonly baseFs; private readonly options; private readonly watchManager; private readonly pnpFilePath; private nodeModulesTree; constructor(pnp: PnpApi, { baseFs, pnpifyFs }?: PortableNodeModulesFSOptions); private watchPnpFile; private persistPath; private persistVirtualParentFolder; getExtractHint(hints: ExtractHintOptions): boolean; resolve(path: PortablePath): PortablePath; getBaseFs(): FakeFS<PortablePath>; private resolvePath; private resolveFilePath; private resolveDirOrFilePath; private resolveLink; private static makeSymlinkStats; getRealPath(): PortablePath; openPromise(p: PortablePath, flags: string, mode?: number): Promise<number>; openSync(p: PortablePath, flags: string, mode?: number): number; opendirPromise(p: PortablePath, opts?: OpendirOptions): Promise<Dir<PortablePath>>; opendirSync(p: PortablePath, opts?: OpendirOptions): Dir<PortablePath>; readPromise(fd: number, buffer: Buffer, offset?: number, length?: number, position?: number): Promise<number>; readSync(fd: number, buffer: Buffer, offset?: number, length?: number, position?: number): number; writePromise(fd: number, buffer: Buffer, offset?: number, length?: number, position?: number): Promise<number>; writePromise(fd: number, buffer: string, position?: number): Promise<number>; writeSync(fd: number, buffer: Buffer, offset?: number, length?: number, position?: number): number; writeSync(fd: number, buffer: string, position?: number): number; closePromise(fd: number): Promise<void>; closeSync(fd: number): void; createReadStream(p: PortablePath | null, opts?: CreateReadStreamOptions): fs.ReadStream; createWriteStream(p: PortablePath | null, opts?: CreateWriteStreamOptions): fs.WriteStream; realpathPromise(p: PortablePath): Promise<PortablePath>; realpathSync(p: PortablePath): PortablePath; existsPromise(p: PortablePath): Promise<boolean>; existsSync(p: PortablePath): boolean; accessPromise(p: PortablePath, mode?: number): Promise<void>; accessSync(p: PortablePath, mode?: number): void; statPromise(p: PortablePath): Promise<Stats>; statPromise(p: PortablePath, opts: { bigint: true; }): Promise<BigIntStats>; statPromise(p: PortablePath, opts?: { bigint: boolean; }): Promise<BigIntStats | Stats>; statSync(p: PortablePath): Stats; statSync(p: PortablePath, opts: { bigint: true; }): BigIntStats; statSync(p: PortablePath, opts?: { bigint: boolean; }): BigIntStats | Stats; fstatPromise(fd: number): Promise<Stats>; fstatPromise(fd: number, opts: { bigint: true; }): Promise<BigIntStats>; fstatPromise(fd: number, opts?: { bigint: boolean; }): Promise<BigIntStats | Stats>; fstatSync(fd: number): Stats; fstatSync(fd: number, opts: { bigint: true; }): BigIntStats; fstatSync(fd: number, opts?: { bigint: boolean; }): BigIntStats | Stats; lstatPromise(p: PortablePath): Promise<Stats>; lstatPromise(p: PortablePath, opts: { bigint: true; }): Promise<BigIntStats>; lstatPromise(p: PortablePath, opts?: { bigint: boolean; }): Promise<BigIntStats | Stats>; lstatSync(p: PortablePath): Stats; lstatSync(p: PortablePath, opts: { bigint: true; }): BigIntStats; lstatSync(p: PortablePath, opts?: { bigint: boolean; }): BigIntStats | Stats; fchmodPromise(fd: number, mask: number): Promise<void>; fchmodSync(fd: number, mask: number): void; chmodPromise(p: PortablePath, mask: number): Promise<void>; chmodSync(p: PortablePath, mask: number): void; fchownPromise(fd: number, uid: number, gid: number): Promise<void>; fchownSync(fd: number, uid: number, gid: number): void; chownPromise(p: PortablePath, uid: number, gid: number): Promise<void>; chownSync(p: PortablePath, uid: number, gid: number): void; renamePromise(oldP: PortablePath, newP: PortablePath): Promise<void>; renameSync(oldP: PortablePath, newP: PortablePath): void; copyFilePromise(sourceP: PortablePath, destP: PortablePath, flags?: number): Promise<void>; copyFileSync(sourceP: PortablePath, destP: PortablePath, flags?: number): void; appendFilePromise(p: FSPath<PortablePath>, content: string | Uint8Array, opts?: WriteFileOptions): Promise<void>; appendFileSync(p: FSPath<PortablePath>, content: string | Uint8Array, opts?: WriteFileOptions): void; writeFilePromise(p: FSPath<PortablePath>, content: string | NodeJS.ArrayBufferView, opts?: WriteFileOptions): Promise<void>; writeFileSync(p: FSPath<PortablePath>, content: string | NodeJS.ArrayBufferView, opts?: WriteFileOptions): void; unlinkPromise(p: PortablePath): Promise<void>; unlinkSync(p: PortablePath): void; utimesPromise(p: PortablePath, atime: Date | string | number, mtime: Date | string | number): Promise<void>; utimesSync(p: PortablePath, atime: Date | string | number, mtime: Date | string | number): void; lutimesPromise(p: PortablePath, atime: Date | string | number, mtime: Date | string | number): Promise<void>; lutimesSync(p: PortablePath, atime: Date | string | number, mtime: Date | string | number): void; mkdirPromise(p: PortablePath, opts: MkdirOptions): Promise<string | undefined>; mkdirSync(p: PortablePath, opts: MkdirOptions): string | undefined; rmdirPromise(p: PortablePath, opts?: RmdirOptions): Promise<void>; rmdirSync(p: PortablePath, opts?: RmdirOptions): void; rmPromise(p: PortablePath, opts?: RmOptions): Promise<void>; rmSync(p: PortablePath, opts?: RmOptions): void; linkPromise(existingP: PortablePath, newP: PortablePath): Promise<void>; linkSync(existingP: PortablePath, newP: PortablePath): void; symlinkPromise(target: PortablePath, p: PortablePath): Promise<void>; symlinkSync(target: PortablePath, p: PortablePath): void; readFilePromise(p: FSPath<PortablePath>, encoding?: null): Promise<Buffer>; readFilePromise(p: FSPath<PortablePath>, encoding: BufferEncoding): Promise<string>; readFilePromise(p: FSPath<PortablePath>, encoding?: BufferEncoding | null): Promise<Buffer | string>; readFileSync(p: FSPath<PortablePath>, encoding?: null): Buffer; readFileSync(p: FSPath<PortablePath>, encoding: BufferEncoding): string; readFileSync(p: FSPath<PortablePath>, encoding?: BufferEncoding | null): Buffer | string; readdirPromise(p: PortablePath, opts?: null): Promise<Array<Filename>>; readdirPromise(p: PortablePath, opts: { recursive?: false; withFileTypes: true; }): Promise<Array<DirentNoPath>>; readdirPromise(p: PortablePath, opts: { recursive?: false; withFileTypes?: false; }): Promise<Array<Filename>>; readdirPromise(p: PortablePath, opts: { recursive?: false; withFileTypes: boolean; }): Promise<Array<DirentNoPath | Filename>>; readdirPromise(p: PortablePath, opts: { recursive: true; withFileTypes: true; }): Promise<Array<Dirent<PortablePath>>>; readdirPromise(p: PortablePath, opts: { recursive: true; withFileTypes?: false; }): Promise<Array<PortablePath>>; readdirPromise(p: PortablePath, opts: { recursive: true; withFileTypes: boolean; }): Promise<Array<Dirent<PortablePath> | PortablePath>>; readdirPromise(p: PortablePath, opts: { recursive: boolean; withFileTypes: true; }): Promise<Array<Dirent<PortablePath> | DirentNoPath>>; readdirPromise(p: PortablePath, opts: { recursive: boolean; withFileTypes?: false; }): Promise<Array<PortablePath>>; readdirPromise(p: PortablePath, opts: { recursive: boolean; withFileTypes: boolean; }): Promise<Array<Dirent<PortablePath> | DirentNoPath | PortablePath>>; readdirSync(p: PortablePath, opts?: null): Array<Filename>; readdirSync(p: PortablePath, opts: { recursive?: false; withFileTypes: true; }): Array<DirentNoPath>; readdirSync(p: PortablePath, opts: { recursive?: false; withFileTypes?: false; }): Array<Filename>; readdirSync(p: PortablePath, opts: { recursive?: false; withFileTypes: boolean; }): Array<DirentNoPath | Filename>; readdirSync(p: PortablePath, opts: { recursive: true; withFileTypes: true; }): Array<Dirent<PortablePath>>; readdirSync(p: PortablePath, opts: { recursive: true; withFileTypes?: false; }): Array<PortablePath>; readdirSync(p: PortablePath, opts: { recursive: true; withFileTypes: boolean; }): Array<Dirent<PortablePath> | PortablePath>; readdirSync(p: PortablePath, opts: { recursive: boolean; withFileTypes: true; }): Array<Dirent<PortablePath> | DirentNoPath>; readdirSync(p: PortablePath, opts: { recursive: boolean; withFileTypes?: false; }): Array<PortablePath>; readdirSync(p: PortablePath, opts: { recursive: boolean; withFileTypes: boolean; }): Array<Dirent<PortablePath> | DirentNoPath | PortablePath>; readlinkPromise(p: PortablePath): Promise<any>; readlinkSync(p: PortablePath): any; truncatePromise(p: PortablePath, len?: number): Promise<void>; truncateSync(p: PortablePath, len?: number): void; ftruncatePromise(fd: number, len?: number): Promise<void>; ftruncateSync(fd: number, len?: number): void; watch(p: PortablePath, cb?: WatchCallback): Watcher; watch(p: PortablePath, opts: WatchOptions, cb?: WatchCallback): Watcher; watchFile(p: PortablePath, cb: WatchFileCallback): StatWatcher; watchFile(p: PortablePath, opts: WatchFileOptions, cb: WatchFileCallback): StatWatcher; unwatchFile(p: PortablePath, cb?: WatchFileCallback): void; }