Skip to content

Commit edc038f

Browse files
committed
fix: on error builds an error was thrown because of duped files.
1 parent f4395b1 commit edc038f

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

lib/broccoli/broccoli-typescript.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ class BroccoliTypeScriptCompiler extends Plugin {
8080
fse.mkdirsSync(path.dirname(outputFilePath));
8181
fs.linkSync(absoluteFilePath, outputFilePath);
8282
});
83-
return;
8483
} else {
8584
this._fileRegistry[tsFilePath].version = entry.mtime;
8685
pathsToEmit.push(tsFilePath);
@@ -94,7 +93,7 @@ class BroccoliTypeScriptCompiler extends Plugin {
9493
pathsToEmit.forEach(tsFilePath => {
9594
var output = this._tsService.getEmitOutput(tsFilePath);
9695
if (output.emitSkipped) {
97-
var errorFound = this.collectErrors(tsFilePath);
96+
var errorFound = this._collectErrors(tsFilePath);
9897
if (errorFound) {
9998
pathsWithErrors.push(tsFilePath);
10099
errorMessages.push(errorFound);
@@ -129,7 +128,7 @@ class BroccoliTypeScriptCompiler extends Plugin {
129128
this._tsService = ts.createLanguageService(this._tsServiceHost, ts.createDocumentRegistry());
130129
}
131130

132-
collectErrors(tsFilePath) {
131+
_collectErrors(tsFilePath) {
133132
var allDiagnostics = this._tsService.getCompilerOptionsDiagnostics()
134133
.concat(this._tsService.getSyntacticDiagnostics(tsFilePath))
135134
.concat(this._tsService.getSemanticDiagnostics(tsFilePath));
@@ -156,7 +155,7 @@ class BroccoliTypeScriptCompiler extends Plugin {
156155

157156
// Find the entry, update the registry.
158157
let allEntries = this.listEntries();
159-
allEntries.forEach(entry => this._addNewFileEntry(entry));
158+
allEntries.forEach(entry => this._addNewFileEntry(entry, false));
160159

161160
allFiles.forEach(sourceFile => {
162161
const registry = this._fileRegistry[path.resolve(this.inputPaths[0], sourceFile.fileName)];
@@ -166,19 +165,19 @@ class BroccoliTypeScriptCompiler extends Plugin {
166165

167166
if (emitResult.emitSkipped) {
168167
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
169-
var errorMessages_1 = [];
168+
var errorMessages = [];
170169
allDiagnostics.forEach(function (diagnostic) {
171170
var pos = '';
172171
if (diagnostic.file) {
173172
var _a = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start), line = _a.line, character = _a.character;
174173
pos = diagnostic.file.fileName + ' (' + (line + 1) + ', ' + (character + 1) + '): ';
175174
}
176175
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
177-
errorMessages_1.push(' ' + pos + message);
176+
errorMessages.push(' ' + pos + message);
178177
});
179-
if (errorMessages_1.length) {
178+
if (errorMessages.length) {
180179
this.previousRunFailed = true;
181-
var error = new Error('Typescript found the following errors:\n' + errorMessages_1.join('\n'));
180+
var error = new Error('Typescript found the following errors:\n' + errorMessages.join('\n'));
182181
error['showStack'] = false;
183182
throw error;
184183
} else {
@@ -206,10 +205,14 @@ class BroccoliTypeScriptCompiler extends Plugin {
206205
fs.linkSync(absoluteFilePath, outputFilePath);
207206
}
208207

209-
_addNewFileEntry(entry) {
208+
_addNewFileEntry(entry, checkDuplicates /* = true */) {
209+
if (checkDuplicates === undefined) {
210+
checkDuplicates = true;
211+
}
212+
210213
const p = path.join(this.inputPaths[0], entry.relativePath);
211-
if (this._fileRegistry[p]) {
212-
throw new Error('Trying to add a new entry to an already existing one: ' + p);
214+
if (checkDuplicates && this._fileRegistry[p]) {
215+
throw `Trying to add a new entry to an already existing one: "${p}`;
213216
}
214217

215218
this._fileRegistry[p] = {

0 commit comments

Comments
 (0)