@@ -148,7 +148,7 @@ function pluginFn(grunt: IGrunt) {
148
148
proceed ( ) ;
149
149
}
150
150
151
- function proceed ( vsProjectTypeScriptSettings ? : csproj2ts . TypeScriptSettings ) {
151
+ function proceed ( vsProjectTypeScriptSettings ?: csproj2ts . TypeScriptSettings ) {
152
152
153
153
if ( vsProjectTypeScriptSettings && ! vs . ignoreSettings ) {
154
154
options . declaration = utils . firstElementWithValue ( [ vsProjectTypeScriptSettings . GeneratesDeclarations ,
@@ -313,7 +313,7 @@ function pluginFn(grunt: IGrunt) {
313
313
return path . resolve ( filename ) === referenceFile ;
314
314
}
315
315
316
- function expandAndFetchTargetOutOrElseTryTargetDest ( target : ITargetOptions ) {
316
+ function fetchTargetOutOrElseTryTargetDest ( target : ITargetOptions ) {
317
317
var targetout = target . out ;
318
318
if ( ! targetout ) {
319
319
if ( target . dest ) {
@@ -328,17 +328,14 @@ function pluginFn(grunt: IGrunt) {
328
328
}
329
329
}
330
330
}
331
- if ( targetout ) {
332
- target . out = grunt . template . process ( targetout , { } ) ;
333
- }
331
+ return targetout ;
334
332
}
335
333
336
334
// Create an output file?
337
- expandAndFetchTargetOutOrElseTryTargetDest ( rawTargetConfig ) ;
335
+ var outFile = fetchTargetOutOrElseTryTargetDest ( rawTargetConfig ) ;
336
+ var outFile_d_ts : string ;
338
337
339
- var outFile ;
340
- var outFile_d_ts ;
341
- if ( ! ! rawTargetConfig . out ) {
338
+ if ( ! ! outFile ) {
342
339
outFile = path . resolve ( rawTargetConfig . out ) ;
343
340
outFile_d_ts = outFile . replace ( '.js' , '.d.ts' ) ;
344
341
}
@@ -368,6 +365,8 @@ function pluginFn(grunt: IGrunt) {
368
365
amdloaderPath = path . dirname ( amdloaderFile ) ;
369
366
}
370
367
368
+ processAllTemplates ( rawTargetConfig , rawTargetOptions ) ;
369
+
371
370
// Compiles all the files
372
371
// Uses the blind tsc compile task
373
372
// logs errors
@@ -696,8 +695,8 @@ function pluginFn(grunt: IGrunt) {
696
695
} ) ;
697
696
698
697
function logBadConfigWithFiles ( config : ITargetOptions ,
699
- task : grunt . task . IMultiTask < ITargetOptions > ,
700
- targetOpt : ITaskOptions ) {
698
+ task : grunt . task . IMultiTask < ITargetOptions > ,
699
+ targetOpt : ITaskOptions ) {
701
700
if ( config . files ) {
702
701
if ( config . vs ) {
703
702
grunt . log . writeln ( ( 'Warning: In task "' + task . target +
@@ -731,6 +730,20 @@ function pluginFn(grunt: IGrunt) {
731
730
}
732
731
}
733
732
733
+ function processAllTemplates ( targetCfg : ITargetOptions , targetOpt : ITaskOptions ) {
734
+ targetCfg . out = processTemplate ( targetCfg . out ) ;
735
+ targetCfg . outDir = processTemplate ( targetCfg . outDir ) ;
736
+ targetCfg . reference = processTemplate ( targetCfg . reference ) ;
737
+ targetOpt . mapRoot = processTemplate ( targetOpt . mapRoot ) ;
738
+ targetOpt . sourceRoot = processTemplate ( targetOpt . sourceRoot ) ;
739
+ }
740
+ function processTemplate ( template : string ) {
741
+ if ( template ) {
742
+ return grunt . template . process ( template , { } ) ;
743
+ }
744
+ return template ;
745
+ }
746
+
734
747
function getVSSettings ( rawTargetOptions : ITargetOptions ) {
735
748
var vs : IVisualStudioProjectSupport = null ;
736
749
if ( rawTargetOptions . vs ) {
0 commit comments