Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengbli committed Nov 1, 2016
1 parent 5268b75 commit 0c72309
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1538,18 +1538,13 @@ namespace ts {
// Report error if the output overwrites input file
if (filesByName.contains(emitFilePath)) {
const sourceFile = filesByName.get(emitFilePath);
if (isSourceFileJavaScript(sourceFile) && options.noEmitOverwriteForJsFiles) {
blockEmitingOfFile(emitFileName);
}
else {
blockEmitingOfFile(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
}
blockEmittingOfFile(emitFileName, !(options.noEmitOverwriteForJsFiles && isSourceFileJavaScript(sourceFile)) && Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
}

// Report error if multiple files write into same file
if (emitFilesSeen.contains(emitFilePath)) {
// Already seen the same emit file - report error
blockEmitingOfFile(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
blockEmittingOfFile(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
}
else {
emitFilesSeen.set(emitFilePath, true);
Expand All @@ -1558,7 +1553,7 @@ namespace ts {
}
}

function blockEmitingOfFile(emitFileName: string, message?: DiagnosticMessage) {
function blockEmittingOfFile(emitFileName: string, message?: DiagnosticMessage) {
hasEmitBlockingDiagnostics.set(toPath(emitFileName, currentDirectory, getCanonicalFileName), true);
if (message) {
programDiagnostics.add(createCompilerDiagnostic(message, emitFileName));
Expand Down

0 comments on commit 0c72309

Please sign in to comment.