@@ -52,7 +52,7 @@ export class Project {
5252 #fsWatchListeners: Array < EventEmitter > = [ ]
5353 #renderer: Renderer = { renderPage : ( ) => void 0 , renderHead : ( ) => void 0 }
5454
55- constructor ( dir : string , mode : 'development' | 'production' ) {
55+ constructor ( dir : string , mode : 'development' | 'production' , reload = false ) {
5656 this . mode = mode
5757 this . appRoot = dir
5858 this . config = {
@@ -75,7 +75,7 @@ export class Project {
7575 this . ready = ( async ( ) => {
7676 const t = performance . now ( )
7777 await this . _loadConfig ( )
78- await this . _init ( )
78+ await this . _init ( reload )
7979 log . debug ( 'initialize project token ' + Math . round ( performance . now ( ) - t ) + 'ms' )
8080 } ) ( )
8181 }
@@ -471,7 +471,7 @@ export class Project {
471471 this . #routing = new Routing ( [ ] , this . config . baseUrl , this . config . defaultLocale , this . config . locales )
472472 }
473473
474- private async _init ( ) {
474+ private async _init ( reload : boolean ) {
475475 const walkOptions = { includeDirs : false , exts : [ '.js' , '.ts' , '.mjs' ] , skip : [ / ^ \. / , / \. d \. t s $ / i, / \. ( t e s t | s p e c | e 2 e ) \. m ? ( j | t ) s x ? $ / i] }
476476 const apiDir = path . join ( this . srcDir , 'api' )
477477 const pagesDir = path . join ( this . srcDir , 'pages' )
@@ -480,6 +480,13 @@ export class Project {
480480 log . fatal ( `'pages' directory not found.` )
481481 }
482482
483+ if ( reload ) {
484+ if ( existsDirSync ( this . buildDir ) ) {
485+ await Deno . remove ( this . buildDir , { recursive : true } )
486+ }
487+ await ensureDir ( this . buildDir )
488+ }
489+
483490 Object . assign ( globalThis , {
484491 ALEPH : {
485492 env : this . config . env ,
0 commit comments