-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chore(deps): update chokidar to v4 #5374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
9492a00
184588d
970c353
d883a1a
3dd2b4b
a34faf6
7b113cf
b01a2c3
3374234
5d42bac
c5539b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ const schema = require("./options.json"); | |
/** @typedef {import("webpack").Stats} Stats */ | ||
/** @typedef {import("webpack").MultiStats} MultiStats */ | ||
/** @typedef {import("os").NetworkInterfaceInfo} NetworkInterfaceInfo */ | ||
/** @typedef {import("chokidar").WatchOptions} WatchOptions */ | ||
/** @typedef {import("chokidar").ChokidarOptions & { disableGlobbing?: boolean }} WatchOptions */ | ||
/** @typedef {import("chokidar").FSWatcher} FSWatcher */ | ||
/** @typedef {import("connect-history-api-fallback").Options} ConnectHistoryApiFallbackOptions */ | ||
/** @typedef {import("bonjour-service").Bonjour} Bonjour */ | ||
|
@@ -3255,9 +3255,65 @@ class Server { | |
* @param {string | string[]} watchPath | ||
* @param {WatchOptions} [watchOptions] | ||
*/ | ||
watchFiles(watchPath, watchOptions) { | ||
watchFiles(watchPath, watchOptions = {}) { | ||
const chokidar = require("chokidar"); | ||
const watcher = chokidar.watch(watchPath, watchOptions); | ||
|
||
const watchPathArr = Array.isArray(watchPath) ? watchPath : [watchPath]; | ||
|
||
if (watchOptions.disableGlobbing !== true) { | ||
const isGlob = require("is-glob"); | ||
const watchPathGlobs = watchPathArr.filter((p) => isGlob(p)); | ||
|
||
// No need to do all this work when no globs are used | ||
if (watchPathGlobs.length > 0) { | ||
const globParent = require("glob-parent"); | ||
const picomatch = require("picomatch"); | ||
|
||
watchPathGlobs.forEach((p) => { | ||
watchPathArr[watchPathArr.indexOf(p)] = globParent(p); | ||
}); | ||
|
||
const matcher = picomatch(watchPathGlobs, { | ||
cwd: watchOptions.cwd, | ||
dot: true, | ||
}); | ||
|
||
const ignoreFunc = (/** @type {string} */ p) => | ||
!watchPathArr.includes(p) && !matcher(p); | ||
|
||
const ignoredArr = Array.isArray(watchOptions.ignored) | ||
? watchOptions.ignored | ||
: []; | ||
|
||
// Nested ternaries are forbidden by eslint so we end up with this | ||
if (watchOptions.ignored && !Array.isArray(watchOptions.ignored)) { | ||
ignoredArr.push(watchOptions.ignored); | ||
} | ||
|
||
const ignoredGlobs = []; | ||
for (let i = 0; i < ignoredArr.length; i++) { | ||
const ignored = ignoredArr[i]; | ||
if (typeof ignored === "string" && isGlob(ignored)) { | ||
ignoredGlobs.push(ignored); | ||
ignoredArr.splice(i, 1); | ||
} | ||
Fuzzyma marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
|
||
if (ignoredGlobs.length > 0) { | ||
const ignoreMatcher = picomatch(ignoredGlobs, { | ||
dot: true, | ||
cwd: watchOptions.cwd, | ||
}); | ||
ignoredArr.push(ignoreMatcher); | ||
} | ||
|
||
ignoredArr.push(ignoreFunc); | ||
|
||
watchOptions.ignored = ignoredArr; | ||
|
||
} | ||
} | ||
|
||
const watcher = chokidar.watch(watchPathArr, watchOptions); | ||
|
||
// disabling refreshing on changing the content | ||
if (this.options.liveReload) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.