Skip to content

Clean destination contents before full builds with safeguards and opt-out - #359

Closed
bcomnes wants to merge 1 commit into
masterfrom
bret/clean-build-destination
Closed

bcomnes wants to merge 1 commit into
masterfrom
bret/clean-build-destination

Conversation

@bcomnes

@bcomnes bcomnes commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Deleting or renaming a source file can leave stale pages and assets in the destination that later get deployed. Full builds now empty the destination before writing output, including hidden files, while preserving the directory itself and its permissions.

Add --no-clean on the CLI and { clean: false } in the API to preserve existing destination contents. The opt-out also works with --replace-watch; delegated builds reject incompatible flags instead of silently ignoring them. Watch rebuilds retain their targeted cleanup.

Cleanup runs under the destination claim, rejects filesystem roots (including normalized paths and symlink aliases), protects source/copy inputs and the working directory, and refuses destinations that changed after claiming. Root guards also run inside the destructive helper itself. Child symlinks are unlinked without following their targets. If a full build fails after cleanup, previous output is not restored.

Validation: all 1,015 Node tests pass with TMPDIR=/private/tmp, along with ESLint and the TypeScript check. Coverage includes preserved directory permissions, stale and hidden files, root paths, symlink aliases, competing destination claims, CLI/API opt-out behavior, and replacing an active watcher with cleanup enabled or disabled. Root regression tests block directory reads and deletion so a missing guard cannot make the tests destructive.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 45329573313

Warning

No base build found for commit 3007e63 on master.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 96.567%

Details

  • Patch coverage: 1 uncovered change across 1 file (75 of 76 lines covered, 98.68%).

Uncovered Changes

File Changed Covered %
lib/helpers/clean-dest.js 44 43 97.73%
Total (5 files) 76 75 98.68%

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 13086
Covered Lines: 12798
Line Coverage: 97.8%
Relevant Branches: 4506
Covered Branches: 4190
Branch Coverage: 92.99%
Branches in Coverage %: Yes
Coverage Strength: 1074.04 hits per line

💛 - Coveralls

@bcomnes bcomnes closed this Nov 24, 2026
@bcomnes
bcomnes deleted the bret/clean-build-destination branch November 24, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants