Skip to content

Commit e5503e1

Browse files
committed
Fix additional issue in #251
As reported by @seanmailander
1 parent dce246f commit e5503e1

File tree

10 files changed

+169
-32
lines changed

10 files changed

+169
-32
lines changed

Gruntfile.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@ module.exports = function (grunt) {
103103
src: ['test/simple/ts/zoo.ts'],
104104
outDir: 'test/simple/js/',
105105
},
106+
out_with_spaces: {
107+
test: true,
108+
options: {
109+
fast: 'never',
110+
sourcemap: false
111+
},
112+
src: ['test/simple/ts/zoo.ts'],
113+
out: 'test/out with spaces/out with spaces.js'
114+
},
115+
outDir_with_spaces: {
116+
test: true,
117+
options: {
118+
fast: 'never',
119+
sourcemap: false
120+
},
121+
src: ['test/simple/ts/zoo.ts'],
122+
outDir: 'test/out with spaces'
123+
},
106124
multifiletest: {
107125
test: true,
108126
files: [{ src: ['test/multifile/a/**/*.ts'], dest: 'test/multifile/a/out.js' },

tasks/modules/compile.js

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

tasks/modules/compile.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ export function compileAllFiles(targetFiles: string[],
156156
}
157157

158158
// Quote the files to compile. Needed for command line parsing by tsc
159-
files = _.map(files, (item) => '"' + path.resolve(item) + '"');
159+
files = _.map(files, (item) => `"${path.resolve(item)}"`);
160+
if (outFile) {
161+
outFile = `"${path.resolve(outFile)}"`;
162+
}
160163

161164
var args: string[] = files.slice(0);
162165

@@ -199,23 +202,30 @@ export function compileAllFiles(targetFiles: string[],
199202
}
200203
}
201204

205+
var theOutDir : string = null;
206+
if (target.outDir) {
207+
if (target.out) {
208+
console.warn('WARNING: Option "out" and "outDir" should not be used together'.magenta);
209+
}
210+
211+
theOutDir = `"${path.resolve(target.outDir)}"`;
212+
args.push('--outDir', theOutDir);
213+
}
214+
202215
// Target options:
203216
if (outFile) {
204217
if (utils.isJavaScriptFile(outFile)) {
205218
args.push('--out', outFile);
206219
} else {
207-
args.push('--outDir', outFile);
220+
if (!theOutDir) {
221+
args.push('--outDir', outFile);
222+
}
208223
}
209224
} else if (target.out) {
210225
args.push('--out', target.out);
211226
}
212227

213-
if (target.outDir) {
214-
if (target.out) {
215-
console.warn('WARNING: Option "out" and "outDir" should not be used together'.magenta);
216-
}
217-
args.push('--outDir', target.outDir);
218-
}
228+
219229

220230
if (target.dest && (!target.out) && (!target.outDir)) {
221231
if (utils.isJavaScriptFile(target.dest)) {

tasks/modules/utils.js

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tasks/modules/utils.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,21 @@ export function endsWith(str: string, suffix: string): boolean {
7373
return str.indexOf(suffix, str.length - suffix.length) !== -1;
7474
}
7575

76+
export function stripQuotesIfQuoted(possiblyQuotedString: string) {
77+
if (!possiblyQuotedString.length || possiblyQuotedString.length < 2) {
78+
return possiblyQuotedString;
79+
}
80+
if (possiblyQuotedString.charAt(0) === '"' &&
81+
possiblyQuotedString.charAt(possiblyQuotedString.length - 1) === '"') {
82+
return possiblyQuotedString.substr(1, possiblyQuotedString.length - 2);
83+
}
84+
return possiblyQuotedString;
85+
}
86+
7687
export function isJavaScriptFile(filePath: string): boolean {
7788
if (filePath.toLowerCase) {
78-
return this.endsWith(filePath.toLowerCase(), '.js');
89+
var normalizedFile = path.resolve(stripQuotesIfQuoted(filePath)).toLowerCase();
90+
return endsWith(normalizedFile, '.js');
7991
}
8092
return false;
8193
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
var __extends = this.__extends || function (d, b) {
2+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
3+
function __() { this.constructor = d; }
4+
__.prototype = b.prototype;
5+
d.prototype = new __();
6+
};
7+
var Animal = (function () {
8+
function Animal(name) {
9+
this.name = name;
10+
}
11+
Animal.prototype.move = function (meters) {
12+
alert(this.name + " moved " + meters + "m.");
13+
};
14+
return Animal;
15+
})();
16+
var Snake = (function (_super) {
17+
__extends(Snake, _super);
18+
function Snake(name) {
19+
_super.call(this, name);
20+
}
21+
Snake.prototype.move = function () {
22+
alert("Slithering...");
23+
_super.prototype.move.call(this, 5);
24+
};
25+
return Snake;
26+
})(Animal);
27+
var Horse = (function (_super) {
28+
__extends(Horse, _super);
29+
function Horse(name) {
30+
_super.call(this, name);
31+
}
32+
Horse.prototype.move = function () {
33+
alert("Galloping...");
34+
_super.prototype.move.call(this, 45);
35+
};
36+
return Horse;
37+
})(Animal);
38+
var sam = new Snake("Sammy the Python");
39+
var tom = new Horse("Tommy the Palomino");
40+
sam.move();
41+
tom.move(34);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
var __extends = this.__extends || function (d, b) {
2+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
3+
function __() { this.constructor = d; }
4+
__.prototype = b.prototype;
5+
d.prototype = new __();
6+
};
7+
var Animal = (function () {
8+
function Animal(name) {
9+
this.name = name;
10+
}
11+
Animal.prototype.move = function (meters) {
12+
alert(this.name + " moved " + meters + "m.");
13+
};
14+
return Animal;
15+
})();
16+
var Snake = (function (_super) {
17+
__extends(Snake, _super);
18+
function Snake(name) {
19+
_super.call(this, name);
20+
}
21+
Snake.prototype.move = function () {
22+
alert("Slithering...");
23+
_super.prototype.move.call(this, 5);
24+
};
25+
return Snake;
26+
})(Animal);
27+
var Horse = (function (_super) {
28+
__extends(Horse, _super);
29+
function Horse(name) {
30+
_super.call(this, name);
31+
}
32+
Horse.prototype.move = function () {
33+
alert("Galloping...");
34+
_super.prototype.move.call(this, 45);
35+
};
36+
return Horse;
37+
})(Animal);
38+
var sam = new Snake("Sammy the Python");
39+
var tom = new Horse("Tommy the Palomino");
40+
sam.move();
41+
tom.move(34);

test/test.js

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

test/test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,9 @@ export var typescript = {
129129
files_ArrayFormatFolder: function (test) {
130130
testDirectory(test, 'multifile/files_testFilesUsedWithDestAsAJSFolder');
131131
test.done();
132+
},
133+
out_and_outdir_with_spaces: function (test) {
134+
testDirectory(test, 'out with spaces');
135+
test.done();
132136
}
133137
}

tsconfig.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,12 @@
5858
"./test/amdloader/ts/app/deep/classb.ts",
5959
"./test/amdloader/ts/app/deep/classc.ts",
6060
"./test/amdloader/ts/app/deep/deeper/classd.ts",
61-
"./test/amdloader/ts/app/partials/templates.a.html.ts",
6261
"./test/amdloader/ts/app/reference.ts",
6362
"./test/amdloader/ts/test/classt.ts",
6463
"./test/amdloader/ts/test/deep/classu.ts",
6564
"./test/amdloader/ts/test/deep/classv.ts",
6665
"./test/amdloader/ts/test/deep/deeper/classw.ts",
6766
"./test/amdloader/ts/test/extendedAppCode.ts",
68-
"./test/amdloader/ts/test/partials/templates.b.html.ts",
6967
"./test/amdloader/ts/test/reference.ts",
7068
"./test/amdloader/ts/test/test.ts",
7169
"./test/amdtest/a.ts",
@@ -97,17 +95,13 @@
9795
"./test/html/reference.ts",
9896
"./test/html/src/bar.ts",
9997
"./test/html/src/foo.ts",
100-
"./test/html/src/test.tpl.html.ts",
10198
"./test/htmlOutDir/reference.ts",
10299
"./test/htmlOutDir/src/bar.ts",
103100
"./test/htmlOutDir/src/foo.ts",
104-
"./test/htmlOutDir/src/test.tpl.html.ts",
105101
"./test/htmlOutDirFlat/reference.ts",
106102
"./test/htmlOutDirFlat/src/bar.ts",
107103
"./test/htmlOutDirFlat/src/foo.ts",
108-
"./test/htmlOutDirFlat/src/test.tpl.html.ts",
109104
"./test/htmlTemplate/reference.ts",
110-
"./test/htmlTemplate/src/advanced.$$template.name.tpl.html.ts",
111105
"./test/htmlTemplate/src/foo.ts",
112106
"./test/multifile/a/a.ts",
113107
"./test/multifile/a/b.ts",
@@ -132,7 +126,6 @@
132126
"./test/simple/js/zoo.d.ts",
133127
"./test/simple/ts/zoo.ts",
134128
"./test/sourceroot/src/a.ts",
135-
"./test/sourceroot/src/nested/b.html.ts",
136129
"./test/sourceroot/src/nested/b.ts",
137130
"./test/sourceroot/src/reference.ts",
138131
"./test/suppressImplicitAnyIndexErrors/test_suppressImplicitAnyIndexError.ts",

0 commit comments

Comments
 (0)