@@ -27,7 +27,6 @@ namespace ts {
27
27
getCurrentDirectory ( ) : string ;
28
28
getDirectories ( path : string ) : string [ ] ;
29
29
readDirectory ( path : string , extension ?: string , exclude ?: string [ ] ) : string [ ] ;
30
- readDirectoryWithMultipleExtensions ?( path : string , extensions : string [ ] , exclude ?: string [ ] ) : string [ ] ;
31
30
getModifiedTime ?( path : string ) : Date ;
32
31
createHash ?( data : string ) : string ;
33
32
getMemoryUsage ?( ) : number ;
@@ -416,64 +415,39 @@ namespace ts {
416
415
return filter < string > ( _fs . readdirSync ( path ) , p => fileSystemEntryExists ( combinePaths ( path , p ) , FileSystemEntryKind . Directory ) ) ;
417
416
}
418
417
419
- function visitDirectory ( path : string , result : string [ ] , extension : string | string [ ] , exclude : string [ ] ) {
420
- const files = _fs . readdirSync ( path || "." ) . sort ( ) ;
421
- const directories : string [ ] = [ ] ;
422
- for ( const current of files ) {
418
+ function readDirectory ( path : string , extension ?: string , exclude ?: string [ ] ) : string [ ] {
419
+ const result : string [ ] = [ ] ;
420
+ exclude = map ( exclude , s => getCanonicalPath ( combinePaths ( path , s ) ) ) ;
421
+ visitDirectory ( path ) ;
422
+ return result ;
423
+ function visitDirectory ( path : string ) {
424
+ const files = _fs . readdirSync ( path || "." ) . sort ( ) ;
425
+ const directories : string [ ] = [ ] ;
426
+ for ( const current of files ) {
423
427
// This is necessary because on some file system node fails to exclude
424
428
// "." and "..". See https://github.com/nodejs/node/issues/4002
425
429
if ( current === "." || current === ".." ) {
426
430
continue ;
427
431
}
428
- const name = combinePaths ( path , current ) ;
429
- if ( ! contains ( exclude , getCanonicalPath ( name ) ) ) {
430
- // fs.statSync would throw an exception if the file is a symlink
431
- // whose linked file doesn't exist.
432
- try {
432
+ const name = combinePaths ( path , current ) ;
433
+ if ( ! contains ( exclude , getCanonicalPath ( name ) ) ) {
433
434
const stat = _fs . statSync ( name ) ;
434
435
if ( stat . isFile ( ) ) {
435
- if ( checkExtension ( name ) ) {
436
+ if ( ! extension || fileExtensionIs ( name , extension ) ) {
436
437
result . push ( name ) ;
437
438
}
438
439
}
439
440
else if ( stat . isDirectory ( ) ) {
440
441
directories . push ( name ) ;
441
442
}
442
443
}
443
- catch ( e ) { }
444
- }
445
- }
446
- for ( const current of directories ) {
447
- visitDirectory ( current , result , extension , exclude ) ;
448
- }
449
-
450
- function checkExtension ( name : string ) {
451
- if ( ! extension ) {
452
- return true ;
453
444
}
454
- if ( typeof extension === "string" ) {
455
- return fileExtensionIs ( name , extension ) ;
456
- }
457
- else {
458
- return forEach ( extension , ext => fileExtensionIs ( name , ext ) ) ;
445
+ for ( const current of directories ) {
446
+ visitDirectory ( current ) ;
459
447
}
460
448
}
461
449
}
462
450
463
- function readDirectoryWithMultipleExtensions ( path : string , extensions : string [ ] , exclude ?: string [ ] ) : string [ ] {
464
- const result : string [ ] = [ ] ;
465
- exclude = map ( exclude , s => getCanonicalPath ( combinePaths ( path , s ) ) ) ;
466
- visitDirectory ( path , result , extensions , exclude ) ;
467
- return result ;
468
- }
469
-
470
- function readDirectory ( path : string , extension ?: string , exclude ?: string [ ] ) : string [ ] {
471
- const result : string [ ] = [ ] ;
472
- exclude = map ( exclude , s => getCanonicalPath ( combinePaths ( path , s ) ) ) ;
473
- visitDirectory ( path , result , extension , exclude ) ;
474
- return result ;
475
- }
476
-
477
451
return {
478
452
args : process . argv . slice ( 2 ) ,
479
453
newLine : _os . EOL ,
@@ -548,7 +522,6 @@ namespace ts {
548
522
} ,
549
523
getDirectories,
550
524
readDirectory,
551
- readDirectoryWithMultipleExtensions,
552
525
getModifiedTime ( path ) {
553
526
try {
554
527
return _fs . statSync ( path ) . mtime ;
0 commit comments