diff --git a/package-lock.json b/package-lock.json index 97a722af5..0fe28ebd6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3228,6 +3228,7 @@ "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dev": true, + "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", diff --git a/tools/build/_/index.ts b/tools/build/_/index.ts index 535ccce3e..22a644794 100644 --- a/tools/build/_/index.ts +++ b/tools/build/_/index.ts @@ -25,7 +25,6 @@ import * as fs from "fs/promises" import { EMPTY, Observable, - concatAll, filter, from, fromEvent, @@ -35,6 +34,7 @@ import { map, mergeWith, of, + switchMap, tap } from "rxjs" import glob from "tiny-glob" @@ -110,33 +110,34 @@ export function resolve( return from(glob(pattern, { dot: true, ...options })) .pipe( catchError(() => EMPTY), - concatAll(), + switchMap(files => from(files).pipe( + + /* Start file watcher */ + options?.watch + ? mergeWith(watch(files, options)) + : identity + )), /* Build overrides */ !process.argv.includes("--all") ? filter(file => !file.startsWith(".overrides/")) : identity, - - /* Start file watcher */ - options?.watch - ? mergeWith(watch(pattern, options)) - : identity ) } /** - * Watch all files matching the given pattern + * Watch all given files * - * @param pattern - Pattern + * @param files - Files * @param options - Options * * @returns File observable */ export function watch( - pattern: string, options: WatchOptions + files: string[], options: WatchOptions ): Observable { return fromEvent( - chokidar.watch(pattern, options), + chokidar.watch(files, options), "change", file => file // see https://t.ly/dli_k ) as Observable }