Skip to content

Commit

Permalink
chore: update chokidar to v4
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Dec 30, 2024
1 parent 241d17d commit 38a755e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 64 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"@types/node": "^22.10.2",
"@types/postcss-prefix-selector": "^1.16.3",
"@types/prompts": "^2.4.9",
"chokidar": "^3.6.0",
"chokidar": "^4.0.3",
"conventional-changelog-cli": "^5.0.0",
"cross-spawn": "^7.0.6",
"debug": "^4.4.0",
Expand Down Expand Up @@ -205,7 +205,7 @@
"optional": true
}
},
"packageManager": "[email protected].1",
"packageManager": "[email protected].2",
"pnpm": {
"peerDependencyRules": {
"ignoreMissing": [
Expand Down
79 changes: 20 additions & 59 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions scripts/watchAndCopy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { copy, remove } from 'fs-extra'
import { watch } from 'chokidar'
import { copy, remove } from 'fs-extra'
import { normalizePath } from 'vite'

function toClientAndNode(method, file) {
Expand All @@ -18,14 +18,19 @@ function toDist(file) {
}

// copy shared files to the client and node directory whenever they change.
watch('src/shared/**/*.ts')
watch('src/shared', {
ignored: (path, stats) => stats?.isFile() && !path.endsWith('.ts')
})
.on('change', (file) => toClientAndNode('copy', file))
.on('add', (file) => toClientAndNode('copy', file))
.on('unlink', (file) => toClientAndNode('remove', file))

// copy non ts files, such as an html or css, to the dist directory whenever
// they change.
watch('src/client/**/!(*.ts|tsconfig.json)')
watch('src/client', {
ignored: (path, stats) =>
stats?.isFile() && (path.endsWith('.ts') || path.endsWith('tsconfig.json'))
})
.on('change', (file) => copy(file, toDist(file)))
.on('add', (file) => copy(file, toDist(file)))
.on('unlink', (file) => remove(toDist(file)))

0 comments on commit 38a755e

Please sign in to comment.