Skip to content

Commit eb7a05b

Browse files
committed
Ensure all reasonably templatable options are templatable.
1 parent eef37c0 commit eb7a05b

File tree

2 files changed

+42
-18
lines changed

2 files changed

+42
-18
lines changed

tasks/ts.js

Lines changed: 18 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tasks/ts.ts

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function pluginFn(grunt: IGrunt) {
148148
proceed();
149149
}
150150

151-
function proceed(vsProjectTypeScriptSettings? : csproj2ts.TypeScriptSettings) {
151+
function proceed(vsProjectTypeScriptSettings?: csproj2ts.TypeScriptSettings) {
152152

153153
if (vsProjectTypeScriptSettings && !vs.ignoreSettings) {
154154
options.declaration = utils.firstElementWithValue([vsProjectTypeScriptSettings.GeneratesDeclarations,
@@ -313,7 +313,7 @@ function pluginFn(grunt: IGrunt) {
313313
return path.resolve(filename) === referenceFile;
314314
}
315315

316-
function expandAndFetchTargetOutOrElseTryTargetDest(target: ITargetOptions) {
316+
function fetchTargetOutOrElseTryTargetDest(target: ITargetOptions) {
317317
var targetout = target.out;
318318
if (!targetout) {
319319
if (target.dest) {
@@ -328,17 +328,14 @@ function pluginFn(grunt: IGrunt) {
328328
}
329329
}
330330
}
331-
if (targetout) {
332-
target.out = grunt.template.process(targetout, {});
333-
}
331+
return targetout;
334332
}
335333

336334
// Create an output file?
337-
expandAndFetchTargetOutOrElseTryTargetDest(rawTargetConfig);
335+
var outFile = fetchTargetOutOrElseTryTargetDest(rawTargetConfig);
336+
var outFile_d_ts: string;
338337

339-
var outFile;
340-
var outFile_d_ts;
341-
if (!!rawTargetConfig.out) {
338+
if (!!outFile) {
342339
outFile = path.resolve(rawTargetConfig.out);
343340
outFile_d_ts = outFile.replace('.js', '.d.ts');
344341
}
@@ -368,6 +365,8 @@ function pluginFn(grunt: IGrunt) {
368365
amdloaderPath = path.dirname(amdloaderFile);
369366
}
370367

368+
processAllTemplates(rawTargetConfig, rawTargetOptions);
369+
371370
// Compiles all the files
372371
// Uses the blind tsc compile task
373372
// logs errors
@@ -696,8 +695,8 @@ function pluginFn(grunt: IGrunt) {
696695
});
697696

698697
function logBadConfigWithFiles(config: ITargetOptions,
699-
task: grunt.task.IMultiTask<ITargetOptions>,
700-
targetOpt: ITaskOptions) {
698+
task: grunt.task.IMultiTask<ITargetOptions>,
699+
targetOpt: ITaskOptions) {
701700
if (config.files) {
702701
if (config.vs) {
703702
grunt.log.writeln(('Warning: In task "' + task.target +
@@ -731,6 +730,20 @@ function pluginFn(grunt: IGrunt) {
731730
}
732731
}
733732

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+
734747
function getVSSettings(rawTargetOptions: ITargetOptions) {
735748
var vs: IVisualStudioProjectSupport = null;
736749
if (rawTargetOptions.vs) {

0 commit comments

Comments
 (0)