Skip to content

Commit

Permalink
fix: access the private property properly
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman committed Mar 31, 2024
1 parent 1f3cd68 commit 0cab666
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/watcher.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import chokidar from 'chokidar'
import type { ContextManager } from './lib/ContextManager.js'
import { existsSync } from 'node:fs'
import glob from 'tiny-glob'
import path from 'node:path'
import glob from 'tiny-glob'

export type WatchEvent = {
type: string
Expand Down Expand Up @@ -38,12 +37,15 @@ export const createContextWatcher = (context: ContextRebuilder) => {
cb()
}
}

const builder = () => context.build.bind(context)

return (globPattern, { root, onEvent, onBuild }: Options = { root: '.' }) => {
syncify(globPattern, root, () => {
watchers.forEach(w => {
w.addListener('all', (type, file) => {
if (!onEvent) {
return forcePromise(context.build).then(() => {
return forcePromise(builder).then(() => {
onBuild?.()
})
}
Expand All @@ -53,7 +55,7 @@ export const createContextWatcher = (context: ContextRebuilder) => {
})

if (!build) return
return forcePromise(context.build).then(() => {
return forcePromise(builder).then(() => {
onBuild?.()
})
})
Expand Down

0 comments on commit 0cab666

Please sign in to comment.