From a638d86490cea2551a151a482bb607cf1ddd70ef Mon Sep 17 00:00:00 2001 From: Juan Carlos Valerio Arrieta Date: Thu, 11 Jun 2020 16:57:17 -0600 Subject: [PATCH] fix(core): read tsconfig file using readJsonInTree --- .../src/schematics/remove/lib/update-tsconfig.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/workspace/src/schematics/remove/lib/update-tsconfig.ts b/packages/workspace/src/schematics/remove/lib/update-tsconfig.ts index e2b1a41a98..49ddddbf09 100644 --- a/packages/workspace/src/schematics/remove/lib/update-tsconfig.ts +++ b/packages/workspace/src/schematics/remove/lib/update-tsconfig.ts @@ -23,16 +23,11 @@ export function updateTsconfig(schema: Schema) { const tsConfigPath = 'tsconfig.json'; if (tree.exists(tsConfigPath)) { - let contents = tree.read(tsConfigPath).toString('utf-8'); - try { - contents = JSON.parse(contents); - } catch (e) { - throw new Error(`Cannot parse ${tsConfigPath}: ${e.message}`); - } - delete contents.compilerOptions.paths[ + const tsConfigJson = readJsonInTree(tree, tsConfigPath); + delete tsConfigJson.compilerOptions.paths[ `@${nxJson.npmScope}/${project.root.substr(5)}` ]; - tree.overwrite(tsConfigPath, serializeJson(contents)); + tree.overwrite(tsConfigPath, serializeJson(tsConfigJson)); } return tree;