@@ -68,7 +68,7 @@ function doRun(rootPath: string, file?: string) {
6868 runner . init ( ) ;
6969}
7070
71- function doInit ( _rootPath : string , projectName ?: string ) {
71+ async function doInit ( _rootPath : string , projectName ?: string ) {
7272 if ( ! projectName ) {
7373 cliLog . warn ( "Project name is required for initialization." ) ;
7474 Deno . exit ( 1 ) ;
@@ -117,9 +117,15 @@ function doInit(_rootPath: string, projectName?: string) {
117117 } ,
118118 } ) ,
119119 ) ;
120- proc . status . then ( ( status ) => {
120+ try {
121+ const status = await proc . status ;
121122 Deno . writeTextFileSync ( "main.ts" , makeMainFile ( projectName ) ) ;
122123 if ( status . success ) {
124+ const cmd = new Deno . Command ( Deno . execPath ( ) , {
125+ args : [ "cache" , "--reload" , "main.ts" ] ,
126+ } ) ;
127+ await cmd . output ( ) ;
128+
123129 cliLog . info ( [
124130 `Project ${ name } initialized successfully!` ,
125131 "" ,
@@ -131,10 +137,11 @@ function doInit(_rootPath: string, projectName?: string) {
131137 cliLog . error ( `Failed to initialize project ${ name } .` ) ;
132138 Deno . exit ( 1 ) ;
133139 }
134- } ) . catch ( ( err ) => {
135- cliLog . error ( `Error initializing project: ${ err . message } ` ) ;
140+ } catch ( err ) {
141+ const message = err instanceof Error ? err . message : String ( err ) ;
142+ cliLog . error ( `Error initializing project: ${ message } ` ) ;
136143 Deno . exit ( 1 ) ;
137- } ) ;
144+ }
138145}
139146
140147async function init ( ) {
@@ -156,7 +163,7 @@ async function init() {
156163 doRun ( rootPath , file ) ;
157164 break ;
158165 case "init" :
159- doInit ( rootPath , file ) ;
166+ await doInit ( rootPath , file ) ;
160167 break ;
161168 case "syncClient" :
162169 await syncEntryInterface ( ) ;
0 commit comments