Skip to content

Commit 48ca2d1

Browse files
committed
fix: watcher ignore patterns
1 parent 7677a89 commit 48ca2d1

File tree

3 files changed

+10
-35
lines changed

3 files changed

+10
-35
lines changed

deno.lock

Lines changed: 3 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ export { serveDir, type ServeDirOptions, STATUS_CODE, STATUS_TEXT, type StatusCo
44
export { toFileUrl } from 'jsr:@std/path@^1.0.9'
55
export { normalize as posixNormalize } from 'jsr:@std/path@^1.0.9/posix/normalize'
66
export { escape } from 'jsr:@std/regexp@^1.0.1'
7-
export { default as watcher } from 'npm:@brc-dd/[email protected]0'
7+
export { subscribe } from 'npm:@brc-dd/[email protected]2'
88
export type { ZodType } from 'npm:zod@^3.24.3'

src/router.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ import {
3030
STATUS_CODE,
3131
STATUS_TEXT,
3232
type StatusCode,
33+
subscribe,
3334
toFileUrl,
3435
walk,
35-
watcher,
3636
} from '../deps.ts'
3737

3838
const methods = new Set(['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'PATCH'])
39+
const watchOpts = Object.freeze({
40+
ignoreGlobs: [/^(?:.*?\/)?(?:(?:_|\.|node_modules\/|coverage\/).*|.*\.d\.ts)$/.source],
41+
})
3942

4043
type Awaitable<T> = T | Promise<T>
4144
type Params = Record<string, string | string[]>
@@ -311,9 +314,9 @@ export async function createRouter(
311314
}, 100)
312315

313316
if (dev) {
314-
const subscription = await watcher.subscribe(fsRoot, (_, events) => {
317+
const subscription = await subscribe(fsRoot, (_, events) => {
315318
if (events.some((e) => e.type === 'create' || e.type === 'delete')) reloadRouter()
316-
}, { ignore: ['**/*.d.ts', '**/_*', '**/.*', '**/coverage/**', '**/node_modules/**'] })
319+
}, watchOpts)
317320
addEventListener('unload', subscription.unsubscribe)
318321
}
319322

0 commit comments

Comments
 (0)