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__'); + } }