123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107 |
- import { LRUCache } from 'lru-cache';
- import { posix, win32 } from 'path';
- import type { Dirent, Stats } from 'fs';
- import { Minipass } from 'minipass';
- export interface FSOption {
- lstatSync?: (path: string) => Stats;
- readdir?: (path: string, options: {
- withFileTypes: true;
- }, cb: (er: NodeJS.ErrnoException | null, entries?: Dirent[]) => any) => void;
- readdirSync?: (path: string, options: {
- withFileTypes: true;
- }) => Dirent[];
- readlinkSync?: (path: string) => string;
- realpathSync?: (path: string) => string;
- promises?: {
- lstat?: (path: string) => Promise<Stats>;
- readdir?: (path: string, options: {
- withFileTypes: true;
- }) => Promise<Dirent[]>;
- readlink?: (path: string) => Promise<string>;
- realpath?: (path: string) => Promise<string>;
- [k: string]: any;
- };
- [k: string]: any;
- }
- interface FSValue {
- lstatSync: (path: string) => Stats;
- readdir: (path: string, options: {
- withFileTypes: true;
- }, cb: (er: NodeJS.ErrnoException | null, entries?: Dirent[]) => any) => void;
- readdirSync: (path: string, options: {
- withFileTypes: true;
- }) => Dirent[];
- readlinkSync: (path: string) => string;
- realpathSync: (path: string) => string;
- promises: {
- lstat: (path: string) => Promise<Stats>;
- readdir: (path: string, options: {
- withFileTypes: true;
- }) => Promise<Dirent[]>;
- readlink: (path: string) => Promise<string>;
- realpath: (path: string) => Promise<string>;
- [k: string]: any;
- };
- [k: string]: any;
- }
- export type Type = 'Unknown' | 'FIFO' | 'CharacterDevice' | 'Directory' | 'BlockDevice' | 'File' | 'SymbolicLink' | 'Socket';
- export interface PathOpts {
- fullpath?: string;
- relative?: string;
- relativePosix?: string;
- parent?: PathBase;
-
- fs?: FSOption;
- }
- export declare class ResolveCache extends LRUCache<string, string> {
- constructor();
- }
- /**
- * an LRUCache for storing child entries.
- * @internal
- */
- export declare class ChildrenCache extends LRUCache<PathBase, Children> {
- constructor(maxSize?: number);
- }
- /**
- * Array of Path objects, plus a marker indicating the first provisional entry
- *
- * @internal
- */
- export type Children = PathBase[] & {
- provisional: number;
- };
- declare const setAsCwd: unique symbol;
- export declare abstract class PathBase implements Dirent {
- #private;
-
- name: string;
-
- root: PathBase;
-
- roots: {
- [k: string]: PathBase;
- };
-
- parent?: PathBase;
-
- nocase: boolean;
-
- abstract splitSep: string | RegExp;
-
- abstract sep: string;
- get dev(): number | undefined;
- get mode(): number | undefined;
- get nlink(): number | undefined;
- get uid(): number | undefined;
- get gid(): number | undefined;
- get rdev(): number | undefined;
- get blksize(): number | undefined;
- get ino(): number | undefined;
- get size(): number | undefined;
- get blocks(): number | undefined;
- get atimeMs(): number | undefined;
- get mtimeMs(): number | undefined;
- get ctimeMs(): number | undefined;
- get birthtimeMs(): number | undefined;
- get atime(): Date | undefined;
- get mtime(): Date | undefined;
- get ctime(): Date | undefined;
- get birthtime(): Date | undefined;
-
- get path(): string;
-
- constructor(name: string, type: number | undefined, root: PathBase | undefined, roots: {
- [k: string]: PathBase;
- }, nocase: boolean, children: ChildrenCache, opts: PathOpts);
-
- depth(): number;
-
- abstract getRootString(path: string): string;
-
- abstract getRoot(rootPath: string): PathBase;
-
- abstract newChild(name: string, type?: number, opts?: PathOpts): PathBase;
-
- childrenCache(): ChildrenCache;
-
- resolve(path?: string): PathBase;
-
- children(): Children;
-
- child(pathPart: string, opts?: PathOpts): PathBase;
-
- relative(): string;
-
- relativePosix(): string;
-
- fullpath(): string;
-
- fullpathPosix(): string;
-
- isUnknown(): boolean;
- isType(type: Type): boolean;
- getType(): Type;
-
- isFile(): boolean;
-
- isDirectory(): boolean;
-
- isCharacterDevice(): boolean;
-
- isBlockDevice(): boolean;
-
- isFIFO(): boolean;
-
- isSocket(): boolean;
-
- isSymbolicLink(): boolean;
-
- lstatCached(): PathBase | undefined;
-
- readlinkCached(): PathBase | undefined;
-
- realpathCached(): PathBase | undefined;
-
- readdirCached(): PathBase[];
-
- canReadlink(): boolean;
-
- calledReaddir(): boolean;
-
- isENOENT(): boolean;
-
- isNamed(n: string): boolean;
-
- readlink(): Promise<PathBase | undefined>;
-
- readlinkSync(): PathBase | undefined;
-
- lstat(): Promise<PathBase | undefined>;
-
- lstatSync(): PathBase | undefined;
-
- readdirCB(cb: (er: NodeJS.ErrnoException | null, entries: PathBase[]) => any, allowZalgo?: boolean): void;
-
- readdir(): Promise<PathBase[]>;
-
- readdirSync(): PathBase[];
- canReaddir(): boolean;
- shouldWalk(dirs: Set<PathBase | undefined>, walkFilter?: (e: PathBase) => boolean): boolean;
-
- realpath(): Promise<PathBase | undefined>;
-
- realpathSync(): PathBase | undefined;
-
- [setAsCwd](oldCwd: PathBase): void;
- }
- export declare class PathWin32 extends PathBase {
-
- sep: '\\';
-
- splitSep: RegExp;
-
- constructor(name: string, type: number | undefined, root: PathBase | undefined, roots: {
- [k: string]: PathBase;
- }, nocase: boolean, children: ChildrenCache, opts: PathOpts);
-
- newChild(name: string, type?: number, opts?: PathOpts): PathWin32;
-
- getRootString(path: string): string;
-
- getRoot(rootPath: string): PathBase;
-
- sameRoot(rootPath: string, compare?: string): boolean;
- }
- export declare class PathPosix extends PathBase {
-
- splitSep: '/';
-
- sep: '/';
-
- constructor(name: string, type: number | undefined, root: PathBase | undefined, roots: {
- [k: string]: PathBase;
- }, nocase: boolean, children: ChildrenCache, opts: PathOpts);
-
- getRootString(path: string): string;
-
- getRoot(_rootPath: string): PathBase;
-
- newChild(name: string, type?: number, opts?: PathOpts): PathPosix;
- }
- export interface PathScurryOpts {
-
- nocase?: boolean;
-
- childrenCacheSize?: number;
-
- fs?: FSOption;
- }
- export declare abstract class PathScurryBase {
- #private;
-
- root: PathBase;
-
- rootPath: string;
-
- roots: {
- [k: string]: PathBase;
- };
-
- cwd: PathBase;
-
- nocase: boolean;
-
- abstract sep: string | RegExp;
-
- constructor(cwd: string | URL | undefined, pathImpl: typeof win32 | typeof posix, sep: string | RegExp, { nocase, childrenCacheSize, fs, }?: PathScurryOpts);
-
- depth(path?: Path | string): number;
-
- abstract parseRootPath(dir: string): string;
-
- abstract newRoot(fs: FSValue): PathBase;
-
- abstract isAbsolute(p: string): boolean;
-
- childrenCache(): ChildrenCache;
-
- resolve(...paths: string[]): string;
-
- resolvePosix(...paths: string[]): string;
-
- relative(entry?: PathBase | string): string;
-
- relativePosix(entry?: PathBase | string): string;
-
- basename(entry?: PathBase | string): string;
-
- dirname(entry?: PathBase | string): string;
-
- readdir(): Promise<PathBase[]>;
- readdir(opts: {
- withFileTypes: true;
- }): Promise<PathBase[]>;
- readdir(opts: {
- withFileTypes: false;
- }): Promise<string[]>;
- readdir(opts: {
- withFileTypes: boolean;
- }): Promise<PathBase[] | string[]>;
- readdir(entry: PathBase | string): Promise<PathBase[]>;
- readdir(entry: PathBase | string, opts: {
- withFileTypes: true;
- }): Promise<PathBase[]>;
- readdir(entry: PathBase | string, opts: {
- withFileTypes: false;
- }): Promise<string[]>;
- readdir(entry: PathBase | string, opts: {
- withFileTypes: boolean;
- }): Promise<PathBase[] | string[]>;
-
- readdirSync(): PathBase[];
- readdirSync(opts: {
- withFileTypes: true;
- }): PathBase[];
- readdirSync(opts: {
- withFileTypes: false;
- }): string[];
- readdirSync(opts: {
- withFileTypes: boolean;
- }): PathBase[] | string[];
- readdirSync(entry: PathBase | string): PathBase[];
- readdirSync(entry: PathBase | string, opts: {
- withFileTypes: true;
- }): PathBase[];
- readdirSync(entry: PathBase | string, opts: {
- withFileTypes: false;
- }): string[];
- readdirSync(entry: PathBase | string, opts: {
- withFileTypes: boolean;
- }): PathBase[] | string[];
-
- lstat(entry?: string | PathBase): Promise<PathBase | undefined>;
-
- lstatSync(entry?: string | PathBase): PathBase | undefined;
-
- readlink(): Promise<string | undefined>;
- readlink(opt: {
- withFileTypes: false;
- }): Promise<string | undefined>;
- readlink(opt: {
- withFileTypes: true;
- }): Promise<PathBase | undefined>;
- readlink(opt: {
- withFileTypes: boolean;
- }): Promise<PathBase | string | undefined>;
- readlink(entry: string | PathBase, opt?: {
- withFileTypes: false;
- }): Promise<string | undefined>;
- readlink(entry: string | PathBase, opt: {
- withFileTypes: true;
- }): Promise<PathBase | undefined>;
- readlink(entry: string | PathBase, opt: {
- withFileTypes: boolean;
- }): Promise<string | PathBase | undefined>;
-
- readlinkSync(): string | undefined;
- readlinkSync(opt: {
- withFileTypes: false;
- }): string | undefined;
- readlinkSync(opt: {
- withFileTypes: true;
- }): PathBase | undefined;
- readlinkSync(opt: {
- withFileTypes: boolean;
- }): PathBase | string | undefined;
- readlinkSync(entry: string | PathBase, opt?: {
- withFileTypes: false;
- }): string | undefined;
- readlinkSync(entry: string | PathBase, opt: {
- withFileTypes: true;
- }): PathBase | undefined;
- readlinkSync(entry: string | PathBase, opt: {
- withFileTypes: boolean;
- }): string | PathBase | undefined;
-
- realpath(): Promise<string | undefined>;
- realpath(opt: {
- withFileTypes: false;
- }): Promise<string | undefined>;
- realpath(opt: {
- withFileTypes: true;
- }): Promise<PathBase | undefined>;
- realpath(opt: {
- withFileTypes: boolean;
- }): Promise<PathBase | string | undefined>;
- realpath(entry: string | PathBase, opt?: {
- withFileTypes: false;
- }): Promise<string | undefined>;
- realpath(entry: string | PathBase, opt: {
- withFileTypes: true;
- }): Promise<PathBase | undefined>;
- realpath(entry: string | PathBase, opt: {
- withFileTypes: boolean;
- }): Promise<string | PathBase | undefined>;
- realpathSync(): string | undefined;
- realpathSync(opt: {
- withFileTypes: false;
- }): string | undefined;
- realpathSync(opt: {
- withFileTypes: true;
- }): PathBase | undefined;
- realpathSync(opt: {
- withFileTypes: boolean;
- }): PathBase | string | undefined;
- realpathSync(entry: string | PathBase, opt?: {
- withFileTypes: false;
- }): string | undefined;
- realpathSync(entry: string | PathBase, opt: {
- withFileTypes: true;
- }): PathBase | undefined;
- realpathSync(entry: string | PathBase, opt: {
- withFileTypes: boolean;
- }): string | PathBase | undefined;
-
- walk(): Promise<PathBase[]>;
- walk(opts: WalkOptionsWithFileTypesTrue | WalkOptionsWithFileTypesUnset): Promise<PathBase[]>;
- walk(opts: WalkOptionsWithFileTypesFalse): Promise<string[]>;
- walk(opts: WalkOptions): Promise<string[] | PathBase[]>;
- walk(entry: string | PathBase): Promise<PathBase[]>;
- walk(entry: string | PathBase, opts: WalkOptionsWithFileTypesTrue | WalkOptionsWithFileTypesUnset): Promise<PathBase[]>;
- walk(entry: string | PathBase, opts: WalkOptionsWithFileTypesFalse): Promise<string[]>;
- walk(entry: string | PathBase, opts: WalkOptions): Promise<PathBase[] | string[]>;
-
- walkSync(): PathBase[];
- walkSync(opts: WalkOptionsWithFileTypesTrue | WalkOptionsWithFileTypesUnset): PathBase[];
- walkSync(opts: WalkOptionsWithFileTypesFalse): string[];
- walkSync(opts: WalkOptions): string[] | PathBase[];
- walkSync(entry: string | PathBase): PathBase[];
- walkSync(entry: string | PathBase, opts: WalkOptionsWithFileTypesUnset | WalkOptionsWithFileTypesTrue): PathBase[];
- walkSync(entry: string | PathBase, opts: WalkOptionsWithFileTypesFalse): string[];
- walkSync(entry: string | PathBase, opts: WalkOptions): PathBase[] | string[];
-
- [Symbol.asyncIterator](): AsyncGenerator<PathBase, void, void>;
-
- iterate(): AsyncGenerator<PathBase, void, void>;
- iterate(opts: WalkOptionsWithFileTypesTrue | WalkOptionsWithFileTypesUnset): AsyncGenerator<PathBase, void, void>;
- iterate(opts: WalkOptionsWithFileTypesFalse): AsyncGenerator<string, void, void>;
- iterate(opts: WalkOptions): AsyncGenerator<string | PathBase, void, void>;
- iterate(entry: string | PathBase): AsyncGenerator<PathBase, void, void>;
- iterate(entry: string | PathBase, opts: WalkOptionsWithFileTypesTrue | WalkOptionsWithFileTypesUnset): AsyncGenerator<PathBase, void, void>;
- iterate(entry: string | PathBase, opts: WalkOptionsWithFileTypesFalse): AsyncGenerator<string, void, void>;
- iterate(entry: string | PathBase, opts: WalkOptions): AsyncGenerator<PathBase | string, void, void>;
-
- [Symbol.iterator](): Generator<PathBase, void, void>;
- iterateSync(): Generator<PathBase, void, void>;
- iterateSync(opts: WalkOptionsWithFileTypesTrue | WalkOptionsWithFileTypesUnset): Generator<PathBase, void, void>;
- iterateSync(opts: WalkOptionsWithFileTypesFalse): Generator<string, void, void>;
- iterateSync(opts: WalkOptions): Generator<string | PathBase, void, void>;
- iterateSync(entry: string | PathBase): Generator<PathBase, void, void>;
- iterateSync(entry: string | PathBase, opts: WalkOptionsWithFileTypesTrue | WalkOptionsWithFileTypesUnset): Generator<PathBase, void, void>;
- iterateSync(entry: string | PathBase, opts: WalkOptionsWithFileTypesFalse): Generator<string, void, void>;
- iterateSync(entry: string | PathBase, opts: WalkOptions): Generator<PathBase | string, void, void>;
-
- stream(): Minipass<PathBase>;
- stream(opts: WalkOptionsWithFileTypesTrue | WalkOptionsWithFileTypesUnset): Minipass<PathBase>;
- stream(opts: WalkOptionsWithFileTypesFalse): Minipass<string>;
- stream(opts: WalkOptions): Minipass<string | PathBase>;
- stream(entry: string | PathBase): Minipass<PathBase>;
- stream(entry: string | PathBase, opts: WalkOptionsWithFileTypesUnset | WalkOptionsWithFileTypesTrue): Minipass<PathBase>;
- stream(entry: string | PathBase, opts: WalkOptionsWithFileTypesFalse): Minipass<string>;
- stream(entry: string | PathBase, opts: WalkOptions): Minipass<string> | Minipass<PathBase>;
-
- streamSync(): Minipass<PathBase>;
- streamSync(opts: WalkOptionsWithFileTypesTrue | WalkOptionsWithFileTypesUnset): Minipass<PathBase>;
- streamSync(opts: WalkOptionsWithFileTypesFalse): Minipass<string>;
- streamSync(opts: WalkOptions): Minipass<string | PathBase>;
- streamSync(entry: string | PathBase): Minipass<PathBase>;
- streamSync(entry: string | PathBase, opts: WalkOptionsWithFileTypesUnset | WalkOptionsWithFileTypesTrue): Minipass<PathBase>;
- streamSync(entry: string | PathBase, opts: WalkOptionsWithFileTypesFalse): Minipass<string>;
- streamSync(entry: string | PathBase, opts: WalkOptions): Minipass<string> | Minipass<PathBase>;
- chdir(path?: string | Path): void;
- }
- export interface WalkOptions {
-
- withFileTypes?: boolean;
-
- follow?: boolean;
-
- filter?: (entry: PathBase) => boolean;
-
- walkFilter?: (entry: PathBase) => boolean;
- }
- export type WalkOptionsWithFileTypesUnset = WalkOptions & {
- withFileTypes?: undefined;
- };
- export type WalkOptionsWithFileTypesTrue = WalkOptions & {
- withFileTypes: true;
- };
- export type WalkOptionsWithFileTypesFalse = WalkOptions & {
- withFileTypes: false;
- };
- export declare class PathScurryWin32 extends PathScurryBase {
-
- sep: '\\';
- constructor(cwd?: URL | string, opts?: PathScurryOpts);
- /**
- * @internal
- */
- parseRootPath(dir: string): string;
- /**
- * @internal
- */
- newRoot(fs: FSValue): PathWin32;
- /**
- * Return true if the provided path string is an absolute path
- */
- isAbsolute(p: string): boolean;
- }
- /**
- * {@link PathScurryBase} implementation for all posix systems other than Darwin.
- *
- * Defaults to case-sensitive matching, uses `'/'` to generate path strings.
- *
- * Uses {@link PathPosix} for Path objects.
- */
- export declare class PathScurryPosix extends PathScurryBase {
- /**
- * separator for generating path strings
- */
- sep: '/';
- constructor(cwd?: URL | string, opts?: PathScurryOpts);
- /**
- * @internal
- */
- parseRootPath(_dir: string): string;
- /**
- * @internal
- */
- newRoot(fs: FSValue): PathPosix;
- /**
- * Return true if the provided path string is an absolute path
- */
- isAbsolute(p: string): boolean;
- }
- /**
- * {@link PathScurryBase} implementation for Darwin (macOS) systems.
- *
- * Defaults to case-insensitive matching, uses `'/'` for generating path
- * strings.
- *
- * Uses {@link PathPosix} for Path objects.
- */
- export declare class PathScurryDarwin extends PathScurryPosix {
- constructor(cwd?: URL | string, opts?: PathScurryOpts);
- }
- /**
- * Default {@link PathBase} implementation for the current platform.
- *
- * {@link PathWin32} on Windows systems, {@link PathPosix} on all others.
- */
- export declare const Path: typeof PathWin32 | typeof PathPosix;
- export type Path = PathBase | InstanceType<typeof Path>;
- /**
- * Default {@link PathScurryBase} implementation for the current platform.
- *
- * {@link PathScurryWin32} on Windows systems, {@link PathScurryDarwin} on
- * Darwin (macOS) systems, {@link PathScurryPosix} on all others.
- */
- export declare const PathScurry: typeof PathScurryWin32 | typeof PathScurryDarwin | typeof PathScurryPosix;
- export type PathScurry = PathScurryBase | InstanceType<typeof PathScurry>;
- export {};
- //# sourceMappingURL=index.d.ts.map
|