mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 10:46:28 -05:00
When tsc --build --clean, only remove tsbuildinfo if its incremental build
This commit is contained in:
@@ -2033,21 +2033,19 @@ namespace ts {
|
||||
reportParseConfigFileDiagnostic(state, resolvedPath);
|
||||
continue;
|
||||
}
|
||||
const buildInfoPath = getTsBuildInfoEmitOutputFilePath(parsed.options);
|
||||
if (buildInfoPath) {
|
||||
// Only delete buildInfo as thats sufficient
|
||||
removeOutput(buildInfoPath, resolvedPath);
|
||||
continue;
|
||||
}
|
||||
const outputs = getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames());
|
||||
if (!outputs.length) continue;
|
||||
const inputFileNames = new Set(parsed.fileNames.map(f => toPath(state, f)));
|
||||
for (const output of outputs) {
|
||||
// If output name is same as input file name, do not delete and ignore the error
|
||||
if (inputFileNames.has(toPath(state, output))) continue;
|
||||
if (host.fileExists(output)) {
|
||||
if (filesToDelete) {
|
||||
filesToDelete.push(output);
|
||||
}
|
||||
else {
|
||||
host.deleteFile(output);
|
||||
invalidateProject(state, resolvedPath, ConfigFileProgramReloadLevel.None);
|
||||
}
|
||||
}
|
||||
removeOutput(output, resolvedPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2056,6 +2054,18 @@ namespace ts {
|
||||
}
|
||||
|
||||
return ExitStatus.Success;
|
||||
|
||||
function removeOutput(output: string, resolvedPath: ResolvedConfigFilePath) {
|
||||
if (host.fileExists(output)) {
|
||||
if (filesToDelete) {
|
||||
filesToDelete.push(output);
|
||||
}
|
||||
else {
|
||||
host.deleteFile(output);
|
||||
invalidateProject(state, resolvedPath, ConfigFileProgramReloadLevel.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function invalidateProject(state: SolutionBuilderState, resolved: ResolvedConfigFilePath, reloadLevel: ConfigFileProgramReloadLevel) {
|
||||
|
||||
@@ -596,20 +596,8 @@ Output::
|
||||
exitCode:: ExitStatus.Success
|
||||
|
||||
|
||||
//// [/src/2/second-output.d.ts] unlink
|
||||
//// [/src/2/second-output.d.ts.map] unlink
|
||||
//// [/src/2/second-output.js] unlink
|
||||
//// [/src/2/second-output.js.map] unlink
|
||||
//// [/src/2/second-output.tsbuildinfo] unlink
|
||||
//// [/src/first/bin/first-output.d.ts] unlink
|
||||
//// [/src/first/bin/first-output.d.ts.map] unlink
|
||||
//// [/src/first/bin/first-output.js] unlink
|
||||
//// [/src/first/bin/first-output.js.map] unlink
|
||||
//// [/src/first/bin/first-output.tsbuildinfo] unlink
|
||||
//// [/src/third/thirdjs/output/third-output.d.ts] unlink
|
||||
//// [/src/third/thirdjs/output/third-output.d.ts.map] unlink
|
||||
//// [/src/third/thirdjs/output/third-output.js] unlink
|
||||
//// [/src/third/thirdjs/output/third-output.js.map] unlink
|
||||
//// [/src/third/thirdjs/output/third-output.tsbuildinfo] unlink
|
||||
|
||||
|
||||
|
||||
@@ -596,8 +596,4 @@ Output::
|
||||
exitCode:: ExitStatus.Success
|
||||
|
||||
|
||||
//// [/src/2/second-output.d.ts] unlink
|
||||
//// [/src/2/second-output.d.ts.map] unlink
|
||||
//// [/src/2/second-output.js] unlink
|
||||
//// [/src/2/second-output.js.map] unlink
|
||||
//// [/src/2/second-output.tsbuildinfo] unlink
|
||||
|
||||
@@ -390,19 +390,8 @@ Output::
|
||||
exitCode:: ExitStatus.Success
|
||||
|
||||
|
||||
//// [/src/core/anotherModule.d.ts] unlink
|
||||
//// [/src/core/anotherModule.d.ts.map] unlink
|
||||
//// [/src/core/anotherModule.js] unlink
|
||||
//// [/src/core/index.d.ts] unlink
|
||||
//// [/src/core/index.d.ts.map] unlink
|
||||
//// [/src/core/index.js] unlink
|
||||
//// [/src/core/tsconfig.tsbuildinfo] unlink
|
||||
//// [/src/logic/index.d.ts] unlink
|
||||
//// [/src/logic/index.js] unlink
|
||||
//// [/src/logic/index.js.map] unlink
|
||||
//// [/src/logic/tsconfig.tsbuildinfo] unlink
|
||||
//// [/src/tests/index.d.ts] unlink
|
||||
//// [/src/tests/index.js] unlink
|
||||
//// [/src/tests/tsconfig.tsbuildinfo] unlink
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user