5
5
* Use of this source code is governed by an MIT-style license that can be
6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
- import { BaseException } from '@angular-devkit/core' ;
8
+ import {
9
+ BaseException ,
10
+ InvalidJsonCharacterException ,
11
+ UnexpectedEndOfInputException ,
12
+ } from '@angular-devkit/core' ;
9
13
import * as core from '@angular-devkit/core/node' ;
10
14
import { dirname , join , resolve as resolvePath } from 'path' ;
11
15
import { RuleFactory } from '../src' ;
@@ -18,6 +22,7 @@ import {
18
22
CollectionCannotBeResolvedException ,
19
23
CollectionMissingSchematicsMapException ,
20
24
FileSystemEngineHostBase ,
25
+ InvalidCollectionJsonException ,
21
26
SchematicMissingFieldsException ,
22
27
} from './file-system-engine-host-base' ;
23
28
import { readJsonFile } from './file-system-utility' ;
@@ -77,7 +82,7 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
77
82
if ( name . replace ( / \\ / , '/' ) . split ( '/' ) . length > ( name [ 0 ] == '@' ? 2 : 1 ) ) {
78
83
try {
79
84
collectionPath = this . _resolvePath ( name , process . cwd ( ) ) ;
80
- } catch ( _ ) {
85
+ } catch {
81
86
}
82
87
}
83
88
@@ -102,7 +107,13 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
102
107
return collectionPath ;
103
108
}
104
109
} catch ( e ) {
110
+ if (
111
+ e instanceof InvalidJsonCharacterException || e instanceof UnexpectedEndOfInputException
112
+ ) {
113
+ throw new InvalidCollectionJsonException ( name , collectionPath , e ) ;
114
+ }
105
115
}
116
+
106
117
throw new CollectionCannotBeResolvedException ( name ) ;
107
118
}
108
119
0 commit comments