chore: replace rimraf with native fs.rm() - #2631
Conversation
Remove the rimraf package (and @types/rimraf) by replacing all usages with Node.js built-in fs.promises.rm(), which has been stable since Node 14.14.0. This removes one production dependency from the bundle. Source code: rimrafAsync in src/common/utils/utils.ts is now a thin wrapper around fs.promises.rm with recursive + force options and Windows-specific maxRetries for EPERM resilience. Test code: rmRecursive in tests/testutils.ts uses the same approach. npm scripts: clean/clean:deep now use scripts/clean.js, a zero-dependency Node script that handles both static paths and glob patterns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR removes direct usage of the rimraf package and replaces recursive deletions with Node’s built-in fs.rm() / fs.rmSync() to support dependency cleanup and simplify maintenance.
Changes:
- Replaced
rimrafusage in test utilities and common runtime utilities withfs.promises.rm(...). - Added a custom
scripts/clean.jsto replace therimrafCLI usage in npm scripts. - Removed
rimrafand@types/rimraffrompackage.json.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/testutils.ts | Switched test cleanup helper from rimraf to fs.promises.rm. |
| src/common/utils/utils.ts | Replaced rimrafAsync implementation with fs.promises.rm. |
| scripts/clean.js | Introduced a Node-based clean script to replace the rimraf CLI. |
| package.json | Dropped rimraf deps and updated clean scripts to use scripts/clean.js. |
| package-lock.json | Lockfile updated to reflect dependency removal and transitive changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await fsPromises.rm(path, { | ||
| recursive: true, | ||
| force: true, | ||
| maxRetries: process.platform === "win32" ? 10 : 0 | ||
| }); |
| await fsPromises.rm(path, { | ||
| recursive: true, | ||
| force: true, | ||
| maxRetries: process.platform === "win32" ? 10 : 0 | ||
| }); |
| function rm(target) { | ||
| try { | ||
| fs.rmSync(target, { recursive: true, force: true }); | ||
| } catch (err) { | ||
| if (err.code !== "ENOENT") { | ||
| console.error(`Warning: could not remove ${target}: ${err.message}`); | ||
| } | ||
| } |
| "clean": "node scripts/clean.js", | ||
| "clean:deep": "node scripts/clean.js --deep", |
|
|
@md84419, let's address all the issues in the Pull request first. |
|
@jainakanksha-msft rimraf 3.0.2 is a security vulnerability.
Eliminating the rimraf dependency removes that whole depdency chain and I assume the original author decided it was simpler and more maintainable than getting the code working with the latest rimraf. I guess the bigger question is, what would it take to release a version of azurite with 0 vulnerabilities?
|
Summary
rimrafdependency with Node.js built-infs.rm()with{ recursive: true, force: true }rimraffrompackage.jsondependenciesThis aligns with the e18e ecosystem cleanup initiative —
rimrafis a thin wrapper aroundfs.rm()which has been available since Node.js 14.14.0.Test plan
npm testpassesrimrafin source