UNPKG

2.08 kBTypeScriptView Raw
1import { AbsoluteFsPath, FileStats, FileSystem, PathManipulation, PathSegment, PathString, ReadonlyFileSystem } from './types';
2/**
3 * A wrapper around the Node.js file-system that supports path manipulation.
4 */
5export declare class NodeJSPathManipulation implements PathManipulation {
6 pwd(): AbsoluteFsPath;
7 chdir(dir: AbsoluteFsPath): void;
8 resolve(...paths: string[]): AbsoluteFsPath;
9 dirname<T extends string>(file: T): T;
10 join<T extends string>(basePath: T, ...paths: string[]): T;
11 isRoot(path: AbsoluteFsPath): boolean;
12 isRooted(path: string): boolean;
13 relative<T extends PathString>(from: T, to: T): PathSegment | AbsoluteFsPath;
14 basename(filePath: string, extension?: string): PathSegment;
15 extname(path: AbsoluteFsPath | PathSegment): string;
16 normalize<T extends string>(path: T): T;
17}
18/**
19 * A wrapper around the Node.js file-system that supports readonly operations and path manipulation.
20 */
21export declare class NodeJSReadonlyFileSystem extends NodeJSPathManipulation implements ReadonlyFileSystem {
22 private _caseSensitive;
23 isCaseSensitive(): boolean;
24 exists(path: AbsoluteFsPath): boolean;
25 readFile(path: AbsoluteFsPath): string;
26 readFileBuffer(path: AbsoluteFsPath): Uint8Array;
27 readdir(path: AbsoluteFsPath): PathSegment[];
28 lstat(path: AbsoluteFsPath): FileStats;
29 stat(path: AbsoluteFsPath): FileStats;
30 realpath(path: AbsoluteFsPath): AbsoluteFsPath;
31 getDefaultLibLocation(): AbsoluteFsPath;
32}
33/**
34 * A wrapper around the Node.js file-system (i.e. the `fs` package).
35 */
36export declare class NodeJSFileSystem extends NodeJSReadonlyFileSystem implements FileSystem {
37 writeFile(path: AbsoluteFsPath, data: string | Uint8Array, exclusive?: boolean): void;
38 removeFile(path: AbsoluteFsPath): void;
39 symlink(target: AbsoluteFsPath, path: AbsoluteFsPath): void;
40 copyFile(from: AbsoluteFsPath, to: AbsoluteFsPath): void;
41 moveFile(from: AbsoluteFsPath, to: AbsoluteFsPath): void;
42 ensureDir(path: AbsoluteFsPath): void;
43 removeDeep(path: AbsoluteFsPath): void;
44}