@@ -13,13 +13,41 @@ namespace ts {
13
13
assert . isTrue ( undefined === parsed . config ) ;
14
14
assert . isTrue ( undefined !== parsed . error ) ;
15
15
}
16
-
16
+
17
17
function assertParseErrorWithExcludesKeyword ( jsonText : string ) {
18
18
let parsed = ts . parseConfigFileTextToJson ( "/apath/tsconfig.json" , jsonText ) ;
19
19
let parsedCommand = ts . parseJsonConfigFileContent ( parsed , ts . sys , "tests/cases/unittests" ) ;
20
20
assert . isTrue ( undefined !== parsedCommand . errors ) ;
21
21
}
22
22
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
+
23
51
it ( "returns empty config for file with only whitespaces" , ( ) => {
24
52
assertParseResult ( "" , { config : { } } ) ;
25
53
assertParseResult ( " " , { config : { } } ) ;
@@ -108,7 +136,7 @@ namespace ts {
108
136
config : { compilerOptions : { lib : "es5,es6" } }
109
137
} ) ;
110
138
} ) ;
111
-
139
+
112
140
it ( "returns error when tsconfig have excludes" , ( ) => {
113
141
assertParseErrorWithExcludesKeyword (
114
142
`{
@@ -120,5 +148,15 @@ namespace ts {
120
148
]
121
149
}` ) ;
122
150
} ) ;
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
+ } )
123
161
} ) ;
124
162
}
0 commit comments