@@ -234,14 +234,29 @@ function applyCompilerOptions(applyTo: IGruntTSOptions, projectSpec: ITSConfigFi
234
234
addUniqueRelativeFilesToSrc ( projectSpec . files , src , absolutePathToTSConfig ) ;
235
235
} else {
236
236
if ( ! ( < any > globExpander ) . isStub ) {
237
- // if files is not specified, default to including *.ts and *.tsx in folder and subfolders.
238
- const virtualGlob = [ path . resolve ( absolutePathToTSConfig , './**/*.ts' ) ,
239
- path . resolve ( absolutePathToTSConfig , './**/*.tsx' ) ] ;
237
+
238
+ const virtualGlob : string [ ] = [ ] ;
239
+
240
240
if ( projectSpec . exclude && _ . isArray ( projectSpec . exclude ) ) {
241
- projectSpec . exclude . forEach ( exc => {
242
- virtualGlob . push ( '!' + path . resolve ( absolutePathToTSConfig , exc , './**/*.ts' ) ) ;
243
- virtualGlob . push ( '!' + path . resolve ( absolutePathToTSConfig , exc , './**/*.tsx' ) ) ;
244
- } ) ;
241
+ virtualGlob . push ( path . resolve ( absolutePathToTSConfig , './*.ts' ) ) ;
242
+ virtualGlob . push ( path . resolve ( absolutePathToTSConfig , './*.tsx' ) ) ;
243
+
244
+ const tsconfigExcludedDirectories : string [ ] = [ ] ;
245
+ projectSpec . exclude . forEach ( exc => {
246
+ tsconfigExcludedDirectories . push ( path . normalize ( path . join ( absolutePathToTSConfig , exc ) ) ) ;
247
+ } ) ;
248
+ fs . readdirSync ( absolutePathToTSConfig ) . forEach ( item => {
249
+ const filePath = path . normalize ( path . join ( absolutePathToTSConfig , item ) ) ;
250
+ if ( fs . statSync ( filePath ) . isDirectory ( ) ) {
251
+ if ( tsconfigExcludedDirectories . indexOf ( filePath ) === - 1 ) {
252
+ virtualGlob . push ( path . resolve ( absolutePathToTSConfig , item , './**/*.ts' ) ) ;
253
+ virtualGlob . push ( path . resolve ( absolutePathToTSConfig , item , './**/*.tsx' ) ) ;
254
+ }
255
+ }
256
+ } ) ;
257
+ } else {
258
+ virtualGlob . push ( path . resolve ( absolutePathToTSConfig , './**/*.ts' ) ) ;
259
+ virtualGlob . push ( path . resolve ( absolutePathToTSConfig , './**/*.tsx' ) ) ;
245
260
}
246
261
247
262
const files = globExpander ( virtualGlob ) ;
0 commit comments