@@ -15,7 +15,7 @@ module ts {
15
15
createDirectory ( path : string ) : void ;
16
16
getExecutingFilePath ( ) : string ;
17
17
getCurrentDirectory ( ) : string ;
18
- readDirectory ( path : string , extension ?: string ) : string [ ] ;
18
+ readDirectory ( path : string , extension ?: string , exclude ?: string [ ] ) : string [ ] ;
19
19
getMemoryUsage ?( ) : number ;
20
20
exit ( exitCode ?: number ) : void ;
21
21
}
@@ -109,29 +109,38 @@ module ts {
109
109
}
110
110
}
111
111
112
- function getNames ( collection : any ) : string [ ] {
112
+ function getCanonicalPath ( path : string ) : string {
113
+ return path . toLowerCase ( ) ;
114
+ }
115
+
116
+ function getNames ( collection : any ) : string [ ] {
113
117
var result : string [ ] = [ ] ;
114
118
for ( var e = new Enumerator ( collection ) ; ! e . atEnd ( ) ; e . moveNext ( ) ) {
115
119
result . push ( e . item ( ) . Name ) ;
116
120
}
117
121
return result . sort ( ) ;
118
122
}
119
123
120
- function readDirectory ( path : string , extension ?: string ) : string [ ] {
124
+ function readDirectory ( path : string , extension ?: string , exclude ?: string [ ] ) : string [ ] {
121
125
var result : string [ ] = [ ] ;
126
+ exclude = map ( exclude , s => getCanonicalPath ( combinePaths ( path , s ) ) ) ;
122
127
visitDirectory ( path ) ;
123
128
return result ;
124
129
function visitDirectory ( path : string ) {
125
130
var folder = fso . GetFolder ( path || "." ) ;
126
131
var files = getNames ( folder . files ) ;
127
- for ( let name of files ) {
128
- if ( ! extension || fileExtensionIs ( name , extension ) ) {
129
- result . push ( combinePaths ( path , name ) ) ;
132
+ for ( let current of files ) {
133
+ let name = combinePaths ( path , current ) ;
134
+ if ( ( ! extension || fileExtensionIs ( name , extension ) ) && ! contains ( exclude , getCanonicalPath ( name ) ) ) {
135
+ result . push ( name ) ;
130
136
}
131
137
}
132
138
var subfolders = getNames ( folder . subfolders ) ;
133
139
for ( let current of subfolders ) {
134
- visitDirectory ( combinePaths ( path , current ) ) ;
140
+ let name = combinePaths ( path , current ) ;
141
+ if ( ! contains ( exclude , getCanonicalPath ( name ) ) ) {
142
+ visitDirectory ( name ) ;
143
+ }
135
144
}
136
145
}
137
146
}
@@ -222,23 +231,30 @@ module ts {
222
231
_fs . writeFileSync ( fileName , data , "utf8" ) ;
223
232
}
224
233
225
- function readDirectory ( path : string , extension ?: string ) : string [ ] {
234
+ function getCanonicalPath ( path : string ) : string {
235
+ return useCaseSensitiveFileNames ? path . toLowerCase ( ) : path ;
236
+ }
237
+
238
+ function readDirectory ( path : string , extension ?: string , exclude ?: string [ ] ) : string [ ] {
226
239
var result : string [ ] = [ ] ;
240
+ exclude = map ( exclude , s => getCanonicalPath ( combinePaths ( path , s ) ) ) ;
227
241
visitDirectory ( path ) ;
228
242
return result ;
229
243
function visitDirectory ( path : string ) {
230
244
var files = _fs . readdirSync ( path || "." ) . sort ( ) ;
231
245
var directories : string [ ] = [ ] ;
232
246
for ( let current of files ) {
233
247
var name = combinePaths ( path , current ) ;
234
- var stat = _fs . statSync ( name ) ;
235
- if ( stat . isFile ( ) ) {
236
- if ( ! extension || fileExtensionIs ( name , extension ) ) {
237
- result . push ( name ) ;
248
+ if ( ! contains ( exclude , getCanonicalPath ( name ) ) ) {
249
+ var stat = _fs . statSync ( name ) ;
250
+ if ( stat . isFile ( ) ) {
251
+ if ( ! extension || fileExtensionIs ( name , extension ) ) {
252
+ result . push ( name ) ;
253
+ }
254
+ }
255
+ else if ( stat . isDirectory ( ) ) {
256
+ directories . push ( name ) ;
238
257
}
239
- }
240
- else if ( stat . isDirectory ( ) ) {
241
- directories . push ( name ) ;
242
258
}
243
259
}
244
260
for ( let current of directories ) {
0 commit comments