@@ -27,7 +27,6 @@ namespace ts {
2727 getCurrentDirectory ( ) : string ;
2828 getDirectories ( path : string ) : string [ ] ;
2929 readDirectory ( path : string , extension ?: string , exclude ?: string [ ] ) : string [ ] ;
30- readDirectoryWithMultipleExtensions ?( path : string , extensions : string [ ] , exclude ?: string [ ] ) : string [ ] ;
3130 getModifiedTime ?( path : string ) : Date ;
3231 createHash ?( data : string ) : string ;
3332 getMemoryUsage ?( ) : number ;
@@ -416,64 +415,39 @@ namespace ts {
416415 return filter < string > ( _fs . readdirSync ( path ) , p => fileSystemEntryExists ( combinePaths ( path , p ) , FileSystemEntryKind . Directory ) ) ;
417416 }
418417
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 ) {
423427 // This is necessary because on some file system node fails to exclude
424428 // "." and "..". See https://github.com/nodejs/node/issues/4002
425429 if ( current === "." || current === ".." ) {
426430 continue ;
427431 }
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 ) ) ) {
433434 const stat = _fs . statSync ( name ) ;
434435 if ( stat . isFile ( ) ) {
435- if ( checkExtension ( name ) ) {
436+ if ( ! extension || fileExtensionIs ( name , extension ) ) {
436437 result . push ( name ) ;
437438 }
438439 }
439440 else if ( stat . isDirectory ( ) ) {
440441 directories . push ( name ) ;
441442 }
442443 }
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 ;
453444 }
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 ) ;
459447 }
460448 }
461449 }
462450
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-
477451 return {
478452 args : process . argv . slice ( 2 ) ,
479453 newLine : _os . EOL ,
@@ -548,7 +522,6 @@ namespace ts {
548522 } ,
549523 getDirectories,
550524 readDirectory,
551- readDirectoryWithMultipleExtensions,
552525 getModifiedTime ( path ) {
553526 try {
554527 return _fs . statSync ( path ) . mtime ;
0 commit comments