Skip to content

fix: on error builds an error was thrown because of duped files. #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions lib/broccoli/broccoli-typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class BroccoliTypeScriptCompiler extends Plugin {
fse.mkdirsSync(path.dirname(outputFilePath));
fs.linkSync(absoluteFilePath, outputFilePath);
});
return;
} else {
this._fileRegistry[tsFilePath].version = entry.mtime;
pathsToEmit.push(tsFilePath);
Expand All @@ -94,7 +93,7 @@ class BroccoliTypeScriptCompiler extends Plugin {
pathsToEmit.forEach(tsFilePath => {
var output = this._tsService.getEmitOutput(tsFilePath);
if (output.emitSkipped) {
var errorFound = this.collectErrors(tsFilePath);
var errorFound = this._collectErrors(tsFilePath);
if (errorFound) {
pathsWithErrors.push(tsFilePath);
errorMessages.push(errorFound);
Expand Down Expand Up @@ -129,7 +128,7 @@ class BroccoliTypeScriptCompiler extends Plugin {
this._tsService = ts.createLanguageService(this._tsServiceHost, ts.createDocumentRegistry());
}

collectErrors(tsFilePath) {
_collectErrors(tsFilePath) {
var allDiagnostics = this._tsService.getCompilerOptionsDiagnostics()
.concat(this._tsService.getSyntacticDiagnostics(tsFilePath))
.concat(this._tsService.getSemanticDiagnostics(tsFilePath));
Expand All @@ -156,7 +155,7 @@ class BroccoliTypeScriptCompiler extends Plugin {

// Find the entry, update the registry.
let allEntries = this.listEntries();
allEntries.forEach(entry => this._addNewFileEntry(entry));
allEntries.forEach(entry => this._addNewFileEntry(entry, false));

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

if (emitResult.emitSkipped) {
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
var errorMessages_1 = [];
var errorMessages = [];
allDiagnostics.forEach(function (diagnostic) {
var pos = '';
if (diagnostic.file) {
var _a = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start), line = _a.line, character = _a.character;
pos = diagnostic.file.fileName + ' (' + (line + 1) + ', ' + (character + 1) + '): ';
}
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
errorMessages_1.push(' ' + pos + message);
errorMessages.push(' ' + pos + message);
});
if (errorMessages_1.length) {
if (errorMessages.length) {
this.previousRunFailed = true;
var error = new Error('Typescript found the following errors:\n' + errorMessages_1.join('\n'));
error['showStack'] = false;
Expand Down Expand Up @@ -206,10 +205,14 @@ class BroccoliTypeScriptCompiler extends Plugin {
fs.linkSync(absoluteFilePath, outputFilePath);
}

_addNewFileEntry(entry) {
_addNewFileEntry(entry, checkDuplicates /* = true */) {
if (checkDuplicates === undefined) {
checkDuplicates = true;
}

const p = path.join(this.inputPaths[0], entry.relativePath);
if (this._fileRegistry[p]) {
throw new Error('Trying to add a new entry to an already existing one: ' + p);
if (checkDuplicates && this._fileRegistry[p]) {
throw `Trying to add a new entry to an already existing one: "${p}`;
}

this._fileRegistry[p] = {
Expand Down