1 |
|
2 |
|
3 |
|
4 | import * as fs from 'fs-extra';
|
5 | import * as stream from 'stream';
|
6 | export * from 'fs-extra';
|
7 | export { stat as statSafe, readdir as readdirSafe } from './safe';
|
8 | export interface ReaddirPOptions {
|
9 | |
10 |
|
11 |
|
12 |
|
13 |
|
14 | readonly filter?: (item: WalkerItem) => boolean;
|
15 | |
16 |
|
17 |
|
18 |
|
19 |
|
20 | readonly onError?: (err: Error) => void;
|
21 | readonly walkerOptions?: WalkerOptions;
|
22 | }
|
23 | export declare function readdirp(dir: string, { filter, onError, walkerOptions }?: ReaddirPOptions): Promise<string[]>;
|
24 | export declare const enum FileType {
|
25 | FILE = "file",
|
26 | DIRECTORY = "directory"
|
27 | }
|
28 | export interface RegularFileNode {
|
29 | path: string;
|
30 | type: FileType.FILE;
|
31 | parent: FileNode;
|
32 | }
|
33 | export interface DirectoryNode {
|
34 | path: string;
|
35 | type: FileType.DIRECTORY;
|
36 | parent?: FileNode;
|
37 | children: FileNode[];
|
38 | }
|
39 | export declare type FileNode = RegularFileNode | DirectoryNode;
|
40 | export interface GetFileTreeOptions<RE = {}, DE = {}> {
|
41 | |
42 |
|
43 |
|
44 |
|
45 |
|
46 | readonly onError?: (err: Error) => void;
|
47 | |
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | readonly onFileNode?: (node: RegularFileNode) => RegularFileNode & RE;
|
54 | |
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 | readonly onDirectoryNode?: (node: DirectoryNode) => DirectoryNode & DE;
|
61 | readonly walkerOptions?: WalkerOptions;
|
62 | }
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | export declare function getFileTree<RE = {}, DE = {}>(dir: string, { onError, onFileNode, onDirectoryNode, walkerOptions }?: GetFileTreeOptions<RE, DE>): Promise<RegularFileNode & RE | DirectoryNode & DE>;
|
73 | export declare function fileToString(filePath: string): Promise<string>;
|
74 | export declare function getFileChecksum(filePath: string): Promise<string>;
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 | export declare function getFileChecksums(p: string): Promise<[string, string | undefined]>;
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 | export declare function cacheFileChecksum(p: string, checksum?: string): Promise<void>;
|
92 | export declare function writeStreamToFile(stream: NodeJS.ReadableStream, destination: string): Promise<any>;
|
93 | export declare function pathAccessible(filePath: string, mode: number): Promise<boolean>;
|
94 | export declare function pathExists(filePath: string): Promise<boolean>;
|
95 | export declare function pathReadable(filePath: string): Promise<boolean>;
|
96 | export declare function pathWritable(filePath: string): Promise<boolean>;
|
97 | export declare function pathExecutable(filePath: string): Promise<boolean>;
|
98 | export declare function isExecutableFile(filePath: string): Promise<boolean>;
|
99 |
|
100 |
|
101 |
|
102 | export declare function findBaseDirectory(dir: string, file: string): Promise<string | undefined>;
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 | export declare function tmpfilepath(prefix?: string): string;
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 | export declare function compilePaths(filePath: string): string[];
|
118 | export interface WalkerItem {
|
119 | path: string;
|
120 | stats: fs.Stats;
|
121 | }
|
122 | export interface WalkerOptions {
|
123 | |
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 | readonly pathFilter?: (p: string) => boolean;
|
136 | }
|
137 | export interface Walker extends stream.Readable {
|
138 | on(event: 'data', callback: (item: WalkerItem) => void): this;
|
139 | on(event: string, callback: (...args: any[]) => any): this;
|
140 | }
|
141 | export declare class Walker extends stream.Readable {
|
142 | readonly p: string;
|
143 | readonly options: WalkerOptions;
|
144 | readonly paths: string[];
|
145 | constructor(p: string, options?: WalkerOptions);
|
146 | _read(): void;
|
147 | }
|
148 | export declare function walk(p: string, options?: WalkerOptions): Walker;
|