feat: use chokidar v4 (#622)

This commit is contained in:
pengzhanbo 2025-06-19 19:27:06 +08:00 committed by GitHub
parent 338334f479
commit 6f15557f11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 18 additions and 10 deletions

View File

@ -35,9 +35,10 @@ export function searchPlugin({
onPrepared: app => prepareSearchIndex({ app, isSearchable, searchOptions }),
onWatched: (app, watchers) => {
const searchIndexWatcher = chokidar.watch('pages/**/*.js', {
const searchIndexWatcher = chokidar.watch('pages', {
cwd: app.dir.temp(),
ignoreInitial: true,
ignored: (filepath, stats) => Boolean(stats?.isFile()) && !filepath.endsWith('.js'),
})
searchIndexWatcher.on('add', (filepath) => {
onSearchIndexUpdated(filepath, { app, isSearchable, searchOptions })

10
pnpm-lock.yaml generated
View File

@ -201,8 +201,8 @@ catalogs:
specifier: ^4.5.0
version: 4.5.0
chokidar:
specifier: 3.6.0
version: 3.6.0
specifier: 4.0.3
version: 4.0.3
create-filter:
specifier: ^1.1.0
version: 1.1.0
@ -628,7 +628,7 @@ importers:
version: 13.3.0(vue@3.5.17(typescript@5.8.3))
chokidar:
specifier: catalog:prod
version: 3.6.0
version: 4.0.3
esbuild:
specifier: ^0.25.5
version: 0.25.5
@ -728,7 +728,7 @@ importers:
version: 13.3.0(axios@1.8.3)(focus-trap@7.6.5)(vue@3.5.17(typescript@5.8.3))
chokidar:
specifier: catalog:prod
version: 3.6.0
version: 4.0.3
focus-trap:
specifier: catalog:prod
version: 7.6.5
@ -830,7 +830,7 @@ importers:
version: 7.1.0
chokidar:
specifier: catalog:prod
version: 3.6.0
version: 4.0.3
create-filter:
specifier: catalog:prod
version: 1.1.0

View File

@ -82,7 +82,7 @@ catalogs:
bcrypt-ts: ^7.1.0
cac: ^6.7.14
chart.js: ^4.5.0
chokidar: 3.6.0
chokidar: 4.0.3
create-filter: ^1.1.0
dayjs: ^1.11.13
echarts: ^5.6.0

View File

@ -115,10 +115,16 @@ export async function watchAutoFrontmatter(app: App, watchers: any[]): Promise<v
if (!generate)
return
const watcher = chokidar.watch('**/*.md', {
const watcher = chokidar.watch('.', {
cwd: app.dir.source(),
ignoreInitial: true,
ignored: /(node_modules|\.vuepress)\//,
ignored: (filepath, stats) => {
if (filepath.includes('node_modules'))
return true
if (filepath.includes('.vuepress'))
return true
return Boolean(stats?.isFile()) && !filepath.endsWith('.md')
},
})
watcher.on('add', async (relativePath) => {

View File

@ -25,9 +25,10 @@ export function watchPrepare(
app: App,
watchers: any[],
): void {
const pagesWatcher = watch('pages/**/*.js', {
const pagesWatcher = watch('pages', {
cwd: app.dir.temp(),
ignoreInitial: true,
ignored: (filepath, stats) => Boolean(stats?.isFile()) && !filepath.endsWith('.js'),
})
watchers.push(pagesWatcher)