File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
libs/plugin/src/generators/init Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import {
19
19
Project ,
20
20
PropertyAssignment ,
21
21
ScriptKind ,
22
+ StringLiteral ,
22
23
SyntaxKind ,
23
24
} from 'ts-morph' ;
24
25
import { addMetadataJson } from '../../utils' ;
@@ -259,9 +260,16 @@ export async function initGenerator(tree: Tree, options: InitGeneratorSchema) {
259
260
} ) ;
260
261
261
262
if ( templateUrlMetadata ) {
262
- const templateUrl = templateUrlMetadata . getInitializer ( ) . getText ( ) ;
263
- const templateUrlPath = join ( componentPath , templateUrl ) ;
264
- const templateContent = tree . read ( templateUrlPath , 'utf-8' ) ;
263
+ const templateUrl = (
264
+ templateUrlMetadata . getInitializer ( ) as StringLiteral | NoSubstitutionTemplateLiteral
265
+ ) . getLiteralValue ?.( ) ;
266
+
267
+ if ( ! templateUrl ) {
268
+ return await stopSetup ( tree , `Could not locate templateUrl in ${ componentPath } ` ) ;
269
+ }
270
+
271
+ const templateUrlPath = join ( dirname ( componentPath ) , templateUrl ) ;
272
+ const templateContent = tree . read ( templateUrlPath , 'utf8' ) ;
265
273
266
274
tree . write (
267
275
templateUrlPath ,
You can’t perform that action at this time.
0 commit comments