@@ -218,47 +218,17 @@ suite('Raw FileSystem', () => {
218
218
} ) ;
219
219
} ) ;
220
220
221
- suite ( 'stat' , ( ) => {
222
- test ( 'gets the info for an existing file' , async ( ) => {
223
- const filename = await fix . createFile ( 'x/y/z/spam.py' , '...' ) ;
224
- const expected = await fsextra . stat ( filename ) ;
225
-
226
- const stat = await filesystem . stat ( filename ) ;
227
-
228
- expect ( stat ) . to . deep . equal ( expected ) ;
229
- } ) ;
230
-
231
- test ( 'gets the info for an existing directory' , async ( ) => {
232
- const dirname = await fix . createDirectory ( 'x/y/z/spam' ) ;
233
- const expected = await fsextra . stat ( dirname ) ;
234
-
235
- const stat = await filesystem . stat ( dirname ) ;
236
-
237
- expect ( stat ) . to . deep . equal ( expected ) ;
238
- } ) ;
239
-
240
- test ( 'for symlinks, gets the info for the linked file' , async ( ) => {
241
- const filename = await fix . createFile ( 'x/y/z/spam.py' , '...' ) ;
242
- const symlink = await fix . createSymlink ( 'x/y/z/eggs.py' , filename ) ;
243
- const expected = await fsextra . stat ( filename ) ;
244
-
245
- const stat = await filesystem . stat ( symlink ) ;
246
-
247
- expect ( stat ) . to . deep . equal ( expected ) ;
248
- } ) ;
249
-
250
- test ( 'fails if the file does not exist' , async ( ) => {
251
- const promise = filesystem . stat ( DOES_NOT_EXIST ) ;
252
-
253
- await expect ( promise ) . to . eventually . be . rejected ;
254
- } ) ;
255
- } ) ;
256
-
257
221
suite ( 'lstat' , ( ) => {
258
222
test ( 'for symlinks, gives the link info' , async ( ) => {
259
223
const filename = await fix . createFile ( 'x/y/z/spam.py' , '...' ) ;
260
224
const symlink = await fix . createSymlink ( 'x/y/z/eggs.py' , filename ) ;
261
- const expected = await fsextra . lstat ( symlink ) ;
225
+ const old = await fsextra . lstat ( symlink ) ;
226
+ const expected = {
227
+ type : FileType . SymbolicLink ,
228
+ size : old . size ,
229
+ ctime : old . ctimeMs ,
230
+ mtime : old . mtimeMs
231
+ } ;
262
232
263
233
const stat = await filesystem . lstat ( symlink ) ;
264
234
@@ -267,7 +237,13 @@ suite('Raw FileSystem', () => {
267
237
268
238
test ( 'for normal files, gives the file info' , async ( ) => {
269
239
const filename = await fix . createFile ( 'x/y/z/spam.py' , '...' ) ;
270
- const expected = await fsextra . stat ( filename ) ;
240
+ const old = await fsextra . stat ( filename ) ;
241
+ const expected = {
242
+ type : FileType . File ,
243
+ size : old . size ,
244
+ ctime : old . ctimeMs ,
245
+ mtime : old . mtimeMs
246
+ } ;
271
247
272
248
const stat = await filesystem . lstat ( filename ) ;
273
249
@@ -356,7 +332,13 @@ suite('Raw FileSystem', () => {
356
332
suite ( 'statSync' , ( ) => {
357
333
test ( 'gets the info for an existing file' , async ( ) => {
358
334
const filename = await fix . createFile ( 'x/y/z/spam.py' , '...' ) ;
359
- const expected = await fsextra . stat ( filename ) ;
335
+ const old = await fsextra . stat ( filename ) ;
336
+ const expected = {
337
+ type : FileType . File ,
338
+ size : old . size ,
339
+ ctime : old . ctimeMs ,
340
+ mtime : old . mtimeMs
341
+ } ;
360
342
361
343
const stat = filesystem . statSync ( filename ) ;
362
344
@@ -365,7 +347,13 @@ suite('Raw FileSystem', () => {
365
347
366
348
test ( 'gets the info for an existing directory' , async ( ) => {
367
349
const dirname = await fix . createDirectory ( 'x/y/z/spam' ) ;
368
- const expected = await fsextra . stat ( dirname ) ;
350
+ const old = await fsextra . stat ( dirname ) ;
351
+ const expected = {
352
+ type : FileType . Directory ,
353
+ size : old . size ,
354
+ ctime : old . ctimeMs ,
355
+ mtime : old . mtimeMs
356
+ } ;
369
357
370
358
const stat = filesystem . statSync ( dirname ) ;
371
359
@@ -375,7 +363,13 @@ suite('Raw FileSystem', () => {
375
363
test ( 'for symlinks, gets the info for the linked file' , async ( ) => {
376
364
const filename = await fix . createFile ( 'x/y/z/spam.py' , '...' ) ;
377
365
const symlink = await fix . createSymlink ( 'x/y/z/eggs.py' , filename ) ;
378
- const expected = await fsextra . stat ( filename ) ;
366
+ const old = await fsextra . stat ( filename ) ;
367
+ const expected = {
368
+ type : FileType . File ,
369
+ size : old . size ,
370
+ ctime : old . ctimeMs ,
371
+ mtime : old . mtimeMs
372
+ } ;
379
373
380
374
const stat = filesystem . statSync ( symlink ) ;
381
375
@@ -632,100 +626,6 @@ suite('FileSystem Utils', () => {
632
626
}
633
627
} ) ;
634
628
635
- suite ( 'pathExists' , ( ) => {
636
- test ( 'file missing (any})' , async ( ) => {
637
- const exists = await utils . pathExists ( DOES_NOT_EXIST ) ;
638
-
639
- expect ( exists ) . to . equal ( false ) ;
640
- } ) ;
641
-
642
- Object . keys ( FileType ) . forEach ( ft => {
643
- test ( `file missing (${ ft } )` , async ( ) => {
644
- //tslint:disable-next-line:no-any
645
- const exists = await utils . pathExists ( DOES_NOT_EXIST , ft as any as FileType ) ;
646
-
647
- expect ( exists ) . to . equal ( false ) ;
648
- } ) ;
649
- } ) ;
650
-
651
- test ( 'any' , async ( ) => {
652
- const filename = await fix . createFile ( 'x/y/z/spam.py' ) ;
653
-
654
- const exists = await utils . pathExists ( filename ) ;
655
-
656
- expect ( exists ) . to . equal ( true ) ;
657
- } ) ;
658
-
659
- test ( 'want file, got file' , async ( ) => {
660
- const filename = await fix . createFile ( 'x/y/z/spam.py' ) ;
661
-
662
- const exists = await utils . pathExists ( filename , FileType . File ) ;
663
-
664
- expect ( exists ) . to . equal ( true ) ;
665
- } ) ;
666
-
667
- test ( 'want file, not file' , async ( ) => {
668
- const filename = await fix . createDirectory ( 'x/y/z/spam.py' ) ;
669
-
670
- const exists = await utils . pathExists ( filename , FileType . File ) ;
671
-
672
- expect ( exists ) . to . equal ( false ) ;
673
- } ) ;
674
-
675
- test ( 'want directory, got directory' , async ( ) => {
676
- const dirname = await fix . createDirectory ( 'x/y/z/spam' ) ;
677
-
678
- const exists = await utils . pathExists ( dirname , FileType . Directory ) ;
679
-
680
- expect ( exists ) . to . equal ( true ) ;
681
- } ) ;
682
-
683
- test ( 'want directory, not directory' , async ( ) => {
684
- const dirname = await fix . createFile ( 'x/y/z/spam' ) ;
685
-
686
- const exists = await utils . pathExists ( dirname , FileType . Directory ) ;
687
-
688
- expect ( exists ) . to . equal ( false ) ;
689
- } ) ;
690
-
691
- test ( 'symlink' , async ( ) => {
692
- const filename = await fix . createFile ( 'x/y/z/spam.py' , '...' ) ;
693
- const symlink = await fix . createSymlink ( 'x/y/z/eggs.py' , filename ) ;
694
-
695
- const exists = await utils . pathExists ( symlink , FileType . SymbolicLink ) ;
696
-
697
- expect ( exists ) . to . equal ( false ) ;
698
- } ) ;
699
-
700
- test ( 'unknown' , async ( ) => {
701
- const sockFile = await fix . createSocket ( 'x/y/z/ipc.sock' ) ;
702
-
703
- const exists = await utils . pathExists ( sockFile , FileType . Unknown ) ;
704
-
705
- expect ( exists ) . to . equal ( false ) ;
706
- } ) ;
707
- } ) ;
708
-
709
- suite ( 'fileExists' , ( ) => {
710
- test ( 'want file, got file' , async ( ) => {
711
- const filename = await fix . createFile ( 'x/y/z/spam.py' ) ;
712
-
713
- const exists = await utils . fileExists ( filename ) ;
714
-
715
- expect ( exists ) . to . equal ( true ) ;
716
- } ) ;
717
- } ) ;
718
-
719
- suite ( 'directoryExists' , ( ) => {
720
- test ( 'want directory, got directory' , async ( ) => {
721
- const dirname = await fix . createDirectory ( 'x/y/z/spam' ) ;
722
-
723
- const exists = await utils . directoryExists ( dirname ) ;
724
-
725
- expect ( exists ) . to . equal ( true ) ;
726
- } ) ;
727
- } ) ;
728
-
729
629
suite ( 'pathExistsSync' , ( ) => {
730
630
test ( 'exists' , async ( ) => {
731
631
const filename = await fix . createFile ( 'x/y/z/spam.py' ) ;
0 commit comments