@@ -17,14 +17,16 @@ interface ITypeScriptCompilerMessages {
17
17
18
18
export class TypeScriptCompilationService implements ITypeScriptCompilationService {
19
19
private typeScriptFiles : string [ ] ;
20
+ private definitionFiles : string [ ] ;
20
21
21
22
constructor ( private $childProcess : IChildProcess ,
22
23
private $fs : IFileSystem ,
23
24
private $logger : ILogger ,
24
25
private $config : Config . IConfig ) { }
25
26
26
- public initialize ( typeScriptFiles : string [ ] ) : void {
27
+ public initialize ( typeScriptFiles : string [ ] , definitionFiles ?: string [ ] ) : void {
27
28
this . typeScriptFiles = typeScriptFiles ;
29
+ this . definitionFiles = definitionFiles || [ ] ;
28
30
}
29
31
30
32
public compileAllFiles ( ) : IFuture < void > {
@@ -194,11 +196,14 @@ export class TypeScriptCompilationService implements ITypeScriptCompilationServi
194
196
195
197
private getTypeScriptDefinitionsFiles ( ) : IFuture < string [ ] > {
196
198
return ( ( ) => {
197
- var typeScriptDefinitionsFilesPath = path . join ( __dirname , "../../../resources/typescript-definitions-files" ) ;
198
- var definitionsFiles = this . $fs . readDirectory ( typeScriptDefinitionsFilesPath ) . wait ( ) ;
199
- return _ . map ( definitionsFiles , ( definitionFilePath : string ) => {
200
- return path . join ( typeScriptDefinitionsFilesPath , definitionFilePath ) ;
201
- } ) ;
199
+ var defaultTypeScriptDefinitionsFilesPath = path . join ( __dirname , "../../../resources/typescript-definitions-files" ) ;
200
+ var defaultDefinitionsFiles = this . $fs . readDirectory ( defaultTypeScriptDefinitionsFilesPath ) . wait ( ) ;
201
+
202
+ // Exclude definition files from default path, which are already part of the project (check only the name of the file)
203
+ var remainingDefaultDefinitionFiles = _ . filter ( defaultDefinitionsFiles , defFile => ! _ . any ( this . definitionFiles , f => path . basename ( f ) === defFile ) ) ;
204
+ return _ . map ( remainingDefaultDefinitionFiles , ( definitionFilePath : string ) => {
205
+ return path . join ( defaultTypeScriptDefinitionsFilesPath , definitionFilePath ) ;
206
+ } ) . concat ( this . definitionFiles ) ;
202
207
} ) . future < string [ ] > ( ) ( ) ;
203
208
}
204
209
}
0 commit comments