fix(generate): improve error handling
Deliver better errors than `Unexpected token } in JSON at position X` Fix issue #1047 https://github.com/nrwl/nx/issues/1047
This commit is contained in:
parent
240c3f62df
commit
c1b494c22e
@ -23,7 +23,12 @@ export function updateTsconfig(schema: Schema) {
|
|||||||
|
|
||||||
const tsConfigPath = 'tsconfig.json';
|
const tsConfigPath = 'tsconfig.json';
|
||||||
if (tree.exists(tsConfigPath)) {
|
if (tree.exists(tsConfigPath)) {
|
||||||
let contents = JSON.parse(tree.read(tsConfigPath).toString('utf-8'));
|
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[
|
delete contents.compilerOptions.paths[
|
||||||
`@${nxJson.npmScope}/${project.root.substr(5)}`
|
`@${nxJson.npmScope}/${project.root.substr(5)}`
|
||||||
];
|
];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user