MCPcopy Index your code
hub / github.com/nodejs/node / clean

Function clean

test/fixtures/snapshot/typescript.js:125261–125304  ·  view source on GitHub ↗
(state, project, onlyReferences)

Source from the content-addressed store, hash-verified

125259 : ts.ExitStatus.DiagnosticsPresent_OutputsSkipped;
125260 }
125261 function clean(state, project, onlyReferences) {
125262 var buildOrder = getBuildOrderFor(state, project, onlyReferences);
125263 if (!buildOrder)
125264 return ts.ExitStatus.InvalidProject_OutputsSkipped;
125265 if (isCircularBuildOrder(buildOrder)) {
125266 reportErrors(state, buildOrder.circularDiagnostics);
125267 return ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped;
125268 }
125269 var options = state.options, host = state.host;
125270 var filesToDelete = options.dry ? [] : undefined;
125271 for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) {
125272 var proj = buildOrder_1[_i];
125273 var resolvedPath = toResolvedConfigFilePath(state, proj);
125274 var parsed = parseConfigFile(state, proj, resolvedPath);
125275 if (parsed === undefined) {
125276 // File has gone missing; fine to ignore here
125277 reportParseConfigFileDiagnostic(state, resolvedPath);
125278 continue;
125279 }
125280 var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames());
125281 if (!outputs.length)
125282 continue;
125283 var inputFileNames = new ts.Set(parsed.fileNames.map(function (f) { return toPath(state, f); }));
125284 for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) {
125285 var output = outputs_3[_a];
125286 // If output name is same as input file name, do not delete and ignore the error
125287 if (inputFileNames.has(toPath(state, output)))
125288 continue;
125289 if (host.fileExists(output)) {
125290 if (filesToDelete) {
125291 filesToDelete.push(output);
125292 }
125293 else {
125294 host.deleteFile(output);
125295 invalidateProject(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None);
125296 }
125297 }
125298 }
125299 }
125300 if (filesToDelete) {
125301 reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * ".concat(f); }).join(""));
125302 }
125303 return ts.ExitStatus.Success;
125304 }
125305 function invalidateProject(state, resolved, reloadLevel) {
125306 // If host implements getParsedCommandLine, we cant get list of files from parseConfigFileHost
125307 if (state.host.getParsedCommandLine && reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) {

Callers 1

Calls 14

getBuildOrderForFunction · 0.85
isCircularBuildOrderFunction · 0.85
reportErrorsFunction · 0.85
toResolvedConfigFilePathFunction · 0.85
parseConfigFileFunction · 0.85
toPathFunction · 0.85
invalidateProjectFunction · 0.85
reportStatusFunction · 0.85
concatMethod · 0.80
mapMethod · 0.65
hasMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…