Skip to content

Commit 2014b63

Browse files
committed
Fixed file watching for Chokidar 4
1 parent 25b2107 commit 2014b63

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

package-lock.json

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/build/_/index.ts

+12-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import * as fs from "fs/promises"
2525
import {
2626
EMPTY,
2727
Observable,
28-
concatAll,
2928
filter,
3029
from,
3130
fromEvent,
@@ -35,6 +34,7 @@ import {
3534
map,
3635
mergeWith,
3736
of,
37+
switchMap,
3838
tap
3939
} from "rxjs"
4040
import glob from "tiny-glob"
@@ -110,33 +110,34 @@ export function resolve(
110110
return from(glob(pattern, { dot: true, ...options }))
111111
.pipe(
112112
catchError(() => EMPTY),
113-
concatAll(),
113+
switchMap(files => from(files).pipe(
114+
115+
/* Start file watcher */
116+
options?.watch
117+
? mergeWith(watch(files, options))
118+
: identity
119+
)),
114120

115121
/* Build overrides */
116122
!process.argv.includes("--all")
117123
? filter(file => !file.startsWith(".overrides/"))
118124
: identity,
119-
120-
/* Start file watcher */
121-
options?.watch
122-
? mergeWith(watch(pattern, options))
123-
: identity
124125
)
125126
}
126127

127128
/**
128-
* Watch all files matching the given pattern
129+
* Watch all given files
129130
*
130-
* @param pattern - Pattern
131+
* @param files - Files
131132
* @param options - Options
132133
*
133134
* @returns File observable
134135
*/
135136
export function watch(
136-
pattern: string, options: WatchOptions
137+
files: string[], options: WatchOptions
137138
): Observable<string> {
138139
return fromEvent(
139-
chokidar.watch(pattern, options),
140+
chokidar.watch(files, options),
140141
"change", file => file // see https://t.ly/dli_k
141142
) as Observable<string>
142143
}

0 commit comments

Comments
 (0)