@reliverse/relifso 1.1.3 → 1.2.0
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.
- package/README.md +6 -1
- package/bin/impl/async.d.ts +7 -0
- package/bin/impl/async.js +9 -0
- package/bin/impl/copy.d.ts +20 -0
- package/bin/impl/copy.js +28 -0
- package/bin/impl/create-file.d.ts +1 -0
- package/bin/impl/create-file.js +8 -0
- package/bin/impl/dive.d.ts +17 -0
- package/bin/impl/dive.js +56 -0
- package/bin/impl/empty-dir.d.ts +1 -0
- package/bin/impl/empty-dir.js +10 -0
- package/bin/impl/mkdirs.d.ts +1 -0
- package/bin/impl/mkdirs.js +7 -0
- package/bin/impl/move.d.ts +14 -0
- package/bin/impl/move.js +42 -0
- package/bin/impl/output-file.d.ts +8 -0
- package/bin/impl/output-file.js +8 -0
- package/bin/impl/output-json.d.ts +8 -0
- package/bin/impl/output-json.js +8 -0
- package/bin/impl/path-exists.d.ts +1 -0
- package/bin/impl/path-exists.js +4 -0
- package/bin/impl/read-file.d.ts +12 -0
- package/bin/impl/read-file.js +12 -0
- package/bin/impl/read-json.d.ts +14 -0
- package/bin/impl/read-json.js +24 -0
- package/bin/impl/remove.d.ts +1 -0
- package/bin/impl/remove.js +4 -0
- package/bin/impl/write-file.d.ts +11 -0
- package/bin/impl/write-file.js +9 -0
- package/bin/impl/write-json.d.ts +20 -0
- package/bin/impl/write-json.js +11 -0
- package/bin/mod.d.ts +50 -2
- package/bin/mod.js +158 -2
- package/package.json +6 -8
- package/bin/d.ts.txt +0 -1000
- package/bin/impl/args-impl.d.ts +0 -0
- package/bin/impl/args-impl.js +0 -0
- package/bin/impl/array-polyfill.d.ts +0 -15
- package/bin/impl/external/path-is-inside.d.ts +0 -1
- package/bin/impl/external/path-is-inside.js +0 -16
- package/bin/impl/external/vacuum.d.ts +0 -26
- package/bin/impl/external/vacuum.js +0 -95
- package/bin/impl/fs/dive.d.ts +0 -8
- package/bin/impl/fs/dive.js +0 -91
- package/bin/impl/fs/exists.d.ts +0 -31
- package/bin/impl/fs/exists.js +0 -10
- package/bin/impl/fs/for-each-child.d.ts +0 -34
- package/bin/impl/fs/for-each-child.js +0 -37
- package/bin/impl/fs/index.d.ts +0 -1118
- package/bin/impl/fs/index.js +0 -66
- package/bin/impl/fs/is-directory.d.ts +0 -14
- package/bin/impl/fs/is-directory.js +0 -16
- package/bin/impl/fs/map-children.d.ts +0 -17
- package/bin/impl/fs/map-children.js +0 -31
- package/bin/impl/fs/map-structure.d.ts +0 -35
- package/bin/impl/fs/map-structure.js +0 -44
- package/bin/impl/fs/read-lines.d.ts +0 -16
- package/bin/impl/fs/read-lines.js +0 -32
- package/bin/impl/fs/read-text.d.ts +0 -13
- package/bin/impl/fs/read-text.js +0 -10
- package/bin/impl/fs/universalify.d.ts +0 -18
- package/bin/impl/fs/universalify.js +0 -38
- package/bin/impl/fs/write-file.d.ts +0 -93
- package/bin/impl/fs/write-file.js +0 -47
- package/bin/impl/helpers.d.ts +0 -1
- package/bin/impl/helpers.js +0 -37
- package/bin/impl/json.d.ts +0 -16
- package/bin/impl/json.js +0 -90
- package/bin/impl/lib/copy/copy-sync.d.ts +0 -25
- package/bin/impl/lib/copy/copy-sync.js +0 -119
- package/bin/impl/lib/copy/copy.d.ts +0 -7
- package/bin/impl/lib/copy/copy.js +0 -144
- package/bin/impl/lib/copy/index.d.ts +0 -5
- package/bin/impl/lib/copy/index.js +0 -2
- package/bin/impl/lib/empty/index.d.ts +0 -1
- package/bin/impl/lib/empty/index.js +0 -29
- package/bin/impl/lib/ensure/file.d.ts +0 -2
- package/bin/impl/lib/ensure/file.js +0 -56
- package/bin/impl/lib/ensure/index.d.ts +0 -8
- package/bin/impl/lib/ensure/index.js +0 -12
- package/bin/impl/lib/ensure/link.d.ts +0 -2
- package/bin/impl/lib/ensure/link.js +0 -53
- package/bin/impl/lib/ensure/symlink-paths.d.ts +0 -5
- package/bin/impl/lib/ensure/symlink-paths.js +0 -63
- package/bin/impl/lib/ensure/symlink-type.d.ts +0 -2
- package/bin/impl/lib/ensure/symlink-type.js +0 -23
- package/bin/impl/lib/ensure/symlink.d.ts +0 -2
- package/bin/impl/lib/ensure/symlink.js +0 -59
- package/bin/impl/lib/fs/index.d.ts +0 -1
- package/bin/impl/lib/fs/index.js +0 -1
- package/bin/impl/lib/index.d.ts +0 -15
- package/bin/impl/lib/index.js +0 -34
- package/bin/impl/lib/index_rollup.d.ts +0 -10
- package/bin/impl/lib/index_rollup.js +0 -10
- package/bin/impl/lib/json/index.d.ts +0 -3
- package/bin/impl/lib/json/index.js +0 -10
- package/bin/impl/lib/json/output-json-sync.d.ts +0 -1
- package/bin/impl/lib/json/output-json-sync.js +0 -6
- package/bin/impl/lib/json/output-json.d.ts +0 -1
- package/bin/impl/lib/json/output-json.js +0 -6
- package/bin/impl/lib/mkdirs/index.d.ts +0 -1
- package/bin/impl/lib/mkdirs/index.js +0 -4
- package/bin/impl/lib/mkdirs/make-dir.d.ts +0 -2
- package/bin/impl/lib/mkdirs/make-dir.js +0 -21
- package/bin/impl/lib/mkdirs/utils.d.ts +0 -1
- package/bin/impl/lib/mkdirs/utils.js +0 -13
- package/bin/impl/lib/move/index.d.ts +0 -30
- package/bin/impl/lib/move/index.js +0 -2
- package/bin/impl/lib/move/move-sync.d.ts +0 -8
- package/bin/impl/lib/move/move-sync.js +0 -51
- package/bin/impl/lib/move/move.d.ts +0 -6
- package/bin/impl/lib/move/move.js +0 -48
- package/bin/impl/lib/output-file/index.d.ts +0 -1
- package/bin/impl/lib/output-file/index.js +0 -24
- package/bin/impl/lib/remove/index.d.ts +0 -53
- package/bin/impl/lib/remove/index.js +0 -8
- package/bin/impl/lib/util/stat.d.ts +0 -39
- package/bin/impl/lib/util/stat.js +0 -140
- package/bin/impl/lib/util/utimes.d.ts +0 -7
- package/bin/impl/lib/util/utimes.js +0 -31
- package/bin/impl/subindex.d.ts +0 -43
- package/bin/impl/subindex.js +0 -161
- package/bin/types.d.ts +0 -100
- package/bin/types.js +0 -1
package/bin/d.ts.txt
DELETED
|
@@ -1,1000 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
import * as fs from "fs";
|
|
4
|
-
import * as jsonfile from "jsonfile";
|
|
5
|
-
import { StringifyOptions } from "jsonfile/utils";
|
|
6
|
-
|
|
7
|
-
export * from "fs";
|
|
8
|
-
|
|
9
|
-
// ** ===================================================
|
|
10
|
-
// ** @types/fs-extra -- source -- not used at the moment
|
|
11
|
-
// ** ===================================================
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Copy a file or directory. The directory can have contents.
|
|
15
|
-
*
|
|
16
|
-
* @param src Note that if `src` is a directory it will copy everything inside of this directory,
|
|
17
|
-
* not the entire directory itself (see [issue #537](https://github.com/jprichardson/node-fs-extra/issues/537)).
|
|
18
|
-
* @param dest Note that if `src` is a file, `dest` cannot be a directory
|
|
19
|
-
* (see [issue #323](https://github.com/jprichardson/node-fs-extra/issues/323)).
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* import * as fs from 'fs-extra'
|
|
23
|
-
*
|
|
24
|
-
* // With a callback:
|
|
25
|
-
* fs.copy('/tmp/myfile', '/tmp/mynewfile', err => {
|
|
26
|
-
* if (err) return console.error(err)
|
|
27
|
-
* console.log('success!')
|
|
28
|
-
* }) // copies file
|
|
29
|
-
*
|
|
30
|
-
* fs.copy('/tmp/mydir', '/tmp/mynewdir', err => {
|
|
31
|
-
* if (err) return console.error(err)
|
|
32
|
-
* console.log('success!')
|
|
33
|
-
* }) // copies directory, even if it has subdirectories or files
|
|
34
|
-
*
|
|
35
|
-
* // With Promises:
|
|
36
|
-
* fs.copy('/tmp/myfile', '/tmp/mynewfile')
|
|
37
|
-
* .then(() => {
|
|
38
|
-
* console.log('success!')
|
|
39
|
-
* })
|
|
40
|
-
* .catch(err => {
|
|
41
|
-
* console.error(err)
|
|
42
|
-
* })
|
|
43
|
-
*
|
|
44
|
-
* // With async/await:
|
|
45
|
-
* async function asyncAwait () {
|
|
46
|
-
* try {
|
|
47
|
-
* await fs.copy('/tmp/myfile', '/tmp/mynewfile')
|
|
48
|
-
* console.log('success!')
|
|
49
|
-
* } catch (err) {
|
|
50
|
-
* console.error(err)
|
|
51
|
-
* }
|
|
52
|
-
* }
|
|
53
|
-
*
|
|
54
|
-
* asyncAwait()
|
|
55
|
-
*
|
|
56
|
-
* // Using filter function
|
|
57
|
-
* fs.copy(
|
|
58
|
-
* '/tmp/mydir',
|
|
59
|
-
* '/tmp/mynewdir',
|
|
60
|
-
* {
|
|
61
|
-
* filter(src, dest) {
|
|
62
|
-
* // your logic here
|
|
63
|
-
* // it will be copied if return true
|
|
64
|
-
* }
|
|
65
|
-
* },
|
|
66
|
-
* err => {
|
|
67
|
-
* if (err) return console.error(err)
|
|
68
|
-
* console.log('success!')
|
|
69
|
-
* }
|
|
70
|
-
* )
|
|
71
|
-
*/
|
|
72
|
-
export function copy(src: string, dest: string, options?: CopyOptions): Promise<void>;
|
|
73
|
-
export function copy(src: string, dest: string, callback: NoParamCallbackWithUndefined): void;
|
|
74
|
-
export function copy(src: string, dest: string, options: CopyOptions, callback: NoParamCallbackWithUndefined): void;
|
|
75
|
-
/**
|
|
76
|
-
* Copy a file or directory. The directory can have contents.
|
|
77
|
-
*
|
|
78
|
-
* @param src Note that if `src` is a directory it will copy everything inside of this directory,
|
|
79
|
-
* not the entire directory itself (see [issue #537](https://github.com/jprichardson/node-fs-extra/issues/537)).
|
|
80
|
-
* @param dest Note that if `src` is a file, `dest` cannot be a directory
|
|
81
|
-
* (see [issue #323](https://github.com/jprichardson/node-fs-extra/issues/323)).
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* import * as fs from 'fs-extra'
|
|
85
|
-
*
|
|
86
|
-
* // copy file
|
|
87
|
-
* fs.copySync('/tmp/myfile', '/tmp/mynewfile')
|
|
88
|
-
*
|
|
89
|
-
* // copy directory, even if it has subdirectories or files
|
|
90
|
-
* fs.copySync('/tmp/mydir', '/tmp/mynewdir')
|
|
91
|
-
*
|
|
92
|
-
* // Using filter function
|
|
93
|
-
* fs.copySync('/tmp/mydir', '/tmp/mynewdir', {
|
|
94
|
-
* filter(src, dest) {
|
|
95
|
-
* // your logic here
|
|
96
|
-
* // it will be copied if return true
|
|
97
|
-
* }
|
|
98
|
-
* })
|
|
99
|
-
*/
|
|
100
|
-
export function copySync(src: string, dest: string, options?: CopyOptionsSync): void;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Moves a file or directory, even across devices.
|
|
104
|
-
*
|
|
105
|
-
* @param dest Note: When `src` is a file, `dest` must be a file and when `src` is a directory, `dest` must be a directory.
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* import * as fs from 'fs-extra'
|
|
109
|
-
*
|
|
110
|
-
* const src = '/tmp/file.txt'
|
|
111
|
-
* const dest = '/tmp/this/path/does/not/exist/file.txt'
|
|
112
|
-
*
|
|
113
|
-
* // With a callback:
|
|
114
|
-
* fs.move(src, dest, err => {
|
|
115
|
-
* if (err) return console.error(err)
|
|
116
|
-
* console.log('success!')
|
|
117
|
-
* })
|
|
118
|
-
*
|
|
119
|
-
* // With Promises:
|
|
120
|
-
* fs.move(src, dest)
|
|
121
|
-
* .then(() => {
|
|
122
|
-
* console.log('success!')
|
|
123
|
-
* })
|
|
124
|
-
* .catch(err => {
|
|
125
|
-
* console.error(err)
|
|
126
|
-
* })
|
|
127
|
-
*
|
|
128
|
-
* // With async/await:
|
|
129
|
-
* async function asyncAwait () {
|
|
130
|
-
* try {
|
|
131
|
-
* await fs.move(src, dest)
|
|
132
|
-
* console.log('success!')
|
|
133
|
-
* } catch (err) {
|
|
134
|
-
* console.error(err)
|
|
135
|
-
* }
|
|
136
|
-
* }
|
|
137
|
-
*
|
|
138
|
-
* asyncAwait()
|
|
139
|
-
*
|
|
140
|
-
* // Using `overwrite` option
|
|
141
|
-
* fs.move('/tmp/somedir', '/tmp/may/already/exist/somedir', { overwrite: true }, err => {
|
|
142
|
-
* if (err) return console.error(err)
|
|
143
|
-
* console.log('success!')
|
|
144
|
-
* })
|
|
145
|
-
*/
|
|
146
|
-
export function move(src: string, dest: string, options?: MoveOptions): Promise<void>;
|
|
147
|
-
export function move(src: string, dest: string, callback: NoParamCallbackWithUndefined): void;
|
|
148
|
-
export function move(src: string, dest: string, options: MoveOptions, callback: NoParamCallbackWithUndefined): void;
|
|
149
|
-
/**
|
|
150
|
-
* Moves a file or directory, even across devices.
|
|
151
|
-
*
|
|
152
|
-
* @param dest Note: When `src` is a file, `dest` must be a file and when `src` is a directory, `dest` must be a directory.
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
* import * as fs from 'fs-extra'
|
|
156
|
-
*
|
|
157
|
-
* fs.moveSync('/tmp/somefile', '/tmp/does/not/exist/yet/somefile')
|
|
158
|
-
*
|
|
159
|
-
* // Using `overwrite` option
|
|
160
|
-
* fs.moveSync('/tmp/somedir', '/tmp/may/already/exist/somedir', { overwrite: true })
|
|
161
|
-
*/
|
|
162
|
-
export function moveSync(src: string, dest: string, options?: MoveOptions): void;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Ensures that the file exists. If the file that is requested to be created is in
|
|
166
|
-
* directories that do not exist, these directories are created. If the file already
|
|
167
|
-
* exists, it is **NOT MODIFIED**.
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* import * as fs from 'fs-extra'
|
|
171
|
-
*
|
|
172
|
-
* const file = '/tmp/this/path/does/not/exist/file.txt'
|
|
173
|
-
*
|
|
174
|
-
* // With a callback:
|
|
175
|
-
* fs.ensureFile(file, err => {
|
|
176
|
-
* console.log(err) // => null
|
|
177
|
-
* // file has now been created, including the directory it is to be placed in
|
|
178
|
-
* })
|
|
179
|
-
*
|
|
180
|
-
* // With Promises:
|
|
181
|
-
* fs.ensureFile(file)
|
|
182
|
-
* .then(() => {
|
|
183
|
-
* console.log('success!')
|
|
184
|
-
* })
|
|
185
|
-
* .catch(err => {
|
|
186
|
-
* console.error(err)
|
|
187
|
-
* })
|
|
188
|
-
*
|
|
189
|
-
* // With async/await:
|
|
190
|
-
* async function asyncAwait () {
|
|
191
|
-
* try {
|
|
192
|
-
* await fs.ensureFile(file)
|
|
193
|
-
* console.log('success!')
|
|
194
|
-
* } catch (err) {
|
|
195
|
-
* console.error(err)
|
|
196
|
-
* }
|
|
197
|
-
* }
|
|
198
|
-
*
|
|
199
|
-
* asyncAwait()
|
|
200
|
-
*/
|
|
201
|
-
export function ensureFile(file: string): Promise<void>;
|
|
202
|
-
export function ensureFile(file: string, callback: NoParamCallbackWithUndefined): void;
|
|
203
|
-
/**
|
|
204
|
-
* @see ensureFile
|
|
205
|
-
*/
|
|
206
|
-
export const createFile: typeof ensureFile;
|
|
207
|
-
/**
|
|
208
|
-
* Ensures that the file exists. If the file that is requested to be created is in
|
|
209
|
-
* directories that do not exist, these directories are created. If the file already
|
|
210
|
-
* exists, it is **NOT MODIFIED**.
|
|
211
|
-
*
|
|
212
|
-
* @example
|
|
213
|
-
* import * as fs from 'fs-extra'
|
|
214
|
-
*
|
|
215
|
-
* const file = '/tmp/this/path/does/not/exist/file.txt'
|
|
216
|
-
* fs.ensureFileSync(file)
|
|
217
|
-
* // file has now been created, including the directory it is to be placed in
|
|
218
|
-
*/
|
|
219
|
-
export function ensureFileSync(file: string): void;
|
|
220
|
-
/**
|
|
221
|
-
* @see ensureFileSync
|
|
222
|
-
*/
|
|
223
|
-
export const createFileSync: typeof ensureFileSync;
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Ensures that the link exists. If the directory structure does not exist, it is created.
|
|
227
|
-
*
|
|
228
|
-
* @example
|
|
229
|
-
* import * as fs from 'fs-extra'
|
|
230
|
-
*
|
|
231
|
-
* const srcPath = '/tmp/file.txt'
|
|
232
|
-
* const destPath = '/tmp/this/path/does/not/exist/file.txt'
|
|
233
|
-
*
|
|
234
|
-
* // With a callback:
|
|
235
|
-
* fs.ensureLink(srcPath, destPath, err => {
|
|
236
|
-
* console.log(err) // => null
|
|
237
|
-
* // link has now been created, including the directory it is to be placed in
|
|
238
|
-
* })
|
|
239
|
-
*
|
|
240
|
-
* // With Promises:
|
|
241
|
-
* fs.ensureLink(srcPath, destPath)
|
|
242
|
-
* .then(() => {
|
|
243
|
-
* console.log('success!')
|
|
244
|
-
* })
|
|
245
|
-
* .catch(err => {
|
|
246
|
-
* console.error(err)
|
|
247
|
-
* })
|
|
248
|
-
*
|
|
249
|
-
* // With async/await:
|
|
250
|
-
* async function asyncAwait () {
|
|
251
|
-
* try {
|
|
252
|
-
* await fs.ensureLink(srcPath, destPath)
|
|
253
|
-
* console.log('success!')
|
|
254
|
-
* } catch (err) {
|
|
255
|
-
* console.error(err)
|
|
256
|
-
* }
|
|
257
|
-
* }
|
|
258
|
-
*
|
|
259
|
-
* asyncAwait()
|
|
260
|
-
*/
|
|
261
|
-
export function ensureLink(src: string, dest: string): Promise<void>;
|
|
262
|
-
export function ensureLink(src: string, dest: string, callback: fs.NoParamCallback): void;
|
|
263
|
-
/**
|
|
264
|
-
* @see ensureLink
|
|
265
|
-
*/
|
|
266
|
-
export const createLink: typeof ensureLink;
|
|
267
|
-
/**
|
|
268
|
-
* Ensures that the link exists. If the directory structure does not exist, it is created.
|
|
269
|
-
*
|
|
270
|
-
* @example
|
|
271
|
-
* import * as fs from 'fs-extra'
|
|
272
|
-
*
|
|
273
|
-
* const srcPath = '/tmp/file.txt'
|
|
274
|
-
* const destPath = '/tmp/this/path/does/not/exist/file.txt'
|
|
275
|
-
* fs.ensureLinkSync(srcPath, destPath)
|
|
276
|
-
* // link has now been created, including the directory it is to be placed in
|
|
277
|
-
*/
|
|
278
|
-
export function ensureLinkSync(src: string, dest: string): void;
|
|
279
|
-
/**
|
|
280
|
-
* @see ensureLinkSync
|
|
281
|
-
*/
|
|
282
|
-
export const createLinkSync: typeof ensureLinkSync;
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Ensures that the symlink exists. If the directory structure does not exist, it is created.
|
|
286
|
-
*
|
|
287
|
-
* @param type It is only available on Windows and ignored on other platforms.
|
|
288
|
-
*
|
|
289
|
-
* @example
|
|
290
|
-
* import * as fs from 'fs-extra'
|
|
291
|
-
*
|
|
292
|
-
* const srcPath = '/tmp/file.txt'
|
|
293
|
-
* const destPath = '/tmp/this/path/does/not/exist/file.txt'
|
|
294
|
-
*
|
|
295
|
-
* // With a callback:
|
|
296
|
-
* fs.ensureSymlink(srcPath, destPath, err => {
|
|
297
|
-
* console.log(err) // => null
|
|
298
|
-
* // symlink has now been created, including the directory it is to be placed in
|
|
299
|
-
* })
|
|
300
|
-
*
|
|
301
|
-
* // With Promises:
|
|
302
|
-
* fs.ensureSymlink(srcPath, destPath)
|
|
303
|
-
* .then(() => {
|
|
304
|
-
* console.log('success!')
|
|
305
|
-
* })
|
|
306
|
-
* .catch(err => {
|
|
307
|
-
* console.error(err)
|
|
308
|
-
* })
|
|
309
|
-
*
|
|
310
|
-
* // With async/await:
|
|
311
|
-
* async function asyncAwait () {
|
|
312
|
-
* try {
|
|
313
|
-
* await fs.ensureSymlink(srcPath, destPath)
|
|
314
|
-
* console.log('success!')
|
|
315
|
-
* } catch (err) {
|
|
316
|
-
* console.error(err)
|
|
317
|
-
* }
|
|
318
|
-
* }
|
|
319
|
-
*
|
|
320
|
-
* asyncAwait()
|
|
321
|
-
*/
|
|
322
|
-
export function ensureSymlink(src: string, dest: string, type?: SymlinkType): Promise<void>;
|
|
323
|
-
export function ensureSymlink(src: string, dest: string, callback: fs.NoParamCallback): void;
|
|
324
|
-
export function ensureSymlink(src: string, dest: string, type: SymlinkType, callback: fs.NoParamCallback): void;
|
|
325
|
-
/**
|
|
326
|
-
* @see ensureSymlink
|
|
327
|
-
*/
|
|
328
|
-
export const createSymlink: typeof ensureSymlink;
|
|
329
|
-
/**
|
|
330
|
-
* Ensures that the symlink exists. If the directory structure does not exist, it is created.
|
|
331
|
-
*
|
|
332
|
-
* @param type It is only available on Windows and ignored on other platforms.
|
|
333
|
-
*
|
|
334
|
-
* @example
|
|
335
|
-
* import * as fs from 'fs-extra'
|
|
336
|
-
*
|
|
337
|
-
* const srcPath = '/tmp/file.txt'
|
|
338
|
-
* const destPath = '/tmp/this/path/does/not/exist/file.txt'
|
|
339
|
-
* fs.ensureSymlinkSync(srcPath, destPath)
|
|
340
|
-
* // symlink has now been created, including the directory it is to be placed in
|
|
341
|
-
*/
|
|
342
|
-
export function ensureSymlinkSync(src: string, dest: string, type?: SymlinkType): void;
|
|
343
|
-
/**
|
|
344
|
-
* @see ensureSymlinkSync
|
|
345
|
-
*/
|
|
346
|
-
export const createSymlinkSync: typeof ensureSymlinkSync;
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Ensures that the directory exists. If the directory structure does not exist, it is created.
|
|
350
|
-
*
|
|
351
|
-
* @example
|
|
352
|
-
* import * as fs from 'fs-extra'
|
|
353
|
-
*
|
|
354
|
-
* const dir = '/tmp/this/path/does/not/exist'
|
|
355
|
-
* const desiredMode = 0o2775
|
|
356
|
-
* const options = {
|
|
357
|
-
* mode: 0o2775
|
|
358
|
-
* }
|
|
359
|
-
*
|
|
360
|
-
* // With a callback:
|
|
361
|
-
* fs.ensureDir(dir, err => {
|
|
362
|
-
* console.log(err) // => null
|
|
363
|
-
* // dir has now been created, including the directory it is to be placed in
|
|
364
|
-
* })
|
|
365
|
-
*
|
|
366
|
-
* // With a callback and a mode integer
|
|
367
|
-
* fs.ensureDir(dir, desiredMode, err => {
|
|
368
|
-
* console.log(err) // => null
|
|
369
|
-
* // dir has now been created with mode 0o2775, including the directory it is to be placed in
|
|
370
|
-
* })
|
|
371
|
-
*
|
|
372
|
-
* // With Promises:
|
|
373
|
-
* fs.ensureDir(dir)
|
|
374
|
-
* .then(() => {
|
|
375
|
-
* console.log('success!')
|
|
376
|
-
* })
|
|
377
|
-
* .catch(err => {
|
|
378
|
-
* console.error(err)
|
|
379
|
-
* })
|
|
380
|
-
*
|
|
381
|
-
* // With Promises and a mode integer:
|
|
382
|
-
* fs.ensureDir(dir, desiredMode)
|
|
383
|
-
* .then(() => {
|
|
384
|
-
* console.log('success!')
|
|
385
|
-
* })
|
|
386
|
-
* .catch(err => {
|
|
387
|
-
* console.error(err)
|
|
388
|
-
* })
|
|
389
|
-
*
|
|
390
|
-
* // With async/await:
|
|
391
|
-
* async function asyncAwait () {
|
|
392
|
-
* try {
|
|
393
|
-
* await fs.ensureDir(dir)
|
|
394
|
-
* console.log('success!')
|
|
395
|
-
* } catch (err) {
|
|
396
|
-
* console.error(err)
|
|
397
|
-
* }
|
|
398
|
-
* }
|
|
399
|
-
* asyncAwait()
|
|
400
|
-
*
|
|
401
|
-
* // With async/await and an options object, containing mode:
|
|
402
|
-
* async function asyncAwaitMode () {
|
|
403
|
-
* try {
|
|
404
|
-
* await fs.ensureDir(dir, options)
|
|
405
|
-
* console.log('success!')
|
|
406
|
-
* } catch (err) {
|
|
407
|
-
* console.error(err)
|
|
408
|
-
* }
|
|
409
|
-
* }
|
|
410
|
-
* asyncAwaitMode()
|
|
411
|
-
*/
|
|
412
|
-
export function ensureDir(path: string, options?: EnsureDirOptions | number): Promise<void>;
|
|
413
|
-
export function ensureDir(path: string, callback: fs.NoParamCallback): void;
|
|
414
|
-
export function ensureDir(path: string, options: EnsureDirOptions | number, callback: fs.NoParamCallback): void;
|
|
415
|
-
/**
|
|
416
|
-
* Ensures that the directory exists. If the directory structure does not exist, it is created.
|
|
417
|
-
* If provided, options may specify the desired mode for the directory.
|
|
418
|
-
*
|
|
419
|
-
* @example
|
|
420
|
-
* import * as fs from 'fs-extra'
|
|
421
|
-
*
|
|
422
|
-
* const dir = '/tmp/this/path/does/not/exist'
|
|
423
|
-
*
|
|
424
|
-
* const desiredMode = 0o2775
|
|
425
|
-
* const options = {
|
|
426
|
-
* mode: 0o2775
|
|
427
|
-
* }
|
|
428
|
-
*
|
|
429
|
-
* fs.ensureDirSync(dir)
|
|
430
|
-
* // dir has now been created, including the directory it is to be placed in
|
|
431
|
-
*
|
|
432
|
-
* fs.ensureDirSync(dir, desiredMode)
|
|
433
|
-
* // dir has now been created, including the directory it is to be placed in with permission 0o2775
|
|
434
|
-
*
|
|
435
|
-
* fs.ensureDirSync(dir, options)
|
|
436
|
-
* // dir has now been created, including the directory it is to be placed in with permission 0o2775
|
|
437
|
-
*/
|
|
438
|
-
export function ensureDirSync(path: string, options?: EnsureDirOptions | number): void;
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* @see ensureDir
|
|
442
|
-
*/
|
|
443
|
-
export const mkdirs: typeof ensureDir;
|
|
444
|
-
/**
|
|
445
|
-
* @see ensureDirSync
|
|
446
|
-
*/
|
|
447
|
-
export const mkdirsSync: typeof ensureDirSync;
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
* @see ensureDir
|
|
451
|
-
*/
|
|
452
|
-
export const mkdirp: typeof ensureDir;
|
|
453
|
-
/**
|
|
454
|
-
* @see ensureDirSync
|
|
455
|
-
*/
|
|
456
|
-
export const mkdirpSync: typeof ensureDirSync;
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* Almost the same as `writeFile` (i.e. it overwrites), except that if the parent directory
|
|
460
|
-
* does not exist, it's created.
|
|
461
|
-
*
|
|
462
|
-
* @example
|
|
463
|
-
* import * as fs from 'fs-extra'
|
|
464
|
-
*
|
|
465
|
-
* const file = '/tmp/this/path/does/not/exist/file.txt'
|
|
466
|
-
*
|
|
467
|
-
* // With a callback:
|
|
468
|
-
* fs.outputFile(file, 'hello!', err => {
|
|
469
|
-
* console.log(err) // => null
|
|
470
|
-
*
|
|
471
|
-
* fs.readFile(file, 'utf8', (err, data) => {
|
|
472
|
-
* if (err) return console.error(err)
|
|
473
|
-
* console.log(data) // => hello!
|
|
474
|
-
* })
|
|
475
|
-
* })
|
|
476
|
-
*
|
|
477
|
-
* // With Promises:
|
|
478
|
-
* fs.outputFile(file, 'hello!')
|
|
479
|
-
* .then(() => fs.readFile(file, 'utf8'))
|
|
480
|
-
* .then(data => {
|
|
481
|
-
* console.log(data) // => hello!
|
|
482
|
-
* })
|
|
483
|
-
* .catch(err => {
|
|
484
|
-
* console.error(err)
|
|
485
|
-
* })
|
|
486
|
-
*
|
|
487
|
-
* // With async/await:
|
|
488
|
-
* async function asyncAwait () {
|
|
489
|
-
* try {
|
|
490
|
-
* await fs.outputFile(file, 'hello!')
|
|
491
|
-
*
|
|
492
|
-
* const data = await fs.readFile(file, 'utf8')
|
|
493
|
-
*
|
|
494
|
-
* console.log(data) // => hello!
|
|
495
|
-
* } catch (err) {
|
|
496
|
-
* console.error(err)
|
|
497
|
-
* }
|
|
498
|
-
* }
|
|
499
|
-
*
|
|
500
|
-
* asyncAwait()
|
|
501
|
-
*/
|
|
502
|
-
export function outputFile(
|
|
503
|
-
file: string,
|
|
504
|
-
data: string | NodeJS.ArrayBufferView,
|
|
505
|
-
options?: fs.WriteFileOptions,
|
|
506
|
-
): Promise<void>;
|
|
507
|
-
export function outputFile(file: string, data: string | NodeJS.ArrayBufferView, callback: fs.NoParamCallback): void;
|
|
508
|
-
export function outputFile(
|
|
509
|
-
file: string,
|
|
510
|
-
data: string | NodeJS.ArrayBufferView,
|
|
511
|
-
options: fs.WriteFileOptions,
|
|
512
|
-
callback: fs.NoParamCallback,
|
|
513
|
-
): void;
|
|
514
|
-
/**
|
|
515
|
-
* Almost the same as `writeFileSync` (i.e. it overwrites), except that if the parent directory
|
|
516
|
-
* does not exist, it's created.
|
|
517
|
-
*
|
|
518
|
-
* @example
|
|
519
|
-
* import * as fs from 'fs-extra'
|
|
520
|
-
*
|
|
521
|
-
* const file = '/tmp/this/path/does/not/exist/file.txt'
|
|
522
|
-
* fs.outputFileSync(file, 'hello!')
|
|
523
|
-
*
|
|
524
|
-
* const data = fs.readFileSync(file, 'utf8')
|
|
525
|
-
* console.log(data) // => hello!
|
|
526
|
-
*/
|
|
527
|
-
export function outputFileSync(
|
|
528
|
-
file: string,
|
|
529
|
-
data: string | NodeJS.ArrayBufferView,
|
|
530
|
-
options?: fs.WriteFileOptions,
|
|
531
|
-
): void;
|
|
532
|
-
|
|
533
|
-
/**
|
|
534
|
-
* Reads a JSON file and then parses it into an object.
|
|
535
|
-
*
|
|
536
|
-
* @example
|
|
537
|
-
* import * as fs from 'fs-extra'
|
|
538
|
-
*
|
|
539
|
-
* // With a callback:
|
|
540
|
-
* fs.readJson('./package.json', (err, packageObj) => {
|
|
541
|
-
* if (err) console.error(err)
|
|
542
|
-
* console.log(packageObj.version) // => 0.1.3
|
|
543
|
-
* })
|
|
544
|
-
*
|
|
545
|
-
* // With Promises:
|
|
546
|
-
* fs.readJson('./package.json')
|
|
547
|
-
* .then(packageObj => {
|
|
548
|
-
* console.log(packageObj.version) // => 0.1.3
|
|
549
|
-
* })
|
|
550
|
-
* .catch(err => {
|
|
551
|
-
* console.error(err)
|
|
552
|
-
* })
|
|
553
|
-
*
|
|
554
|
-
* // With async/await:
|
|
555
|
-
* async function asyncAwait () {
|
|
556
|
-
* try {
|
|
557
|
-
* const packageObj = await fs.readJson('./package.json')
|
|
558
|
-
* console.log(packageObj.version) // => 0.1.3
|
|
559
|
-
* } catch (err) {
|
|
560
|
-
* console.error(err)
|
|
561
|
-
* }
|
|
562
|
-
* }
|
|
563
|
-
*
|
|
564
|
-
* asyncAwait()
|
|
565
|
-
*
|
|
566
|
-
* // `readJsonSync()` can take a `throws` option set to `false` and it won't throw if the JSON is invalid. Example:
|
|
567
|
-
* const file = '/tmp/some-invalid.json'
|
|
568
|
-
* const data = '{not valid JSON'
|
|
569
|
-
* fs.writeFileSync(file, data)
|
|
570
|
-
*
|
|
571
|
-
* // With a callback:
|
|
572
|
-
* fs.readJson(file, { throws: false }, (err, obj) => {
|
|
573
|
-
* if (err) console.error(err)
|
|
574
|
-
* console.log(obj) // => null
|
|
575
|
-
* })
|
|
576
|
-
*
|
|
577
|
-
* // With Promises:
|
|
578
|
-
* fs.readJson(file, { throws: false })
|
|
579
|
-
* .then(obj => {
|
|
580
|
-
* console.log(obj) // => null
|
|
581
|
-
* })
|
|
582
|
-
* .catch(err => {
|
|
583
|
-
* console.error(err) // Not called
|
|
584
|
-
* })
|
|
585
|
-
*
|
|
586
|
-
* // With async/await:
|
|
587
|
-
* async function asyncAwaitThrows () {
|
|
588
|
-
* const obj = await fs.readJson(file, { throws: false })
|
|
589
|
-
* console.log(obj) // => null
|
|
590
|
-
* }
|
|
591
|
-
*
|
|
592
|
-
* asyncAwaitThrows()
|
|
593
|
-
*/
|
|
594
|
-
export const readJson: typeof jsonfile.readFile;
|
|
595
|
-
/**
|
|
596
|
-
* @see readJson
|
|
597
|
-
*/
|
|
598
|
-
export const readJSON: typeof jsonfile.readFile;
|
|
599
|
-
/**
|
|
600
|
-
* Reads a JSON file and then parses it into an object.
|
|
601
|
-
*
|
|
602
|
-
* @example
|
|
603
|
-
* import * as fs from 'fs-extra'
|
|
604
|
-
*
|
|
605
|
-
* const packageObj = fs.readJsonSync('./package.json')
|
|
606
|
-
* console.log(packageObj.version) // => 2.0.0
|
|
607
|
-
*
|
|
608
|
-
* // `readJsonSync()` can take a `throws` option set to `false` and it won't throw if the JSON is invalid. Example:
|
|
609
|
-
* const file = '/tmp/some-invalid.json'
|
|
610
|
-
* const data = '{not valid JSON'
|
|
611
|
-
* fs.writeFileSync(file, data)
|
|
612
|
-
*
|
|
613
|
-
* const obj = fs.readJsonSync(file, { throws: false })
|
|
614
|
-
* console.log(obj) // => null
|
|
615
|
-
*/
|
|
616
|
-
export const readJsonSync: typeof jsonfile.readFileSync;
|
|
617
|
-
/**
|
|
618
|
-
* @see readJsonSync
|
|
619
|
-
*/
|
|
620
|
-
export const readJSONSync: typeof jsonfile.readFileSync;
|
|
621
|
-
|
|
622
|
-
/**
|
|
623
|
-
* Writes an object to a JSON file.
|
|
624
|
-
*
|
|
625
|
-
* @example
|
|
626
|
-
* import * as fs from 'fs-extra'
|
|
627
|
-
*
|
|
628
|
-
* // With a callback:
|
|
629
|
-
* fs.writeJson('./package.json', {name: 'fs-extra'}, err => {
|
|
630
|
-
* if (err) return console.error(err)
|
|
631
|
-
* console.log('success!')
|
|
632
|
-
* })
|
|
633
|
-
*
|
|
634
|
-
* // With Promises:
|
|
635
|
-
* fs.writeJson('./package.json', {name: 'fs-extra'})
|
|
636
|
-
* .then(() => {
|
|
637
|
-
* console.log('success!')
|
|
638
|
-
* })
|
|
639
|
-
* .catch(err => {
|
|
640
|
-
* console.error(err)
|
|
641
|
-
* })
|
|
642
|
-
*
|
|
643
|
-
* // With async/await:
|
|
644
|
-
* async function asyncAwait () {
|
|
645
|
-
* try {
|
|
646
|
-
* await fs.writeJson('./package.json', {name: 'fs-extra'})
|
|
647
|
-
* console.log('success!')
|
|
648
|
-
* } catch (err) {
|
|
649
|
-
* console.error(err)
|
|
650
|
-
* }
|
|
651
|
-
* }
|
|
652
|
-
*
|
|
653
|
-
* asyncAwait()
|
|
654
|
-
*/
|
|
655
|
-
export const writeJson: typeof jsonfile.writeFile;
|
|
656
|
-
/**
|
|
657
|
-
* @see writeJson
|
|
658
|
-
*/
|
|
659
|
-
export const writeJSON: typeof jsonfile.writeFile;
|
|
660
|
-
/**
|
|
661
|
-
* Writes an object to a JSON file.
|
|
662
|
-
*
|
|
663
|
-
* @example
|
|
664
|
-
* import * as fs from 'fs-extra'
|
|
665
|
-
*
|
|
666
|
-
* fs.writeJsonSync('./package.json', {name: 'fs-extra'})
|
|
667
|
-
*/
|
|
668
|
-
export const writeJsonSync: typeof jsonfile.writeFileSync;
|
|
669
|
-
/**
|
|
670
|
-
* @see writeJsonSync
|
|
671
|
-
*/
|
|
672
|
-
export const writeJSONSync: typeof jsonfile.writeFileSync;
|
|
673
|
-
|
|
674
|
-
/**
|
|
675
|
-
* Almost the same as `writeJson`, except that if the directory does not exist, it's created.
|
|
676
|
-
*
|
|
677
|
-
* @example
|
|
678
|
-
* import * as fs from 'fs-extra'
|
|
679
|
-
*
|
|
680
|
-
* const file = '/tmp/this/path/does/not/exist/file.json'
|
|
681
|
-
*
|
|
682
|
-
* // With a callback:
|
|
683
|
-
* fs.outputJson(file, {name: 'JP'}, err => {
|
|
684
|
-
* console.log(err) // => null
|
|
685
|
-
*
|
|
686
|
-
* fs.readJson(file, (err, data) => {
|
|
687
|
-
* if (err) return console.error(err)
|
|
688
|
-
* console.log(data.name) // => JP
|
|
689
|
-
* })
|
|
690
|
-
* })
|
|
691
|
-
*
|
|
692
|
-
* // With Promises:
|
|
693
|
-
* fs.outputJson(file, {name: 'JP'})
|
|
694
|
-
* .then(() => fs.readJson(file))
|
|
695
|
-
* .then(data => {
|
|
696
|
-
* console.log(data.name) // => JP
|
|
697
|
-
* })
|
|
698
|
-
* .catch(err => {
|
|
699
|
-
* console.error(err)
|
|
700
|
-
* })
|
|
701
|
-
*
|
|
702
|
-
* // With async/await:
|
|
703
|
-
* async function asyncAwait () {
|
|
704
|
-
* try {
|
|
705
|
-
* await fs.outputJson(file, {name: 'JP'})
|
|
706
|
-
*
|
|
707
|
-
* const data = await fs.readJson(file)
|
|
708
|
-
*
|
|
709
|
-
* console.log(data.name) // => JP
|
|
710
|
-
* } catch (err) {
|
|
711
|
-
* console.error(err)
|
|
712
|
-
* }
|
|
713
|
-
* }
|
|
714
|
-
*
|
|
715
|
-
* asyncAwait()
|
|
716
|
-
*/
|
|
717
|
-
export function outputJson(file: string, data: any, options?: JsonOutputOptions): Promise<void>;
|
|
718
|
-
export function outputJson(file: string, data: any, options: JsonOutputOptions, callback: fs.NoParamCallback): void;
|
|
719
|
-
export function outputJson(file: string, data: any, callback: fs.NoParamCallback): void;
|
|
720
|
-
/**
|
|
721
|
-
* @see outputJson
|
|
722
|
-
*/
|
|
723
|
-
export const outputJSON: typeof outputJson;
|
|
724
|
-
/**
|
|
725
|
-
* Almost the same as `writeJsonSync`, except that if the directory does not exist, it's created.
|
|
726
|
-
*
|
|
727
|
-
* @example
|
|
728
|
-
* import * as fs from 'fs-extra'
|
|
729
|
-
*
|
|
730
|
-
* const file = '/tmp/this/path/does/not/exist/file.json'
|
|
731
|
-
* fs.outputJsonSync(file, {name: 'JP'})
|
|
732
|
-
*
|
|
733
|
-
* const data = fs.readJsonSync(file)
|
|
734
|
-
* console.log(data.name) // => JP
|
|
735
|
-
*/
|
|
736
|
-
export function outputJsonSync(file: string, data: any, options?: JsonOutputOptions): void;
|
|
737
|
-
/**
|
|
738
|
-
* @see outputJsonSync
|
|
739
|
-
*/
|
|
740
|
-
export const outputJSONSync: typeof outputJsonSync;
|
|
741
|
-
|
|
742
|
-
/**
|
|
743
|
-
* Removes a file or directory. The directory can have contents. If the path does not exist, silently does nothing.
|
|
744
|
-
*
|
|
745
|
-
* @example
|
|
746
|
-
* import * as fs from 'fs-extra'
|
|
747
|
-
*
|
|
748
|
-
* // remove file
|
|
749
|
-
* // With a callback:
|
|
750
|
-
* fs.remove('/tmp/myfile', err => {
|
|
751
|
-
* if (err) return console.error(err)
|
|
752
|
-
* console.log('success!')
|
|
753
|
-
* })
|
|
754
|
-
*
|
|
755
|
-
* fs.remove('/home/jprichardson', err => {
|
|
756
|
-
* if (err) return console.error(err)
|
|
757
|
-
* console.log('success!') // I just deleted my entire HOME directory.
|
|
758
|
-
* })
|
|
759
|
-
*
|
|
760
|
-
* // With Promises:
|
|
761
|
-
* fs.remove('/tmp/myfile')
|
|
762
|
-
* .then(() => {
|
|
763
|
-
* console.log('success!')
|
|
764
|
-
* })
|
|
765
|
-
* .catch(err => {
|
|
766
|
-
* console.error(err)
|
|
767
|
-
* })
|
|
768
|
-
*
|
|
769
|
-
* // With async/await:
|
|
770
|
-
* async function asyncAwait () {
|
|
771
|
-
* try {
|
|
772
|
-
* await fs.remove('/tmp/myfile')
|
|
773
|
-
* console.log('success!')
|
|
774
|
-
* } catch (err) {
|
|
775
|
-
* console.error(err)
|
|
776
|
-
* }
|
|
777
|
-
* }
|
|
778
|
-
*
|
|
779
|
-
* asyncAwait()
|
|
780
|
-
*/
|
|
781
|
-
export function remove(dir: string): Promise<void>;
|
|
782
|
-
export function remove(dir: string, callback: fs.NoParamCallback): void;
|
|
783
|
-
/**
|
|
784
|
-
* Removes a file or directory. The directory can have contents. If the path does not exist, silently does nothing.
|
|
785
|
-
*
|
|
786
|
-
* @example
|
|
787
|
-
* import * as fs from 'fs-extra'
|
|
788
|
-
*
|
|
789
|
-
* // remove file
|
|
790
|
-
* fs.removeSync('/tmp/myfile')
|
|
791
|
-
*
|
|
792
|
-
* fs.removeSync('/home/jprichardson') // I just deleted my entire HOME directory.
|
|
793
|
-
*/
|
|
794
|
-
export function removeSync(dir: string): void;
|
|
795
|
-
|
|
796
|
-
/**
|
|
797
|
-
* Ensures that a directory is empty. Deletes directory contents if the directory is not empty.
|
|
798
|
-
* If the directory does not exist, it is created. The directory itself is not deleted.
|
|
799
|
-
*
|
|
800
|
-
* @example
|
|
801
|
-
* import * as fs from 'fs-extra'
|
|
802
|
-
*
|
|
803
|
-
* // assume this directory has a lot of files and folders
|
|
804
|
-
* // With a callback:
|
|
805
|
-
* fs.emptyDir('/tmp/some/dir', err => {
|
|
806
|
-
* if (err) return console.error(err)
|
|
807
|
-
* console.log('success!')
|
|
808
|
-
* })
|
|
809
|
-
*
|
|
810
|
-
* // With Promises:
|
|
811
|
-
* fs.emptyDir('/tmp/some/dir')
|
|
812
|
-
* .then(() => {
|
|
813
|
-
* console.log('success!')
|
|
814
|
-
* })
|
|
815
|
-
* .catch(err => {
|
|
816
|
-
* console.error(err)
|
|
817
|
-
* })
|
|
818
|
-
*
|
|
819
|
-
* // With async/await:
|
|
820
|
-
* async function asyncAwait () {
|
|
821
|
-
* try {
|
|
822
|
-
* await fs.emptyDir('/tmp/some/dir')
|
|
823
|
-
* console.log('success!')
|
|
824
|
-
* } catch (err) {
|
|
825
|
-
* console.error(err)
|
|
826
|
-
* }
|
|
827
|
-
* }
|
|
828
|
-
*
|
|
829
|
-
* asyncAwait()
|
|
830
|
-
*/
|
|
831
|
-
export function emptyDir(path: string): Promise<void>;
|
|
832
|
-
export function emptyDir(path: string, callback: fs.NoParamCallback): void;
|
|
833
|
-
/**
|
|
834
|
-
* @see emptyDir
|
|
835
|
-
*/
|
|
836
|
-
export const emptydir: typeof emptyDir;
|
|
837
|
-
/**
|
|
838
|
-
* Ensures that a directory is empty. Deletes directory contents if the directory is not empty.
|
|
839
|
-
* If the directory does not exist, it is created. The directory itself is not deleted.
|
|
840
|
-
*
|
|
841
|
-
* @example
|
|
842
|
-
* import * as fs from 'fs-extra'
|
|
843
|
-
*
|
|
844
|
-
* // assume this directory has a lot of files and folders
|
|
845
|
-
* fs.emptyDirSync('/tmp/some/dir')
|
|
846
|
-
*/
|
|
847
|
-
export function emptyDirSync(path: string): void;
|
|
848
|
-
/**
|
|
849
|
-
* @see emptyDirSync
|
|
850
|
-
*/
|
|
851
|
-
export const emptydirSync: typeof emptyDirSync;
|
|
852
|
-
|
|
853
|
-
/**
|
|
854
|
-
* Test whether or not the given path exists by checking with the file system. Like
|
|
855
|
-
* [`fs.exists`](https://nodejs.org/api/fs.html#fs_fs_exists_path_callback), but with a normal
|
|
856
|
-
* callback signature (err, exists). Uses `fs.access` under the hood.
|
|
857
|
-
*
|
|
858
|
-
* @example
|
|
859
|
-
* import * as fs from 'fs-extra'
|
|
860
|
-
*
|
|
861
|
-
* const file = '/tmp/this/path/does/not/exist/file.txt'
|
|
862
|
-
*
|
|
863
|
-
* // With a callback:
|
|
864
|
-
* fs.pathExists(file, (err, exists) => {
|
|
865
|
-
* console.log(err) // => null
|
|
866
|
-
* console.log(exists) // => false
|
|
867
|
-
* })
|
|
868
|
-
*
|
|
869
|
-
* // Promise usage:
|
|
870
|
-
* fs.pathExists(file)
|
|
871
|
-
* .then(exists => console.log(exists)) // => false
|
|
872
|
-
*
|
|
873
|
-
* // With async/await:
|
|
874
|
-
* async function asyncAwait () {
|
|
875
|
-
* const exists = await fs.pathExists(file)
|
|
876
|
-
*
|
|
877
|
-
* console.log(exists) // => false
|
|
878
|
-
* }
|
|
879
|
-
*
|
|
880
|
-
* asyncAwait()
|
|
881
|
-
*/
|
|
882
|
-
export function pathExists(path: string): Promise<boolean>;
|
|
883
|
-
export function pathExists(path: string, callback: (err: NodeJS.ErrnoException | null, exists: boolean) => void): void;
|
|
884
|
-
/**
|
|
885
|
-
* An alias for [`fs.existsSync`](https://nodejs.org/api/fs.html#fs_fs_existssync_path), created for
|
|
886
|
-
* consistency with `pathExists`.
|
|
887
|
-
*/
|
|
888
|
-
export function pathExistsSync(path: string): boolean;
|
|
889
|
-
|
|
890
|
-
export const access: typeof fs.access.__promisify__ & typeof fs.access;
|
|
891
|
-
export const appendFile: typeof fs.appendFile.__promisify__ & typeof fs.appendFile;
|
|
892
|
-
export const chmod: typeof fs.chmod.__promisify__ & typeof fs.chmod;
|
|
893
|
-
export const chown: typeof fs.chown.__promisify__ & typeof fs.chown;
|
|
894
|
-
export const close: typeof fs.close.__promisify__ & typeof fs.close;
|
|
895
|
-
export const copyFile: typeof fs.copyFile.__promisify__ & typeof fs.copyFile;
|
|
896
|
-
export const exists: typeof fs.exists.__promisify__ & typeof fs.exists;
|
|
897
|
-
export const fchmod: typeof fs.fchmod.__promisify__ & typeof fs.fchmod;
|
|
898
|
-
export const fchown: typeof fs.fchown.__promisify__ & typeof fs.fchown;
|
|
899
|
-
export const fdatasync: typeof fs.fdatasync.__promisify__ & typeof fs.fdatasync;
|
|
900
|
-
export const fstat: typeof fs.fstat.__promisify__ & typeof fs.fstat;
|
|
901
|
-
export const fsync: typeof fs.fsync.__promisify__ & typeof fs.fsync;
|
|
902
|
-
export const ftruncate: typeof fs.ftruncate.__promisify__ & typeof fs.ftruncate;
|
|
903
|
-
export const futimes: typeof fs.futimes.__promisify__ & typeof fs.futimes;
|
|
904
|
-
export const lchmod: typeof fs.lchmod.__promisify__ & typeof fs.lchmod;
|
|
905
|
-
export const lchown: typeof fs.lchown.__promisify__ & typeof fs.lchown;
|
|
906
|
-
export const link: typeof fs.link.__promisify__ & typeof fs.link;
|
|
907
|
-
export const lstat: typeof fs.lstat.__promisify__ & typeof fs.lstat;
|
|
908
|
-
export const mkdir: typeof fs.mkdir.__promisify__ & typeof fs.mkdir;
|
|
909
|
-
export const mkdtemp: typeof fs.mkdtemp.__promisify__ & typeof fs.mkdtemp;
|
|
910
|
-
export const open: typeof fs.open.__promisify__ & typeof fs.open;
|
|
911
|
-
export const opendir: typeof fs.opendir.__promisify__ & typeof fs.opendir;
|
|
912
|
-
export const read: typeof fs.read.__promisify__ & typeof fs.read;
|
|
913
|
-
export const readv: typeof fs.readv.__promisify__ & typeof fs.readv;
|
|
914
|
-
export const readdir: typeof fs.readdir.__promisify__ & typeof fs.readdir;
|
|
915
|
-
export const readFile: typeof fs.readFile.__promisify__ & typeof fs.readFile;
|
|
916
|
-
export const readlink: typeof fs.readlink.__promisify__ & typeof fs.readlink;
|
|
917
|
-
export const realpath:
|
|
918
|
-
& typeof fs.realpath.__promisify__
|
|
919
|
-
& typeof fs.realpath
|
|
920
|
-
& {
|
|
921
|
-
native(path: fs.PathLike, options?: fs.EncodingOption): Promise<string>;
|
|
922
|
-
native(path: fs.PathLike, options: fs.BufferEncodingOption): Promise<Buffer>;
|
|
923
|
-
};
|
|
924
|
-
export const rename: typeof fs.rename.__promisify__ & typeof fs.rename;
|
|
925
|
-
export const rm: typeof fs.rm.__promisify__ & typeof fs.rm;
|
|
926
|
-
export const rmdir: typeof fs.rmdir.__promisify__ & typeof fs.rmdir;
|
|
927
|
-
export const stat: typeof fs.stat.__promisify__ & typeof fs.stat;
|
|
928
|
-
export const symlink: typeof fs.symlink.__promisify__ & typeof fs.symlink;
|
|
929
|
-
export const truncate: typeof fs.truncate.__promisify__ & typeof fs.truncate;
|
|
930
|
-
export const unlink: typeof fs.unlink.__promisify__ & typeof fs.unlink;
|
|
931
|
-
export const utimes: typeof fs.utimes.__promisify__ & typeof fs.utimes;
|
|
932
|
-
export const write: typeof fs.write.__promisify__ & typeof fs.write;
|
|
933
|
-
export const writev: typeof fs.writev.__promisify__ & typeof fs.writev;
|
|
934
|
-
export const writeFile: typeof fs.writeFile.__promisify__ & typeof fs.writeFile;
|
|
935
|
-
|
|
936
|
-
export type NoParamCallbackWithUndefined = (err: NodeJS.ErrnoException | null | undefined) => void;
|
|
937
|
-
|
|
938
|
-
export type SymlinkType = fs.symlink.Type;
|
|
939
|
-
|
|
940
|
-
export type CopyFilterSync = (src: string, dest: string) => boolean;
|
|
941
|
-
export type CopyFilterAsync = (src: string, dest: string) => Promise<boolean>;
|
|
942
|
-
|
|
943
|
-
export interface CopyOptions {
|
|
944
|
-
/**
|
|
945
|
-
* Dereference symlinks.
|
|
946
|
-
* @default false
|
|
947
|
-
*/
|
|
948
|
-
dereference?: boolean | undefined;
|
|
949
|
-
/**
|
|
950
|
-
* Overwrite existing file or directory.
|
|
951
|
-
* _Note that the copy operation will silently fail if you set this to `false` and the destination exists._
|
|
952
|
-
* Use the `errorOnExist` option to change this behavior.
|
|
953
|
-
* @default true
|
|
954
|
-
*/
|
|
955
|
-
overwrite?: boolean | undefined;
|
|
956
|
-
/**
|
|
957
|
-
* When `true`, will set last modification and access times to the ones of the original source files.
|
|
958
|
-
* When `false`, timestamp behavior is OS-dependent.
|
|
959
|
-
* @default false
|
|
960
|
-
*/
|
|
961
|
-
preserveTimestamps?: boolean | undefined;
|
|
962
|
-
/**
|
|
963
|
-
* When `overwrite` is `false` and the destination exists, throw an error.
|
|
964
|
-
* @default false
|
|
965
|
-
*/
|
|
966
|
-
errorOnExist?: boolean | undefined;
|
|
967
|
-
/**
|
|
968
|
-
* Function to filter copied files/directories. Return `true` to copy the item, `false` to ignore it.
|
|
969
|
-
* Can also return a `Promise` that resolves to `true` or `false` (or pass in an `async` function).
|
|
970
|
-
*/
|
|
971
|
-
filter?: CopyFilterSync | CopyFilterAsync | undefined;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
export interface CopyOptionsSync extends CopyOptions {
|
|
975
|
-
/**
|
|
976
|
-
* Function to filter copied files/directories. Return `true` to copy the item, `false` to ignore it.
|
|
977
|
-
*/
|
|
978
|
-
filter?: CopyFilterSync | undefined;
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
export interface EnsureDirOptions {
|
|
982
|
-
mode?: number | undefined;
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
export interface MoveOptions {
|
|
986
|
-
/**
|
|
987
|
-
* Overwrite existing file or directory.
|
|
988
|
-
* @default false
|
|
989
|
-
*/
|
|
990
|
-
overwrite?: boolean | undefined;
|
|
991
|
-
/**
|
|
992
|
-
* Dereference symlinks.
|
|
993
|
-
* @default false
|
|
994
|
-
*/
|
|
995
|
-
dereference?: boolean | undefined;
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
export { JFReadOptions as JsonReadOptions, JFWriteOptions as JsonWriteOptions } from "jsonfile";
|
|
999
|
-
|
|
1000
|
-
export type JsonOutputOptions = fs.WriteFileOptions & StringifyOptions;
|