UNPKG

1.61 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.updateTsconfig = void 0;
4const tslib_1 = require("tslib");
5const devkit_1 = require("@nrwl/devkit");
6const ts_config_1 = require("../../../utilities/ts-config");
7const find_project_for_path_1 = require("nx/src/project-graph/utils/find-project-for-path");
8/**
9 * Updates the tsconfig paths to remove the project.
10 *
11 * @param schema The options provided to the schematic
12 */
13function updateTsconfig(tree, schema) {
14 return tslib_1.__awaiter(this, void 0, void 0, function* () {
15 const tsConfigPath = (0, ts_config_1.getRootTsConfigPathInTree)(tree);
16 if (tree.exists(tsConfigPath)) {
17 const graph = yield (0, devkit_1.createProjectGraphAsync)();
18 const projectMapping = (0, find_project_for_path_1.createProjectRootMappings)(graph.nodes);
19 (0, devkit_1.updateJson)(tree, tsConfigPath, (json) => {
20 for (const importPath in json.compilerOptions.paths) {
21 for (const path of json.compilerOptions.paths[importPath]) {
22 const project = (0, find_project_for_path_1.findProjectForPath)((0, devkit_1.normalizePath)(path), projectMapping);
23 if (project === schema.projectName) {
24 delete json.compilerOptions.paths[importPath];
25 break;
26 }
27 }
28 }
29 return json;
30 });
31 }
32 });
33}
34exports.updateTsconfig = updateTsconfig;
35//# sourceMappingURL=update-tsconfig.js.map
\No newline at end of file