Skip to content

chore(deps): remove rimraf devDependency#5775

Open
roli-lpci wants to merge 1 commit intomochajs:mainfrom
roli-lpci:chore/remove-rimraf
Open

chore(deps): remove rimraf devDependency#5775
roli-lpci wants to merge 1 commit intomochajs:mainfrom
roli-lpci:chore/remove-rimraf

Conversation

@roli-lpci
Copy link

@roli-lpci roli-lpci commented Feb 28, 2026

PR Checklist

Overview

Remove rimraf devDependency, replace with native fs.rmSync (stable since Node.js 14.14).

Changes

  • test/integration/init.spec.js — Replace rimraf.sync(tmpdir) with fs.rmSync(tmpdir, { recursive: true, force: true })
  • package.json — Replace rimraf CLI in clean and test-coverage-clean scripts with cross-platform node -e one-liners; remove rimraf from devDependencies
  • package-lock.json — Regenerated

Testing

  • npm run clean — works correctly
  • npm run test-coverage-clean — works correctly
  • test/integration/init.spec.js — 3/3 passing
  • Unit tests — 1103 passing

Replace `rimraf.sync()` with native `fs.rmSync()` in the init integration
test. `fs.rmSync` with `{ recursive: true, force: true }` has been stable
since Node.js 14.14.0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 28, 2026

👋 Hi @roli-lpci, thanks for the pull request! A scan flagged a concern with it. Could you please take a look?

[pr-task-completion] This PR's body is missing [x] checks on the following tasks from the PR template.

Repositories often provide a set of tasks that pull request authors are expected to complete. Those tasks should be marked as completed with a [x] in the pull request description. Please complete those tasks and mark the checks as [x] completed.

🗺️ This message was posted automatically by OctoGuide: a bot for GitHub repository best practices.

@mark-wiemer
Copy link
Member

Thanks! I'll quickly note that all maintainers are pretty busy this month, but I'll get to this next weekend (if not this one!)

@mark-wiemer mark-wiemer added the status: needs review a maintainer should (re-)review this pull request label Feb 28, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Removes the rimraf devDependency and replaces its usages with Node’s built-in fs.rmSync, reducing external tooling for cleanup operations.

Changes:

  • Replaced rimraf.sync() with fs.rmSync(..., { recursive: true, force: true }) in an integration test cleanup hook
  • Replaced rimraf-based npm scripts with node -e cleanup one-liners
  • Removed rimraf from devDependencies and updated package-lock.json accordingly

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/integration/init.spec.js Uses fs.rmSync for temp directory cleanup instead of rimraf
package.json Removes rimraf devDependency; updates clean and test-coverage-clean scripts to use fs.rmSync
package-lock.json Drops top-level rimraf package; lockfile regenerated to reflect dependency graph

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

"scripts": {
"build": "rollup -c ./rollup.config.mjs",
"clean": "rimraf mocha.js mocha.js.map",
"clean": "node -e \"const fs=require('fs');['mocha.js','mocha.js.map'].forEach(f=>{try{fs.rmSync(f)}catch{}})\"",
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

The new clean script swallows all fs.rmSync errors, which means npm run clean will exit successfully even if deletion fails for reasons other than a missing file (e.g., permissions/locked file). This can leave stale artifacts around and make failures harder to diagnose. Consider using fs.rmSync(path, { force: true }) (no try/catch needed for non-existent paths) or only suppressing ENOENT and rethrowing other errors.

Suggested change
"clean": "node -e \"const fs=require('fs');['mocha.js','mocha.js.map'].forEach(f=>{try{fs.rmSync(f)}catch{}})\"",
"clean": "node -e \"const fs=require('fs');['mocha.js','mocha.js.map'].forEach(f=>fs.rmSync(f,{force:true}))\"",

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

I like this suggestion, @roli-lpci let me know your thoughts :)

"test-browser:webpack-compat": "webpack --mode development --config ./test/browser-specific/fixtures/webpack/webpack.config.js",
"test-browser": "run-s clean build test-browser:*",
"test-coverage-clean": "rimraf .nyc_output coverage",
"test-coverage-clean": "node -e \"['.nyc_output','coverage'].forEach(d=>{try{require('fs').rmSync(d,{recursive:true,force:true})}catch{}})\"",
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

test-coverage-clean catches and ignores any rmSync failure, so the script can report success even when .nyc_output/coverage couldn't be removed. Since rmSync is already called with { recursive: true, force: true } (which avoids ENOENT), consider removing the blanket try/catch (or only ignoring ENOENT) so real cleanup failures still fail the script.

Suggested change
"test-coverage-clean": "node -e \"['.nyc_output','coverage'].forEach(d=>{try{require('fs').rmSync(d,{recursive:true,force:true})}catch{}})\"",
"test-coverage-clean": "node -e \"['.nyc_output','coverage'].forEach(d=>require('fs').rmSync(d,{recursive:true,force:true}))\"",

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Feb 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.74%. Comparing base (5905ed9) to head (6d26a63).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5775   +/-   ##
=======================================
  Coverage   88.74%   88.74%           
=======================================
  Files          66       66           
  Lines        4744     4744           
  Branches      976      976           
=======================================
  Hits         4210     4210           
  Misses        534      534           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

-1 from me. Using node -e "..." in scripts is a lot of work and prone to error. The rimraf devDependency does the job well.

The e18e cleanup initiative is great for packages shipped to end-users. But rimraf is just a devDependency for Mocha. This does nothing for end-users and at best would be a fraction of a percent cleaner for Mocha developers. I don't think this PR is worth consideration.

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

Labels

status: needs review a maintainer should (re-)review this pull request

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants