File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -16,17 +16,15 @@ function getWorkspace(
1616 if ( configBuffer === null ) {
1717 throw new SchematicsException ( `Could not find angular.json` ) ;
1818 }
19- const content = configBuffer . toString ( ) ;
2019
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' ) ;
2224
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' ) ;
3028 }
3129
3230 return {
You can’t perform that action at this time.
0 commit comments