File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -12,8 +12,13 @@ const BUILD_OPTIONS: BuildOptions = {
12
12
} ;
13
13
async function watchMain ( ) : Promise < BuildContext < BuildOptions > > {
14
14
const buildContext = await context ( BUILD_OPTIONS ) ;
15
- await buildContext . watch ( ) ;
16
- await buildContext . serve ( { servedir : "./dist/" } ) ;
15
+ try {
16
+ await buildContext . watch ( ) ;
17
+ await buildContext . serve ( { servedir : "./dist/" } ) ;
18
+ } catch ( error ) {
19
+ await buildContext . dispose ( ) ;
20
+ throw error ;
21
+ }
17
22
return buildContext ;
18
23
}
19
24
async function watchDictionary ( ) : Promise < number > {
Original file line number Diff line number Diff line change @@ -13,8 +13,10 @@ async function tryBuild(): Promise<void> {
13
13
}
14
14
}
15
15
if ( import . meta. main ) {
16
- const watcher = Deno . watchFs ( "./dictionary/dictionary" ) ;
16
+ await using stack = new AsyncDisposableStack ( ) ;
17
+ using watcher = Deno . watchFs ( "./dictionary/dictionary" ) ;
17
18
let task = Promise . resolve ( ) ;
19
+ stack . defer ( async ( ) => await task ) ;
18
20
const buildDebounced = debounce ( ( ) => {
19
21
task = task . then ( tryBuild ) ;
20
22
} , 200 ) ;
You can’t perform that action at this time.
0 commit comments