@umijs/utils 4.0.0-rc.3 → 4.0.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/compiled/execa/index.js +1 -1
  2. package/compiled/fs-extra/index.d.ts +347 -116
  3. package/compiled/fs-extra/index.js +1 -1
  4. package/compiled/pkg-up/index.js +1 -1
  5. package/compiled/yargs-parser/index.js +1 -1
  6. package/dist/index.js +5 -1
  7. package/dist/installDeps.js +5 -1
  8. package/dist/npmClient.js +2 -2
  9. package/package.json +4 -4
  10. package/compiled/globby/@nodelib/fs.scandir/out/adapters/fs.d.ts +0 -20
  11. package/compiled/globby/@nodelib/fs.scandir/out/index.d.ts +0 -12
  12. package/compiled/globby/@nodelib/fs.scandir/out/providers/async.d.ts +0 -7
  13. package/compiled/globby/@nodelib/fs.scandir/out/settings.d.ts +0 -20
  14. package/compiled/globby/@nodelib/fs.scandir/out/types/index.d.ts +0 -20
  15. package/compiled/globby/@nodelib/fs.stat/out/adapters/fs.d.ts +0 -13
  16. package/compiled/globby/@nodelib/fs.stat/out/index.d.ts +0 -12
  17. package/compiled/globby/@nodelib/fs.stat/out/providers/async.d.ts +0 -4
  18. package/compiled/globby/@nodelib/fs.stat/out/settings.d.ts +0 -16
  19. package/compiled/globby/@nodelib/fs.stat/out/types/index.d.ts +0 -4
  20. package/compiled/globby/@nodelib/fs.walk/out/index.d.ts +0 -14
  21. package/compiled/globby/@nodelib/fs.walk/out/providers/async.d.ts +0 -12
  22. package/compiled/globby/@nodelib/fs.walk/out/readers/async.d.ts +0 -30
  23. package/compiled/globby/@nodelib/fs.walk/out/readers/reader.d.ts +0 -6
  24. package/compiled/globby/@nodelib/fs.walk/out/settings.d.ts +0 -30
  25. package/compiled/globby/@nodelib/fs.walk/out/types/index.d.ts +0 -8
  26. package/compiled/globby/LICENSE +0 -9
  27. package/compiled/globby/fast-glob/out/index.d.ts +0 -27
  28. package/compiled/globby/fast-glob/out/managers/tasks.d.ts +0 -22
  29. package/compiled/globby/fast-glob/out/settings.d.ts +0 -164
  30. package/compiled/globby/fast-glob/out/types/index.d.ts +0 -31
  31. package/compiled/globby/index.d.ts +0 -206
  32. package/compiled/globby/index.js +0 -37
  33. package/compiled/globby/package.json +0 -1
@@ -1,4 +1,4 @@
1
- // Type definitions for fs-extra 8.1
1
+ // Type definitions for fs-extra 9.0
2
2
  // Project: https://github.com/jprichardson/node-fs-extra
3
3
  // Definitions by: Alan Agius <https://github.com/alan-agius4>,
4
4
  // midknight41 <https://github.com/midknight41>,
@@ -8,15 +8,17 @@
8
8
  // Sang Dang <https://github.com/sangdth>,
9
9
  // Florian Keller <https://github.com/ffflorian>
10
10
  // Piotr Błażejewicz <https://github.com/peterblazejewicz>
11
+ // Tiger Oakes <https://github.com/NotWoods>
11
12
  // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
12
- // TypeScript Version: 2.2
13
+ // Minimum TypeScript Version: 3.9
13
14
 
14
15
  /// <reference types="node" />
15
16
 
16
17
  import * as fs from 'fs';
17
18
  import Stats = fs.Stats;
19
+ import PathLike = fs.PathLike;
18
20
 
19
- export * from "fs";
21
+ export * from 'fs';
20
22
 
21
23
  export function copy(src: string, dest: string, options?: CopyOptions): Promise<void>;
22
24
  export function copy(src: string, dest: string, callback: (err: Error) => void): void;
@@ -41,6 +43,7 @@ export function createSymlink(src: string, dest: string, type: SymlinkType, call
41
43
  export function createSymlinkSync(src: string, dest: string, type: SymlinkType): void;
42
44
 
43
45
  export function ensureDir(path: string, options?: EnsureOptions | number): Promise<void>;
46
+ export function ensureDir(path: string, callback?: (err: Error) => void): void;
44
47
  export function ensureDir(path: string, options?: EnsureOptions | number, callback?: (err: Error) => void): void;
45
48
  export function ensureDirSync(path: string, options?: EnsureOptions | number): void;
46
49
 
@@ -51,43 +54,80 @@ export function mkdirp(dir: string, callback: (err: Error) => void): void;
51
54
  export function mkdirsSync(dir: string): void;
52
55
  export function mkdirpSync(dir: string): void;
53
56
 
54
- export function outputFile(file: string, data: any, options?: WriteFileOptions | string): Promise<void>;
57
+ export function outputFile(
58
+ file: string,
59
+ data: any,
60
+ options?: WriteFileOptions | BufferEncoding | string,
61
+ ): Promise<void>;
55
62
  export function outputFile(file: string, data: any, callback: (err: Error) => void): void;
56
- export function outputFile(file: string, data: any, options: WriteFileOptions | string, callback: (err: Error) => void): void;
57
- export function outputFileSync(file: string, data: any, options?: WriteFileOptions | string): void;
63
+ export function outputFile(
64
+ file: string,
65
+ data: any,
66
+ options: WriteFileOptions | string,
67
+ callback: (err: Error) => void,
68
+ ): void;
69
+ export function outputFileSync(file: string, data: any, options?: WriteFileOptions | BufferEncoding | string): void;
58
70
 
59
- export function readJson(file: string, options?: ReadOptions): Promise<any>;
71
+ export function readJson(file: string, options?: ReadOptions | BufferEncoding | string): Promise<any>;
60
72
  export function readJson(file: string, callback: (err: Error, jsonObject: any) => void): void;
61
- export function readJson(file: string, options: ReadOptions, callback: (err: Error, jsonObject: any) => void): void;
62
- export function readJSON(file: string, options?: ReadOptions): Promise<any>;
73
+ export function readJson(
74
+ file: string,
75
+ options: ReadOptions | BufferEncoding | string,
76
+ callback: (err: Error, jsonObject: any) => void,
77
+ ): void;
78
+ export function readJSON(file: string, options?: ReadOptions | BufferEncoding | string): Promise<any>;
63
79
  export function readJSON(file: string, callback: (err: Error, jsonObject: any) => void): void;
64
- export function readJSON(file: string, options: ReadOptions, callback: (err: Error, jsonObject: any) => void): void;
80
+ export function readJSON(
81
+ file: string,
82
+ options: ReadOptions | BufferEncoding | string,
83
+ callback: (err: Error, jsonObject: any) => void,
84
+ ): void;
65
85
 
66
- export function readJsonSync(file: string, options?: ReadOptions): any;
67
- export function readJSONSync(file: string, options?: ReadOptions): any;
86
+ export function readJsonSync(file: string, options?: ReadOptions | BufferEncoding | string): any;
87
+ export function readJSONSync(file: string, options?: ReadOptions | BufferEncoding | string): any;
68
88
 
69
- export function remove(dir: string): Promise<void>;
70
89
  export function remove(dir: string, callback: (err: Error) => void): void;
90
+ export function remove(dir: string, callback?: (err: Error) => void): Promise<void>;
71
91
  export function removeSync(dir: string): void;
72
92
 
73
- export function outputJSON(file: string, data: any, options?: WriteOptions): Promise<void>;
74
- export function outputJSON(file: string, data: any, options: WriteOptions, callback: (err: Error) => void): void;
93
+ export function outputJSON(file: string, data: any, options?: WriteOptions | BufferEncoding | string): Promise<void>;
94
+ export function outputJSON(
95
+ file: string,
96
+ data: any,
97
+ options: WriteOptions | BufferEncoding | string,
98
+ callback: (err: Error) => void,
99
+ ): void;
75
100
  export function outputJSON(file: string, data: any, callback: (err: Error) => void): void;
76
- export function outputJson(file: string, data: any, options?: WriteOptions): Promise<void>;
77
- export function outputJson(file: string, data: any, options: WriteOptions, callback: (err: Error) => void): void;
101
+ export function outputJson(file: string, data: any, options?: WriteOptions | BufferEncoding | string): Promise<void>;
102
+ export function outputJson(
103
+ file: string,
104
+ data: any,
105
+ options: WriteOptions | BufferEncoding | string,
106
+ callback: (err: Error) => void,
107
+ ): void;
78
108
  export function outputJson(file: string, data: any, callback: (err: Error) => void): void;
79
- export function outputJsonSync(file: string, data: any, options?: WriteOptions): void;
80
- export function outputJSONSync(file: string, data: any, options?: WriteOptions): void;
109
+ export function outputJsonSync(file: string, data: any, options?: WriteOptions | BufferEncoding | string): void;
110
+ export function outputJSONSync(file: string, data: any, options?: WriteOptions | BufferEncoding | string): void;
81
111
 
82
- export function writeJSON(file: string, object: any, options?: WriteOptions): Promise<void>;
112
+ export function writeJSON(file: string, object: any, options?: WriteOptions | BufferEncoding | string): Promise<void>;
83
113
  export function writeJSON(file: string, object: any, callback: (err: Error) => void): void;
84
- export function writeJSON(file: string, object: any, options: WriteOptions, callback: (err: Error) => void): void;
85
- export function writeJson(file: string, object: any, options?: WriteOptions): Promise<void>;
114
+ export function writeJSON(
115
+ file: string,
116
+ object: any,
117
+ options: WriteOptions | BufferEncoding | string,
118
+ callback: (err: Error) => void,
119
+ ): void;
120
+ export function writeJson(file: string, object: any, options?: WriteOptions | BufferEncoding | string): Promise<void>;
86
121
  export function writeJson(file: string, object: any, callback: (err: Error) => void): void;
87
- export function writeJson(file: string, object: any, options: WriteOptions, callback: (err: Error) => void): void;
122
+ export function writeJson(
123
+ file: string,
124
+ object: any,
125
+ options: WriteOptions | BufferEncoding | string,
126
+ callback: (err: Error) => void,
127
+ ): void;
88
128
 
89
- export function writeJsonSync(file: string, object: any, options?: WriteOptions): void;
90
- export function writeJSONSync(file: string, object: any, options?: WriteOptions): void;
129
+ export function writeJsonSync(file: string, object: any, options?: WriteOptions | BufferEncoding | string): void;
130
+ export function writeJSONSync(file: string, object: any, options?: WriteOptions | BufferEncoding | string): void;
91
131
 
92
132
  export function ensureFile(path: string): Promise<void>;
93
133
  export function ensureFile(path: string, callback: (err: Error) => void): void;
@@ -95,7 +135,11 @@ export function ensureFileSync(path: string): void;
95
135
 
96
136
  export function ensureLink(src: string, dest: string): Promise<void>;
97
137
  export function ensureLink(src: string, dest: string, callback: (err: Error) => void): void;
138
+ // alias for ensureLink
139
+ export const createLink: typeof ensureLink;
98
140
  export function ensureLinkSync(src: string, dest: string): void;
141
+ // aliased as
142
+ export const createLinkSync: typeof ensureLinkSync;
99
143
 
100
144
  export function ensureSymlink(src: string, dest: string, type?: SymlinkType): Promise<void>;
101
145
  export function ensureSymlink(src: string, dest: string, type: SymlinkType, callback: (err: Error) => void): void;
@@ -104,7 +148,10 @@ export function ensureSymlinkSync(src: string, dest: string, type?: SymlinkType)
104
148
 
105
149
  export function emptyDir(path: string): Promise<void>;
106
150
  export function emptyDir(path: string, callback: (err: Error) => void): void;
151
+ export const emptydir: typeof emptyDir;
152
+
107
153
  export function emptyDirSync(path: string): void;
154
+ export const emptydirSync: typeof emptyDirSync;
108
155
 
109
156
  export function pathExists(path: string): Promise<boolean>;
110
157
  export function pathExists(path: string, callback: (err: Error, exists: boolean) => void): void;
@@ -113,26 +160,45 @@ export function pathExistsSync(path: string): boolean;
113
160
  // fs async methods
114
161
  // copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v6/index.d.ts
115
162
 
116
- export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void;
117
- export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException) => void): void;
118
- export function access(path: string | Buffer, mode?: number): Promise<void>;
119
-
120
- export function appendFile(file: string | Buffer | number, data: any, options: { encoding?: string | undefined; mode?: number | string | undefined; flag?: string | undefined; },
121
- callback: (err: NodeJS.ErrnoException) => void): void;
122
- export function appendFile(file: string | Buffer | number, data: any, callback: (err: NodeJS.ErrnoException) => void): void;
123
- export function appendFile(file: string | Buffer | number, data: any, options?: { encoding?: string | undefined; mode?: number | string | undefined; flag?: string | undefined; }): Promise<void>;
124
-
125
- export function chmod(path: string | Buffer, mode: string | number, callback: (err: NodeJS.ErrnoException) => void): void;
126
- export function chmod(path: string | Buffer, mode: string | number): Promise<void>;
127
-
128
- export function chown(path: string | Buffer, uid: number, gid: number): Promise<void>;
129
- export function chown(path: string | Buffer, uid: number, gid: number, callback: (err: NodeJS.ErrnoException) => void): void;
163
+ export function access(path: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
164
+ export function access(path: PathLike, mode: number, callback: (err: NodeJS.ErrnoException) => void): void;
165
+ export function access(path: PathLike, mode?: number): Promise<void>;
166
+
167
+ export function appendFile(
168
+ file: PathLike | number,
169
+ data: any,
170
+ options: {
171
+ encoding?: BufferEncoding | string | undefined;
172
+ mode?: number | string | undefined;
173
+ flag?: string | undefined;
174
+ },
175
+ callback: (err: NodeJS.ErrnoException) => void,
176
+ ): void;
177
+ export function appendFile(file: PathLike | number, data: any, callback: (err: NodeJS.ErrnoException) => void): void;
178
+ export function appendFile(
179
+ file: PathLike | number,
180
+ data: any,
181
+ options?:
182
+ | {
183
+ encoding?: BufferEncoding | string | undefined;
184
+ mode?: number | string | undefined;
185
+ flag?: string | undefined;
186
+ }
187
+ | BufferEncoding
188
+ | string,
189
+ ): Promise<void>;
190
+
191
+ export function chmod(path: PathLike, mode: Mode, callback: (err: NodeJS.ErrnoException) => void): void;
192
+ export function chmod(path: PathLike, mode: Mode): Promise<void>;
193
+
194
+ export function chown(path: PathLike, uid: number, gid: number): Promise<void>;
195
+ export function chown(path: PathLike, uid: number, gid: number, callback: (err: NodeJS.ErrnoException) => void): void;
130
196
 
131
197
  export function close(fd: number, callback: (err: NodeJS.ErrnoException) => void): void;
132
198
  export function close(fd: number): Promise<void>;
133
199
 
134
- export function fchmod(fd: number, mode: string | number, callback: (err: NodeJS.ErrnoException) => void): void;
135
- export function fchmod(fd: number, mode: string | number): Promise<void>;
200
+ export function fchmod(fd: number, mode: Mode, callback: (err: NodeJS.ErrnoException) => void): void;
201
+ export function fchmod(fd: number, mode: Mode): Promise<void>;
136
202
 
137
203
  export function fchown(fd: number, uid: number, gid: number, callback: (err: NodeJS.ErrnoException) => void): void;
138
204
  export function fchown(fd: number, uid: number, gid: number): Promise<void>;
@@ -155,105 +221,272 @@ export function futimes(fd: number, atime: Date, mtime: Date, callback: (err: No
155
221
  export function futimes(fd: number, atime: number, mtime: number): Promise<void>;
156
222
  export function futimes(fd: number, atime: Date, mtime: Date): Promise<void>;
157
223
 
158
- export function lchown(path: string | Buffer, uid: number, gid: number, callback: (err: NodeJS.ErrnoException) => void): void;
159
- export function lchown(path: string | Buffer, uid: number, gid: number): Promise<void>;
224
+ export function lchown(path: PathLike, uid: number, gid: number, callback: (err: NodeJS.ErrnoException) => void): void;
225
+ export function lchown(path: PathLike, uid: number, gid: number): Promise<void>;
160
226
 
161
- export function link(srcpath: string | Buffer, dstpath: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void;
162
- export function link(srcpath: string | Buffer, dstpath: string | Buffer): Promise<void>;
227
+ export function link(existingPath: PathLike, newPath: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
228
+ export function link(existingPath: PathLike, newPath: PathLike): Promise<void>;
163
229
 
164
- export function lstat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
165
- export function lstat(path: string | Buffer): Promise<Stats>;
230
+ export function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
231
+ export function lstat(path: PathLike): Promise<Stats>;
166
232
 
167
233
  /**
168
234
  * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
169
235
  *
170
236
  * @param callback No arguments other than a possible exception are given to the completion callback.
171
237
  */
172
- export function mkdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void;
238
+ export function mkdir(path: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
173
239
  /**
174
240
  * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
175
241
  *
176
242
  * @param callback No arguments other than a possible exception are given to the completion callback.
177
243
  */
178
- export function mkdir(path: string | Buffer, mode: number | string, callback: (err: NodeJS.ErrnoException) => void): void;
179
- export function mkdir(path: string | Buffer): Promise<void>;
180
-
181
- export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void;
182
- export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void;
183
- export function open(path: string | Buffer, flags: string | number, mode?: number): Promise<number>;
244
+ export function mkdir(
245
+ path: PathLike,
246
+ options: Mode | fs.MakeDirectoryOptions | null,
247
+ callback: (err: NodeJS.ErrnoException) => void,
248
+ ): void;
249
+ export function mkdir(path: PathLike, options?: Mode | fs.MakeDirectoryOptions | null): Promise<void>;
250
+ export function mkdirSync(path: PathLike, options?: Mode | fs.MakeDirectoryOptions | null): void;
184
251
 
185
- export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number | null,
186
- callback: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void;
187
- export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number | null): Promise<ReadResult>;
252
+ export function open(
253
+ path: PathLike,
254
+ flags: string | number,
255
+ callback: (err: NodeJS.ErrnoException, fd: number) => void,
256
+ ): void;
257
+ export function open(
258
+ path: PathLike,
259
+ flags: string | number,
260
+ mode: Mode,
261
+ callback: (err: NodeJS.ErrnoException, fd: number) => void,
262
+ ): void;
263
+ export function open(path: PathLike, flags: string | number, mode?: Mode | null): Promise<number>;
188
264
 
189
- export function readFile(file: string | Buffer | number, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
190
- export function readFile(file: string | Buffer | number, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
265
+ export function opendir(path: string, cb: (err: NodeJS.ErrnoException | null, dir: fs.Dir) => void): void;
266
+ export function opendir(
267
+ path: string,
268
+ options: fs.OpenDirOptions,
269
+ cb: (err: NodeJS.ErrnoException | null, dir: fs.Dir) => void,
270
+ ): void;
271
+ export function opendir(path: string, options?: fs.OpenDirOptions): Promise<fs.Dir>;
272
+
273
+ export function read<TBuffer extends ArrayBufferView>(
274
+ fd: number,
275
+ buffer: TBuffer,
276
+ offset: number,
277
+ length: number,
278
+ position: number | null,
279
+ callback: (err: NodeJS.ErrnoException, bytesRead: number, buffer: TBuffer) => void,
280
+ ): void;
281
+ export function read<TBuffer extends ArrayBufferView>(
282
+ fd: number,
283
+ buffer: TBuffer,
284
+ offset: number,
285
+ length: number,
286
+ position: number | null,
287
+ ): Promise<{ bytesRead: number; buffer: TBuffer }>;
288
+
289
+ export function readFile(file: PathLike | number, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
290
+ export function readFile(
291
+ file: PathLike | number,
292
+ encoding: BufferEncoding | string,
293
+ callback: (err: NodeJS.ErrnoException, data: string) => void,
294
+ ): void;
191
295
  export function readFile(
192
- file: string | Buffer | number,
193
- options: { flag?: string | undefined; } | { encoding: string; flag?: string | undefined; },
194
- callback: (err: NodeJS.ErrnoException, data: Buffer) => void
296
+ file: PathLike | number,
297
+ options: { flag?: string | undefined } | { encoding: BufferEncoding | string; flag?: string | undefined },
298
+ callback: (err: NodeJS.ErrnoException, data: Buffer) => void,
195
299
  ): void;
196
- export function readFile(file: string | Buffer | number, options: { flag?: string | undefined; } | { encoding: string; flag?: string | undefined; }): Promise<string>;
300
+ export function readFile(
301
+ file: PathLike | number,
302
+ options: { flag?: string | undefined } | { encoding: BufferEncoding | string; flag?: string | undefined },
303
+ ): Promise<string>;
197
304
  // tslint:disable-next-line:unified-signatures
198
- export function readFile(file: string | Buffer | number, encoding: string): Promise<string>;
199
- export function readFile(file: string | Buffer | number): Promise<Buffer>;
200
-
201
- export function readdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException, files: string[]) => void): void;
202
- export function readdir(path: string | Buffer): Promise<string[]>;
203
-
204
- export function readlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException, linkString: string) => any): void;
205
- export function readlink(path: string | Buffer): Promise<string>;
305
+ export function readFile(file: PathLike | number, encoding: BufferEncoding | string): Promise<string>;
306
+ export function readFile(file: PathLike | number): Promise<Buffer>;
307
+
308
+ export function readdir(path: PathLike, callback: (err: NodeJS.ErrnoException, files: string[]) => void): void;
309
+ export function readdir(
310
+ path: PathLike,
311
+ options: 'buffer' | { encoding: 'buffer'; withFileTypes?: false | undefined },
312
+ ): Promise<Buffer[]>;
313
+ export function readdir(
314
+ path: PathLike,
315
+ options?:
316
+ | { encoding: BufferEncoding | string | null; withFileTypes?: false | undefined }
317
+ | BufferEncoding
318
+ | string
319
+ | null,
320
+ ): Promise<string[]>;
321
+ export function readdir(
322
+ path: PathLike,
323
+ options?: { encoding?: BufferEncoding | string | null | undefined; withFileTypes?: false | undefined },
324
+ ): Promise<string[] | Buffer[]>;
325
+ export function readdir(
326
+ path: PathLike,
327
+ options: { encoding?: BufferEncoding | string | null | undefined; withFileTypes: true },
328
+ ): Promise<fs.Dirent[]>;
329
+
330
+ export function readlink(path: PathLike, callback: (err: NodeJS.ErrnoException, linkString: string) => any): void;
331
+ export function readlink(path: PathLike): Promise<string>;
332
+
333
+ export function realpath(path: PathLike, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
334
+ export function realpath(
335
+ path: PathLike,
336
+ cache: { [path: string]: string },
337
+ callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any,
338
+ ): void;
339
+ export function realpath(path: PathLike, cache?: { [path: string]: string }): Promise<string>;
340
+
341
+ /* tslint:disable:unified-signatures */
342
+ export namespace realpath {
343
+ const native: {
344
+ (path: PathLike, options: { encoding: 'buffer' } | 'buffer'): Promise<Buffer>;
345
+ (
346
+ path: PathLike,
347
+ options: { encoding: BufferEncoding | string | null } | BufferEncoding | string | undefined | null,
348
+ ): Promise<string>;
349
+ (path: PathLike, options: { encoding: BufferEncoding | string | null } | string | undefined | null): Promise<
350
+ string | Buffer
351
+ >;
352
+ (path: PathLike): Promise<string>;
353
+ } & typeof fs.realpath.native;
354
+ }
355
+ /* tslint:enable:unified-signatures */
206
356
 
207
- export function realpath(path: string | Buffer, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
208
- export function realpath(path: string | Buffer, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
209
- export function realpath(path: string | Buffer, cache?: { [path: string]: string }): Promise<string>;
357
+ export function rename(oldPath: PathLike, newPath: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
358
+ export function rename(oldPath: PathLike, newPath: PathLike): Promise<void>;
210
359
 
211
- export function rename(oldPath: string, newPath: string, callback: (err: NodeJS.ErrnoException) => void): void;
212
- export function rename(oldPath: string, newPath: string): Promise<void>;
360
+ /**
361
+ * Asynchronously removes files and directories (modeled on the standard POSIX
362
+ * `rm` utility).
363
+ *
364
+ * Only available in node >= v14.14.0
365
+ */
366
+ export function rm(
367
+ path: PathLike,
368
+ options?: {
369
+ force?: boolean | undefined;
370
+ maxRetries?: number | undefined;
371
+ recursive?: boolean | undefined;
372
+ retryDelay?: number | undefined;
373
+ },
374
+ ): Promise<void>;
213
375
 
214
376
  /**
215
377
  * Asynchronous rmdir - removes the directory specified in {path}
216
378
  *
217
379
  * @param callback No arguments other than a possible exception are given to the completion callback.
218
380
  */
219
- export function rmdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void;
220
- export function rmdir(path: string | Buffer): Promise<void>;
381
+ export function rmdir(path: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
382
+ export function rmdir(path: PathLike, options?: fs.RmDirOptions): Promise<void>;
221
383
 
222
- export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
223
- export function stat(path: string | Buffer): Promise<Stats>;
384
+ export function stat(path: PathLike, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
385
+ export function stat(path: PathLike): Promise<Stats>;
224
386
 
225
- export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type: FsSymlinkType | undefined, callback: (err: NodeJS.ErrnoException) => void): void;
226
- export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void;
227
- export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: FsSymlinkType): Promise<void>;
387
+ export function symlink(
388
+ target: PathLike,
389
+ path: PathLike,
390
+ type: SymlinkType | undefined,
391
+ callback: (err: NodeJS.ErrnoException) => void,
392
+ ): void;
393
+ export function symlink(target: PathLike, path: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
394
+ export function symlink(target: PathLike, path: PathLike, type?: SymlinkType): Promise<void>;
228
395
 
229
- export function truncate(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void;
230
- export function truncate(path: string | Buffer, len: number, callback: (err: NodeJS.ErrnoException) => void): void;
231
- export function truncate(path: string | Buffer, len?: number): Promise<void>;
396
+ export function truncate(path: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
397
+ export function truncate(path: PathLike, len: number, callback: (err: NodeJS.ErrnoException) => void): void;
398
+ export function truncate(path: PathLike, len?: number): Promise<void>;
232
399
 
233
400
  /**
234
401
  * Asynchronous unlink - deletes the file specified in {path}
235
402
  *
236
403
  * @param callback No arguments other than a possible exception are given to the completion callback.
237
404
  */
238
- export function unlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void;
239
- export function unlink(path: string | Buffer): Promise<void>;
240
-
241
- export function utimes(path: string | Buffer, atime: number, mtime: number, callback: (err: NodeJS.ErrnoException) => void): void;
242
- export function utimes(path: string | Buffer, atime: Date, mtime: Date, callback: (err: NodeJS.ErrnoException) => void): void;
243
- export function utimes(path: string | Buffer, atime: number, mtime: number): Promise<void>;
244
- export function utimes(path: string | Buffer, atime: Date, mtime: Date): Promise<void>;
245
-
246
- export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number | null, callback: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
247
- export function write(fd: number, buffer: Buffer, offset: number, length: number, callback: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
248
- export function write(fd: number, data: any, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
249
- export function write(fd: number, data: any, offset: number, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
250
- export function write(fd: number, data: any, offset: number, encoding: string, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
251
- export function write(fd: number, buffer: Buffer, offset?: number, length?: number, position?: number | null): Promise<WriteResult>;
252
- export function write(fd: number, data: any, offset?: number, encoding?: string): Promise<WriteResult>;
253
-
254
- export function writeFile(file: string | Buffer | number, data: any, callback: (err: NodeJS.ErrnoException) => void): void;
255
- export function writeFile(file: string | Buffer | number, data: any, options?: WriteFileOptions | string): Promise<void>;
256
- export function writeFile(file: string | Buffer | number, data: any, options: WriteFileOptions | string, callback: (err: NodeJS.ErrnoException) => void): void;
405
+ export function unlink(path: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
406
+ export function unlink(path: PathLike): Promise<void>;
407
+
408
+ export function utimes(
409
+ path: PathLike,
410
+ atime: number,
411
+ mtime: number,
412
+ callback: (err: NodeJS.ErrnoException) => void,
413
+ ): void;
414
+ export function utimes(path: PathLike, atime: Date, mtime: Date, callback: (err: NodeJS.ErrnoException) => void): void;
415
+ export function utimes(path: PathLike, atime: number, mtime: number): Promise<void>;
416
+ export function utimes(path: PathLike, atime: Date, mtime: Date): Promise<void>;
417
+
418
+ export function write<TBuffer extends ArrayBufferView>(
419
+ fd: number,
420
+ buffer: TBuffer,
421
+ offset: number,
422
+ length: number,
423
+ position: number | null,
424
+ callback: (err: NodeJS.ErrnoException, written: number, buffer: TBuffer) => void,
425
+ ): void;
426
+ export function write<TBuffer extends ArrayBufferView>(
427
+ fd: number,
428
+ buffer: TBuffer,
429
+ offset: number,
430
+ length: number,
431
+ callback: (err: NodeJS.ErrnoException, written: number, buffer: TBuffer) => void,
432
+ ): void;
433
+ export function write(
434
+ fd: number,
435
+ data: any,
436
+ callback: (err: NodeJS.ErrnoException, written: number, str: string) => void,
437
+ ): void;
438
+ export function write(
439
+ fd: number,
440
+ data: any,
441
+ offset: number,
442
+ callback: (err: NodeJS.ErrnoException, written: number, str: string) => void,
443
+ ): void;
444
+ export function write(
445
+ fd: number,
446
+ data: any,
447
+ offset: number,
448
+ encoding: BufferEncoding | string,
449
+ callback: (err: NodeJS.ErrnoException, written: number, str: string) => void,
450
+ ): void;
451
+ export function write<TBuffer extends ArrayBufferView>(
452
+ fd: number,
453
+ buffer: TBuffer,
454
+ offset?: number,
455
+ length?: number,
456
+ position?: number | null,
457
+ ): Promise<{ bytesWritten: number; buffer: TBuffer }>;
458
+ export function write(
459
+ fd: number,
460
+ data: any,
461
+ offset?: number,
462
+ encoding?: BufferEncoding | string,
463
+ ): Promise<{ bytesWritten: number; buffer: string }>;
464
+
465
+ export function writeFile(file: PathLike | number, data: any, callback: (err: NodeJS.ErrnoException) => void): void;
466
+ export function writeFile(
467
+ file: PathLike | number,
468
+ data: any,
469
+ options?: WriteFileOptions | BufferEncoding | string,
470
+ ): Promise<void>;
471
+ export function writeFile(
472
+ file: PathLike | number,
473
+ data: any,
474
+ options: WriteFileOptions | BufferEncoding | string,
475
+ callback: (err: NodeJS.ErrnoException) => void,
476
+ ): void;
477
+
478
+ export function writev(
479
+ fd: number,
480
+ buffers: NodeJS.ArrayBufferView[],
481
+ position: number,
482
+ cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void,
483
+ ): void;
484
+ export function writev(
485
+ fd: number,
486
+ buffers: NodeJS.ArrayBufferView[],
487
+ cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void,
488
+ ): void;
489
+ export function writev(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): Promise<WritevResult>;
257
490
 
258
491
  /**
259
492
  * Asynchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
@@ -275,8 +508,11 @@ export interface PathEntryStream {
275
508
  export type CopyFilterSync = (src: string, dest: string) => boolean;
276
509
  export type CopyFilterAsync = (src: string, dest: string) => Promise<boolean>;
277
510
 
278
- export type SymlinkType = "dir" | "file";
279
- export type FsSymlinkType = "dir" | "file" | "junction";
511
+ export type SymlinkType = 'dir' | 'file' | 'junction';
512
+
513
+ export type Mode = string | number;
514
+
515
+ export type ArrayBufferView = NodeJS.TypedArray | DataView;
280
516
 
281
517
  export interface CopyOptions {
282
518
  dereference?: boolean | undefined;
@@ -304,12 +540,12 @@ export interface ReadOptions {
304
540
  throws?: boolean | undefined;
305
541
  fs?: object | undefined;
306
542
  reviver?: any;
307
- encoding?: string | undefined;
543
+ encoding?: BufferEncoding | string | undefined;
308
544
  flag?: string | undefined;
309
545
  }
310
546
 
311
547
  export interface WriteFileOptions {
312
- encoding?: string | undefined;
548
+ encoding?: BufferEncoding | string | null | undefined;
313
549
  flag?: string | undefined;
314
550
  mode?: number | undefined;
315
551
  }
@@ -321,12 +557,7 @@ export interface WriteOptions extends WriteFileOptions {
321
557
  EOL?: string | undefined;
322
558
  }
323
559
 
324
- export interface ReadResult {
325
- bytesRead: number;
326
- buffer: Buffer;
327
- }
328
-
329
- export interface WriteResult {
560
+ export interface WritevResult {
330
561
  bytesWritten: number;
331
- buffer: Buffer;
562
+ buffers: ArrayBufferView[];
332
563
  }