Skip to content

fix(CLI): reset crash on newer Node versions (rmdir → rm).#3695

Merged
adamziel merged 1 commit into
WordPress:trunkfrom
vipul0425:fix/cli-reset-rmdir-recursive-removed
May 28, 2026
Merged

fix(CLI): reset crash on newer Node versions (rmdir → rm).#3695
adamziel merged 1 commit into
WordPress:trunkfrom
vipul0425:fix/cli-reset-rmdir-recursive-removed

Conversation

@vipul0425

Copy link
Copy Markdown
Contributor

Motivation for the change, related issues

Fixes #3538

Implementation details

Node.js deprecated the { recursive: true } option of fs.rmdirSync() long ago and has since removed it. Replaced the call
fs.rmSync(..., { recursive: true, force: true }), the documented replacement.

Testing Instructions

On Node 25

# 1. Create the site first
npx @wp-playground/cli start --wp=6.9 --php=8.1

# 2. Re-run with --reset
npx @wp-playground/cli start --wp=6.9 --php=8.1 --reset

@vipul0425 vipul0425 requested review from a team, ashfame and Copilot May 28, 2026 09:18
@github-actions github-actions Bot added [Package][@wp-playground] CLI [Type] Bug An existing feature does not function as intended [Aspect] Node.js labels May 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the CLI reset behavior to avoid crashes on newer Node.js versions by replacing deprecated fs.rmdirSync(..., { recursive: true }) usage with fs.rmSync(...).

Changes:

  • Replace rmdirSync import with rmSync
  • Use rmSync(hostPath, { recursive: true, force: true }) when --reset is enabled

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1879 to 1883
if (existsSync(hostPath) && (args['reset'] as boolean)) {
cliOutput.print('Resetting site...');
rmdirSync(hostPath, { recursive: true });
rmSync(hostPath, { recursive: true, force: true });
}
mkdirSync(hostPath, { recursive: true });
@adamziel adamziel merged commit 7681a77 into WordPress:trunk May 28, 2026
53 checks passed
@adamziel

Copy link
Copy Markdown
Collaborator

Thank you @vipul0425!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Aspect] Node.js [Package][@wp-playground] CLI [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: Attempting to start with --reset causes error

3 participants