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