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 {
1919 Project ,
2020 PropertyAssignment ,
2121 ScriptKind ,
22+ StringLiteral ,
2223 SyntaxKind ,
2324} from 'ts-morph' ;
2425import { addMetadataJson } from '../../utils' ;
@@ -259,9 +260,16 @@ export async function initGenerator(tree: Tree, options: InitGeneratorSchema) {
259260 } ) ;
260261
261262 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' ) ;
265273
266274 tree . write (
267275 templateUrlPath ,
You can’t perform that action at this time.
0 commit comments