@@ -10,7 +10,7 @@ const fsPromises = fs.promises;
10
10
11
11
const rEOL = / \r \n / g;
12
12
13
- function exists ( path : string ) {
13
+ export function exists ( path : string ) {
14
14
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
15
15
const promise = fsPromises . access ( path ) . then ( ( ) => true , error => {
16
16
if ( error . code !== 'ENOENT' ) throw error ;
@@ -20,7 +20,7 @@ function exists(path: string) {
20
20
return BlueBirdPromise . resolve ( promise ) ;
21
21
}
22
22
23
- function existsSync ( path : string ) {
23
+ export function existsSync ( path : string ) {
24
24
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
25
25
26
26
try {
@@ -33,13 +33,13 @@ function existsSync(path: string) {
33
33
return true ;
34
34
}
35
35
36
- function mkdirs ( path : string ) {
36
+ export function mkdirs ( path : string ) {
37
37
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
38
38
39
39
return BlueBirdPromise . resolve ( fsPromises . mkdir ( path , { recursive : true } ) ) ;
40
40
}
41
41
42
- function mkdirsSync ( path : string ) {
42
+ export function mkdirsSync ( path : string ) {
43
43
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
44
44
45
45
fs . mkdirSync ( path , { recursive : true } ) ;
@@ -49,7 +49,7 @@ function checkParent(path: string) {
49
49
return BlueBirdPromise . resolve ( fsPromises . mkdir ( dirname ( path ) , { recursive : true } ) ) ;
50
50
}
51
51
52
- function writeFile (
52
+ export function writeFile (
53
53
path : string ,
54
54
data : any ,
55
55
options ?: WriteFileOptions
@@ -63,14 +63,14 @@ function writeFile(
63
63
}
64
64
65
65
66
- function writeFileSync ( path : string , data : any , options ?: WriteFileOptions ) {
66
+ export function writeFileSync ( path : string , data : any , options ?: WriteFileOptions ) {
67
67
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
68
68
69
69
fs . mkdirSync ( dirname ( path ) , { recursive : true } ) ;
70
70
fs . writeFileSync ( path , data , options ) ;
71
71
}
72
72
73
- function appendFile (
73
+ export function appendFile (
74
74
path : string ,
75
75
data : any ,
76
76
options ?: WriteFileOptions ) {
@@ -80,14 +80,14 @@ function appendFile(
80
80
. then ( ( ) => fsPromises . appendFile ( path , data , options ) ) ;
81
81
}
82
82
83
- function appendFileSync ( path : string , data : any , options ?: WriteFileOptions ) {
83
+ export function appendFileSync ( path : string , data : any , options ?: WriteFileOptions ) {
84
84
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
85
85
86
86
fs . mkdirSync ( dirname ( path ) , { recursive : true } ) ;
87
87
fs . appendFileSync ( path , data , options ) ;
88
88
}
89
89
90
- function copyFile (
90
+ export function copyFile (
91
91
src : string , dest : string , flags ?: number ) {
92
92
if ( ! src ) throw new TypeError ( 'src is required!' ) ;
93
93
if ( ! dest ) throw new TypeError ( 'dest is required!' ) ;
@@ -156,7 +156,7 @@ async function _copyDirWalker(
156
156
} ) ;
157
157
}
158
158
159
- function copyDir (
159
+ export function copyDir (
160
160
src : string , dest : string , options : ReadDirOptions = { } ) {
161
161
if ( ! src ) throw new TypeError ( 'src is required!' ) ;
162
162
if ( ! dest ) throw new TypeError ( 'dest is required!' ) ;
@@ -186,7 +186,7 @@ async function _listDirWalker(
186
186
await BlueBirdPromise . all ( promises ) ;
187
187
}
188
188
189
- function listDir (
189
+ export function listDir (
190
190
path : string , options : ReadDirOptions = { } ) {
191
191
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
192
192
@@ -209,7 +209,7 @@ function _listDirSyncWalker(
209
209
}
210
210
}
211
211
212
- function listDirSync ( path : string , options : ReadDirOptions = { } ) {
212
+ export function listDirSync ( path : string , options : ReadDirOptions = { } ) {
213
213
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
214
214
const results = [ ] ;
215
215
@@ -218,15 +218,15 @@ function listDirSync(path: string, options: ReadDirOptions = {}) {
218
218
return results ;
219
219
}
220
220
221
- function escapeEOL ( str : string ) {
221
+ export function escapeEOL ( str : string ) {
222
222
return str . replace ( rEOL , '\n' ) ;
223
223
}
224
224
225
- function escapeBOM ( str : string ) {
225
+ export function escapeBOM ( str : string ) {
226
226
return str . charCodeAt ( 0 ) === 0xFEFF ? str . substring ( 1 ) : str ;
227
227
}
228
228
229
- function escapeFileContent ( content ) {
229
+ export function escapeFileContent ( content ) {
230
230
return escapeBOM ( escapeEOL ( content ) ) ;
231
231
}
232
232
@@ -245,14 +245,14 @@ async function _readFile(path: string, options: ReadFileOptions | null = {}) {
245
245
return content ;
246
246
}
247
247
248
- function readFile (
248
+ export function readFile (
249
249
path : string , options ?: ReadFileOptions | null ) {
250
250
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
251
251
252
252
return BlueBirdPromise . resolve ( _readFile ( path , options ) ) ;
253
253
}
254
254
255
- function readFileSync ( path : string , options : ReadFileOptions = { } ) {
255
+ export function readFileSync ( path : string , options : ReadFileOptions = { } ) {
256
256
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
257
257
258
258
if ( ! Object . prototype . hasOwnProperty . call ( options ,
@@ -293,7 +293,7 @@ async function _emptyDir(
293
293
return results ;
294
294
}
295
295
296
- function emptyDir (
296
+ export function emptyDir (
297
297
path : string , options : ReadDirOptions & { exclude ?: any [ ] } = { } ) {
298
298
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
299
299
@@ -329,7 +329,7 @@ function _emptyDirSync(
329
329
return results ;
330
330
}
331
331
332
- function emptyDirSync (
332
+ export function emptyDirSync (
333
333
path : string , options : ReadDirOptions & { exclude ?: any [ ] } = { } ) {
334
334
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
335
335
@@ -347,7 +347,7 @@ async function _rmdir(path: string) {
347
347
return fsPromises . rmdir ( path ) ;
348
348
}
349
349
350
- function rmdir ( path : string ) {
350
+ export function rmdir ( path : string ) {
351
351
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
352
352
353
353
return BlueBirdPromise . resolve ( _rmdir ( path ) ) ;
@@ -370,13 +370,13 @@ function _rmdirSync(path: string) {
370
370
fs . rmdirSync ( path ) ;
371
371
}
372
372
373
- function rmdirSync ( path : string ) {
373
+ export function rmdirSync ( path : string ) {
374
374
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
375
375
376
376
_rmdirSync ( path ) ;
377
377
}
378
378
379
- function watch (
379
+ export function watch (
380
380
path : string | ReadonlyArray < string > , options ?: WatchOptions ) {
381
381
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
382
382
@@ -416,13 +416,13 @@ async function _ensurePath(path: string): Promise<string> {
416
416
return _findUnusedPath ( path , files ) ;
417
417
}
418
418
419
- function ensurePath ( path : string ) {
419
+ export function ensurePath ( path : string ) {
420
420
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
421
421
422
422
return BlueBirdPromise . resolve ( _ensurePath ( path ) ) ;
423
423
}
424
424
425
- function ensurePathSync ( path : string ) {
425
+ export function ensurePathSync ( path : string ) {
426
426
if ( ! path ) throw new TypeError ( 'path is required!' ) ;
427
427
if ( ! fs . existsSync ( path ) ) return path ;
428
428
@@ -431,7 +431,7 @@ function ensurePathSync(path: string) {
431
431
return _findUnusedPath ( path , files ) ;
432
432
}
433
433
434
- function ensureWriteStream ( path : string , options ?: string | {
434
+ export function ensureWriteStream ( path : string , options ?: string | {
435
435
flags ?: string ;
436
436
encoding ?: string ;
437
437
fd ?: number ;
@@ -447,7 +447,7 @@ function ensureWriteStream(path: string, options?: string | {
447
447
. then ( ( ) => fs . createWriteStream ( path , options ) ) ;
448
448
}
449
449
450
- function ensureWriteStreamSync ( path : string , options ?: string | {
450
+ export function ensureWriteStreamSync ( path : string , options ?: string | {
451
451
flags ?: string ;
452
452
encoding ?: string ;
453
453
fd ?: number ;
@@ -475,10 +475,6 @@ function ensureWriteStreamSync(path: string, options?: string | {
475
475
exports . access = BlueBirdPromise . promisify ( fs . access ) ;
476
476
exports . accessSync = fs . accessSync ;
477
477
478
- // appendFile
479
- exports . appendFile = appendFile ;
480
- exports . appendFileSync = appendFileSync ;
481
-
482
478
// chmod
483
479
exports . chmod = BlueBirdPromise . promisify ( fs . chmod ) ;
484
480
exports . chmodSync = fs . chmodSync ;
@@ -499,30 +495,10 @@ exports.lchownSync = fs.lchownSync;
499
495
exports . close = BlueBirdPromise . promisify ( fs . close ) ;
500
496
exports . closeSync = fs . closeSync ;
501
497
502
- // copy
503
- exports . copyDir = copyDir ;
504
- exports . copyFile = copyFile ;
505
-
506
498
// createStream
507
499
exports . createReadStream = fs . createReadStream ;
508
500
exports . createWriteStream = fs . createWriteStream ;
509
501
510
- // emptyDir
511
- exports . emptyDir = emptyDir ;
512
- exports . emptyDirSync = emptyDirSync ;
513
-
514
- // ensurePath
515
- exports . ensurePath = ensurePath ;
516
- exports . ensurePathSync = ensurePathSync ;
517
-
518
- // ensureWriteStream
519
- exports . ensureWriteStream = ensureWriteStream ;
520
- exports . ensureWriteStreamSync = ensureWriteStreamSync ;
521
-
522
- // exists
523
- exports . exists = exists ;
524
- exports . existsSync = existsSync ;
525
-
526
502
// fsync
527
503
exports . fsync = BlueBirdPromise . promisify ( fs . fsync ) ;
528
504
exports . fsyncSync = fs . fsyncSync ;
@@ -531,18 +507,10 @@ exports.fsyncSync = fs.fsyncSync;
531
507
exports . link = BlueBirdPromise . promisify ( fs . link ) ;
532
508
exports . linkSync = fs . linkSync ;
533
509
534
- // listDir
535
- exports . listDir = listDir ;
536
- exports . listDirSync = listDirSync ;
537
-
538
510
// mkdir
539
511
exports . mkdir = BlueBirdPromise . promisify ( fs . mkdir ) ;
540
512
exports . mkdirSync = fs . mkdirSync ;
541
513
542
- // mkdirs
543
- exports . mkdirs = mkdirs ;
544
- exports . mkdirsSync = mkdirsSync ;
545
-
546
514
// open
547
515
exports . open = BlueBirdPromise . promisify ( fs . open ) ;
548
516
exports . openSync = fs . openSync ;
@@ -559,10 +527,6 @@ exports.readSync = fs.readSync;
559
527
exports . readdir = BlueBirdPromise . promisify ( fs . readdir ) ;
560
528
exports . readdirSync = fs . readdirSync ;
561
529
562
- // readFile
563
- exports . readFile = readFile ;
564
- exports . readFileSync = readFileSync ;
565
-
566
530
// readlink
567
531
exports . readlink = BlueBirdPromise . promisify ( fs . readlink ) ;
568
532
exports . readlinkSync = fs . readlinkSync ;
@@ -575,10 +539,6 @@ exports.realpathSync = fs.realpathSync;
575
539
exports . rename = BlueBirdPromise . promisify ( fs . rename ) ;
576
540
exports . renameSync = fs . renameSync ;
577
541
578
- // rmdir
579
- exports . rmdir = rmdir ;
580
- exports . rmdirSync = rmdirSync ;
581
-
582
542
// stat
583
543
exports . stat = BlueBirdPromise . promisify ( fs . stat ) ;
584
544
exports . statSync = fs . statSync ;
@@ -604,25 +564,16 @@ exports.futimes = BlueBirdPromise.promisify(fs.futimes);
604
564
exports . futimesSync = fs . futimesSync ;
605
565
606
566
// watch
607
- exports . watch = watch ;
608
567
exports . watchFile = fs . watchFile ;
609
568
exports . unwatchFile = fs . unwatchFile ;
610
569
611
570
// write
612
571
exports . write = BlueBirdPromise . promisify ( fs . write ) ;
613
572
exports . writeSync = fs . writeSync ;
614
573
615
- // writeFile
616
- exports . writeFile = writeFile ;
617
- exports . writeFileSync = writeFileSync ;
618
-
619
574
// Static classes
620
575
exports . Stats = fs . Stats ;
621
576
exports . ReadStream = fs . ReadStream ;
622
577
exports . WriteStream = fs . WriteStream ;
623
578
exports . FileReadStream = fs . FileReadStream ;
624
579
exports . FileWriteStream = fs . FileWriteStream ;
625
-
626
- // util
627
- exports . escapeBOM = escapeBOM ;
628
- exports . escapeEOL = escapeEOL ;
0 commit comments