@@ -25,7 +25,7 @@ export interface IO {
25
25
fileExists ( fileName : string ) : boolean ;
26
26
directoryExists ( path : string ) : boolean ;
27
27
deleteFile ( fileName : string ) : void ;
28
- enumerateTestFiles ( runner : RunnerBase ) : ( string | FileBasedTest ) [ ] ;
28
+ enumerateTestFiles ( runner : RunnerBase ) : string [ ] ;
29
29
listFiles ( path : string , filter ?: RegExp , options ?: { recursive ?: boolean ; } ) : string [ ] ;
30
30
log ( text : string ) : void ;
31
31
args ( ) : string [ ] ;
@@ -84,55 +84,28 @@ function createNodeIO(): IO {
84
84
return runner . getTestFiles ( ) ;
85
85
}
86
86
87
- function listFiles ( path : string , spec : RegExp , options : { recursive ?: boolean ; } = { } ) {
87
+ function listFiles ( path : string , spec : RegExp | undefined , options : { recursive ?: boolean ; } = { } ) {
88
88
function filesInFolder ( folder : string ) : string [ ] {
89
+ const { files, directories } = ts . sys . getAccessibleFileSystemEntries ! ( folder ) ;
89
90
let paths : string [ ] = [ ] ;
90
-
91
- for ( const file of fs . readdirSync ( folder ) ) {
91
+ for ( const file of files ) {
92
92
const pathToFile = pathModule . join ( folder , file ) ;
93
- if ( ! fs . existsSync ( pathToFile ) ) continue ; // ignore invalid symlinks
94
- const stat = fs . statSync ( pathToFile ) ;
95
- if ( options . recursive && stat . isDirectory ( ) ) {
96
- paths = paths . concat ( filesInFolder ( pathToFile ) ) ;
97
- }
98
- else if ( stat . isFile ( ) && ( ! spec || file . match ( spec ) ) ) {
93
+ if ( ! spec || file . match ( spec ) ) {
99
94
paths . push ( pathToFile ) ;
100
95
}
101
96
}
102
-
97
+ if ( options . recursive ) {
98
+ for ( const dir of directories ) {
99
+ const pathToDir = pathModule . join ( folder , dir ) ;
100
+ paths = paths . concat ( filesInFolder ( pathToDir ) ) ;
101
+ }
102
+ }
103
103
return paths ;
104
104
}
105
105
106
106
return filesInFolder ( path ) ;
107
107
}
108
108
109
- function getAccessibleFileSystemEntries ( dirname : string ) : ts . FileSystemEntries {
110
- try {
111
- const entries : string [ ] = fs . readdirSync ( dirname || "." ) . sort ( ts . sys . useCaseSensitiveFileNames ? ts . compareStringsCaseSensitive : ts . compareStringsCaseInsensitive ) ;
112
- const files : string [ ] = [ ] ;
113
- const directories : string [ ] = [ ] ;
114
- for ( const entry of entries ) {
115
- if ( entry === "." || entry === ".." ) continue ;
116
- const name = vpath . combine ( dirname , entry ) ;
117
- try {
118
- const stat = fs . statSync ( name ) ;
119
- if ( ! stat ) continue ;
120
- if ( stat . isFile ( ) ) {
121
- files . push ( entry ) ;
122
- }
123
- else if ( stat . isDirectory ( ) ) {
124
- directories . push ( entry ) ;
125
- }
126
- }
127
- catch { /*ignore*/ }
128
- }
129
- return { files, directories } ;
130
- }
131
- catch ( e ) {
132
- return { files : [ ] , directories : [ ] } ;
133
- }
134
- }
135
-
136
109
function createDirectory ( path : string ) {
137
110
try {
138
111
fs . mkdirSync ( path ) ;
@@ -170,7 +143,7 @@ function createNodeIO(): IO {
170
143
getWorkspaceRoot : ( ) => workspaceRoot ,
171
144
exit : exitCode => ts . sys . exit ( exitCode ) ,
172
145
readDirectory : ( path , extension , exclude , include , depth ) => ts . sys . readDirectory ( path , extension , exclude , include , depth ) ,
173
- getAccessibleFileSystemEntries,
146
+ getAccessibleFileSystemEntries : ts . sys . getAccessibleFileSystemEntries ! ,
174
147
tryEnableSourceMapsForHost : ( ) => ts . sys . tryEnableSourceMapsForHost && ts . sys . tryEnableSourceMapsForHost ( ) ,
175
148
getMemoryUsage : ( ) => ts . sys . getMemoryUsage && ts . sys . getMemoryUsage ( ) ,
176
149
getEnvironmentVariable : name => ts . sys . getEnvironmentVariable ( name ) ,
0 commit comments