1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | export declare type BrandedPath<B extends string> = string & {
|
16 | _brand: B;
|
17 | };
|
18 |
|
19 |
|
20 |
|
21 | export declare type AbsoluteFsPath = BrandedPath<'AbsoluteFsPath'>;
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | export declare type PathSegment = BrandedPath<'PathSegment'>;
|
28 |
|
29 |
|
30 |
|
31 | export interface PathManipulation {
|
32 | extname(path: AbsoluteFsPath | PathSegment): string;
|
33 | isRoot(path: AbsoluteFsPath): boolean;
|
34 | isRooted(path: string): boolean;
|
35 | dirname<T extends PathString>(file: T): T;
|
36 | extname(path: AbsoluteFsPath | PathSegment): string;
|
37 | join<T extends PathString>(basePath: T, ...paths: string[]): T;
|
38 | |
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | relative<T extends PathString>(from: T, to: T): PathSegment | AbsoluteFsPath;
|
46 | basename(filePath: string, extension?: string): PathSegment;
|
47 | normalize<T extends PathString>(path: T): T;
|
48 | resolve(...paths: string[]): AbsoluteFsPath;
|
49 | pwd(): AbsoluteFsPath;
|
50 | chdir(path: AbsoluteFsPath): void;
|
51 | }
|
52 |
|
53 |
|
54 |
|
55 | export interface ReadonlyFileSystem extends PathManipulation {
|
56 | isCaseSensitive(): boolean;
|
57 | exists(path: AbsoluteFsPath): boolean;
|
58 | readFile(path: AbsoluteFsPath): string;
|
59 | readFileBuffer(path: AbsoluteFsPath): Uint8Array;
|
60 | readdir(path: AbsoluteFsPath): PathSegment[];
|
61 | lstat(path: AbsoluteFsPath): FileStats;
|
62 | stat(path: AbsoluteFsPath): FileStats;
|
63 | realpath(filePath: AbsoluteFsPath): AbsoluteFsPath;
|
64 | getDefaultLibLocation(): AbsoluteFsPath;
|
65 | }
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | export interface FileSystem extends ReadonlyFileSystem {
|
73 | writeFile(path: AbsoluteFsPath, data: string | Uint8Array, exclusive?: boolean): void;
|
74 | removeFile(path: AbsoluteFsPath): void;
|
75 | symlink(target: AbsoluteFsPath, path: AbsoluteFsPath): void;
|
76 | copyFile(from: AbsoluteFsPath, to: AbsoluteFsPath): void;
|
77 | moveFile(from: AbsoluteFsPath, to: AbsoluteFsPath): void;
|
78 | ensureDir(path: AbsoluteFsPath): void;
|
79 | removeDeep(path: AbsoluteFsPath): void;
|
80 | }
|
81 | export declare type PathString = string | AbsoluteFsPath | PathSegment;
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | export interface FileStats {
|
87 | isFile(): boolean;
|
88 | isDirectory(): boolean;
|
89 | isSymbolicLink(): boolean;
|
90 | }
|