@nrwl/workspace
Version:
35 lines • 1.61 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateTsconfig = void 0;
const tslib_1 = require("tslib");
const devkit_1 = require("@nrwl/devkit");
const ts_config_1 = require("../../../utilities/ts-config");
const find_project_for_path_1 = require("nx/src/project-graph/utils/find-project-for-path");
/**
* Updates the tsconfig paths to remove the project.
*
* @param schema The options provided to the schematic
*/
function updateTsconfig(tree, schema) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const tsConfigPath = (0, ts_config_1.getRootTsConfigPathInTree)(tree);
if (tree.exists(tsConfigPath)) {
const graph = yield (0, devkit_1.createProjectGraphAsync)();
const projectMapping = (0, find_project_for_path_1.createProjectRootMappings)(graph.nodes);
(0, devkit_1.updateJson)(tree, tsConfigPath, (json) => {
for (const importPath in json.compilerOptions.paths) {
for (const path of json.compilerOptions.paths[importPath]) {
const project = (0, find_project_for_path_1.findProjectForPath)((0, devkit_1.normalizePath)(path), projectMapping);
if (project === schema.projectName) {
delete json.compilerOptions.paths[importPath];
break;
}
}
}
return json;
});
}
});
}
exports.updateTsconfig = updateTsconfig;
//# sourceMappingURL=update-tsconfig.js.map
;