File tree 1 file changed +7
-9
lines changed
1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -16,17 +16,15 @@ function getWorkspace(
16
16
if ( configBuffer === null ) {
17
17
throw new SchematicsException ( `Could not find angular.json` ) ;
18
18
}
19
- const content = configBuffer . toString ( ) ;
20
19
21
- const { parse } = ( require ( 'jsonc-parser' ) as typeof import ( 'jsonc-parser' ) ) ;
20
+ // We can not depend on this library to have be included in older (or newer) Angular versions.
21
+ // Require here, since the schematic will add it to the package.json and install it before
22
+ // continuing.
23
+ const { parse } : typeof import ( 'jsonc-parser' ) = require ( 'jsonc-parser' ) ;
22
24
23
- let workspace : Workspace ;
24
- try {
25
- workspace = parse (
26
- content ,
27
- ) as Workspace ;
28
- } catch ( e ) {
29
- throw new SchematicsException ( `Could not parse angular.json: ` + e . message ) ;
25
+ const workspace = parse ( configBuffer . toString ( ) ) as Workspace | undefined ;
26
+ if ( ! workspace ) {
27
+ throw new SchematicsException ( 'Could not parse angular.json' ) ;
30
28
}
31
29
32
30
return {
You can’t perform that action at this time.
0 commit comments