@@ -13,13 +13,41 @@ namespace ts {
1313 assert . isTrue ( undefined === parsed . config ) ;
1414 assert . isTrue ( undefined !== parsed . error ) ;
1515 }
16-
16+
1717 function assertParseErrorWithExcludesKeyword ( jsonText : string ) {
1818 let parsed = ts . parseConfigFileTextToJson ( "/apath/tsconfig.json" , jsonText ) ;
1919 let parsedCommand = ts . parseJsonConfigFileContent ( parsed , ts . sys , "tests/cases/unittests" ) ;
2020 assert . isTrue ( undefined !== parsedCommand . errors ) ;
2121 }
2222
23+ function assertParseFileList ( jsonText : string , configFileName : string , basePath : string , allFileList : string [ ] , expectedFileList : string [ ] ) {
24+ const json = JSON . parse ( jsonText ) ;
25+ const host : ParseConfigHost = { readDirectory : mockReadDirectory } ;
26+ const parsed = ts . parseJsonConfigFileContent ( json , host , basePath , /*existingOptions*/ undefined , configFileName ) ;
27+ assert . isTrue ( arrayIsEqualTo ( parsed . fileNames . sort ( ) , expectedFileList . sort ( ) ) ) ;
28+
29+ function mockReadDirectory ( rootDir : string , extension : string , exclude : string [ ] ) : string [ ] {
30+ const result : string [ ] = [ ] ;
31+ const fullExcludeDirectories = ts . map ( exclude , directory => combinePaths ( rootDir , directory ) ) ;
32+ for ( const file of allFileList ) {
33+ let shouldExclude = false ;
34+ for ( const fullExcludeDirectorie of fullExcludeDirectories ) {
35+ if ( file . indexOf ( fullExcludeDirectorie ) >= 0 ) {
36+ shouldExclude = true ;
37+ break ;
38+ }
39+ }
40+ if ( shouldExclude ) {
41+ continue ;
42+ }
43+ if ( fileExtensionIs ( file , extension ) ) {
44+ result . push ( file ) ;
45+ }
46+ }
47+ return result ;
48+ }
49+ }
50+
2351 it ( "returns empty config for file with only whitespaces" , ( ) => {
2452 assertParseResult ( "" , { config : { } } ) ;
2553 assertParseResult ( " " , { config : { } } ) ;
@@ -108,7 +136,7 @@ namespace ts {
108136 config : { compilerOptions : { lib : "es5,es6" } }
109137 } ) ;
110138 } ) ;
111-
139+
112140 it ( "returns error when tsconfig have excludes" , ( ) => {
113141 assertParseErrorWithExcludesKeyword (
114142 `{
@@ -120,5 +148,15 @@ namespace ts {
120148 ]
121149 }` ) ;
122150 } ) ;
151+
152+ it ( "ignore dotted files and folders" , ( ) => {
153+ assertParseFileList (
154+ `{}` ,
155+ "tsconfig.json" ,
156+ "/apath" ,
157+ [ "/apath/test.ts" , "/apath/.git/a.ts" , "/apath/.b.ts" , "/apath/..c.ts" ] ,
158+ [ "/apath/test.ts" ]
159+ )
160+ } )
123161 } ) ;
124162}
0 commit comments