55 * Use of this source code is governed by an MIT-style license that can be
66 * found in the LICENSE file at https://angular.io/license
77 */
8- import { BaseException } from '@angular-devkit/core' ;
8+ import {
9+ BaseException ,
10+ InvalidJsonCharacterException ,
11+ UnexpectedEndOfInputException ,
12+ } from '@angular-devkit/core' ;
913import * as core from '@angular-devkit/core/node' ;
1014import { dirname , join , resolve as resolvePath } from 'path' ;
1115import { RuleFactory } from '../src' ;
@@ -18,6 +22,7 @@ import {
1822 CollectionCannotBeResolvedException ,
1923 CollectionMissingSchematicsMapException ,
2024 FileSystemEngineHostBase ,
25+ InvalidCollectionJsonException ,
2126 SchematicMissingFieldsException ,
2227} from './file-system-engine-host-base' ;
2328import { readJsonFile } from './file-system-utility' ;
@@ -77,7 +82,7 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
7782 if ( name . replace ( / \\ / , '/' ) . split ( '/' ) . length > ( name [ 0 ] == '@' ? 2 : 1 ) ) {
7883 try {
7984 collectionPath = this . _resolvePath ( name , process . cwd ( ) ) ;
80- } catch ( _ ) {
85+ } catch {
8186 }
8287 }
8388
@@ -102,7 +107,13 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
102107 return collectionPath ;
103108 }
104109 } catch ( e ) {
110+ if (
111+ e instanceof InvalidJsonCharacterException || e instanceof UnexpectedEndOfInputException
112+ ) {
113+ throw new InvalidCollectionJsonException ( name , collectionPath , e ) ;
114+ }
105115 }
116+
106117 throw new CollectionCannotBeResolvedException ( name ) ;
107118 }
108119
0 commit comments