Skip to content

Commit 6f5195e

Browse files
authored
build: exclude snapshots from chokidar (#364)
1 parent 0510474 commit 6f5195e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/astro/scripts/build.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,11 @@ async function copyDefaultFolder() {
6565
await rm(dist, { recursive: true, force: true });
6666

6767
// copy default folder unmodified, without test files
68-
await cp(src, dist, {
69-
recursive: true,
70-
filter: (filename) => !filename.endsWith('.spec.ts') && !filename.includes('__snapshots__'),
71-
});
68+
await cp(src, dist, { recursive: true, filter });
7269

7370
if (isWatch) {
7471
chokidar.watch(src).on('all', (event, filePath, stats) => {
75-
if (stats?.isDirectory() !== true) {
72+
if (stats?.isDirectory() !== true && filter(filePath)) {
7673
const target = path.join(dist, path.relative(src, filePath));
7774

7875
if (event === 'unlink') {
@@ -83,4 +80,8 @@ async function copyDefaultFolder() {
8380
}
8481
});
8582
}
83+
84+
function filter(filename) {
85+
return !filename.endsWith('.spec.ts') && !filename.includes('__snapshots__');
86+
}
8687
}

0 commit comments

Comments
 (0)