mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-27 17:00:54 +01:00
Fixed file watching for Chokidar 4
This commit is contained in:
parent
25b2107b53
commit
2014b634e8
1
package-lock.json
generated
1
package-lock.json
generated
@ -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",
|
||||
|
@ -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<string> {
|
||||
return fromEvent(
|
||||
chokidar.watch(pattern, options),
|
||||
chokidar.watch(files, options),
|
||||
"change", file => file // see https://t.ly/dli_k
|
||||
) as Observable<string>
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user