Skip to content

Commit

Permalink
Only remove output directory files, not the directory (#969)
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis authored May 15, 2024
1 parent 77e4572 commit b923081
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/dirty-hounds-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sku': patch
---

When cleaning the build output directory, only delete files within the directory, rather than the entire directory
13 changes: 12 additions & 1 deletion packages/sku/lib/buildFileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@ const exists = require('./exists');
const copyDirContents = require('./copyDirContents');

const cleanTargetDirectory = async () => {
fs.rm(paths.target, { recursive: true, force: true });
const files = await new Fdir()
.withBasePath()
.withMaxDepth(1)
.withDirs()
// This glob pattern is used to exclude the target directory itself
.glob(`${paths.target}/*`)
.crawl(paths.target)
.withPromise();

for (const file of files) {
await fs.rm(file, { recursive: true, force: true });
}
};

const copyPublicFiles = async () => {
Expand Down

0 comments on commit b923081

Please sign in to comment.