Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
fix(docz-core): chokidar performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Sep 7, 2018
1 parent cc97ab6 commit 0c344d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/docz-core/src/DataServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export class DataServer {
if (this.server) {
this.server.on('connection', socket => {
const close = this.handleConnection(socket)
this.server && this.server.on('close', async () => close())

this.server!.on('close', async () => {
await close()
})
})
}
}
Expand Down
5 changes: 4 additions & 1 deletion packages/docz-core/src/states/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ const updateConfig = (config: Config) => async (p: Params) => {
export const state = (config: Config): State => ({
init: updateConfig(config),
update: async params => {
const watcher = chokidar.watch(finds('docz'))
const update = updateConfig(config)
const watcher = chokidar.watch(finds('docz'), {
cwd: paths.root,
persistent: true,
})

watcher.on('add', async () => update(params))
watcher.on('change', async () => update(params))
Expand Down
6 changes: 5 additions & 1 deletion packages/docz-core/src/states/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ const updateEntries = (entries: Entries) => async (p: Params) => {

export const state = (config: Config): State => {
const entries = new Entries(config)
const watcher = chokidar.watch(config.files, {
const src = path.relative(paths.root, config.src)
const files = path.join(src, config.files)
const watcher = chokidar.watch(files, {
cwd: paths.root,
ignored: /(^|[\/\\])\../,
persistent: true,
})

return {
Expand Down

0 comments on commit 0c344d8

Please sign in to comment.