Skip to content

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

Open
bcomnes wants to merge 3 commits into
masterfrom
bret/clean-build-destination
Open

bcomnes wants to merge 3 commits 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.

@bcomnes
bcomnes marked this pull request as ready for review November 24, 2026 05:41
Comment thread docs/api/README.md Resolved
Comment thread docs/cli/README.md Resolved
Comment thread lib/cli/watch-build.js Resolved
Comment thread lib/helpers/clean-dest.js Resolved
Comment thread README.md Resolved
@coveralls

coveralls commented Nov 24, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 45448922778

Coverage increased (+0.02%) to 96.472%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 6 uncovered changes across 1 file (107 of 113 lines covered, 94.69%).
  • 9 coverage regressions across 1 file.

Uncovered Changes

File Changed Covered %
lib/helpers/clean-dest.js 79 73 92.41%
Total (5 files) 113 107 94.69%

Coverage Regressions

9 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
lib/cli/sessions.js 9 52.27%

Coverage Stats

Coverage Status
Relevant Lines: 13123
Covered Lines: 12821
Line Coverage: 97.7%
Relevant Branches: 4508
Covered Branches: 4188
Branch Coverage: 92.9%
Branches in Coverage %: Yes
Coverage Strength: 1089.04 hits per line

💛 - Coveralls

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