File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import { unreachable } from "@std/assert/unreachable" ;
44import { debounce } from "@std/async/debounce" ;
5+ import { MuxAsyncIterator } from "@std/async/mux-async-iterator" ;
56import { build } from "./build.ts" ;
67import { Parser } from "./parallel_parser.ts" ;
78
9+ // deno-lint-ignore require-yield
10+ async function * errorOnly ( promise : Promise < never > ) : AsyncGenerator < never > {
11+ await promise ;
12+ unreachable ( ) ;
13+ }
814if ( import . meta. main ) {
9- await using stack = new AsyncDisposableStack ( ) ;
1015 using watcher = Deno . watchFs ( "./dictionary.txt" ) ;
1116 using parser = new Parser ( ) ;
17+
18+ const { promise, reject } = Promise . withResolvers < never > ( ) ;
19+ const errorGenerator = errorOnly ( promise ) ;
20+
1221 let task = Promise . resolve ( ) ;
13- stack . defer ( async ( ) => await task ) ;
1422 const buildDebounced = debounce ( ( ) => {
1523 task = task . then ( async ( ) => {
16- await build ( parser ) ;
24+ try {
25+ await build ( parser ) ;
26+ } catch ( error ) {
27+ reject ( error ) ;
28+ }
1729 } ) ;
1830 } , 200 ) ;
31+
32+ const watcherWithError = new MuxAsyncIterator < Deno . FsEvent > ( ) ;
33+ watcherWithError . add ( watcher ) ;
34+ watcherWithError . add ( errorGenerator ) ;
35+
1936 buildDebounced ( ) ;
2037 buildDebounced . flush ( ) ;
21- for await ( const _ of watcher ) {
38+ for await ( const _ of watcherWithError ) {
2239 buildDebounced ( ) ;
2340 }
2441 unreachable ( ) ;
You can’t perform that action at this time.
0 commit comments