From e88e1fd94d7ad96d686f83efcda183eaf1c08d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ari=20Perkki=C3=B6?= Date: Mon, 7 Oct 2024 18:26:29 +0300 Subject: [PATCH] build: exclude snapshots from chokidar --- packages/astro/scripts/build.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/astro/scripts/build.js b/packages/astro/scripts/build.js index c0695a082..aa5f51306 100644 --- a/packages/astro/scripts/build.js +++ b/packages/astro/scripts/build.js @@ -65,14 +65,11 @@ async function copyDefaultFolder() { await rm(dist, { recursive: true, force: true }); // copy default folder unmodified, without test files - await cp(src, dist, { - recursive: true, - filter: (filename) => !filename.endsWith('.spec.ts') && !filename.includes('__snapshots__'), - }); + await cp(src, dist, { recursive: true, filter }); if (isWatch) { chokidar.watch(src).on('all', (event, filePath, stats) => { - if (stats?.isDirectory() !== true) { + if (stats?.isDirectory() !== true && filter(filePath)) { const target = path.join(dist, path.relative(src, filePath)); if (event === 'unlink') { @@ -83,4 +80,8 @@ async function copyDefaultFolder() { } }); } + + function filter(filename) { + return !filename.endsWith('.spec.ts') && !filename.includes('__snapshots__'); + } }