GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: add recursive option to rmdir() by cjihrig · Pull Request #29168 · nodejs/node

Conversation

@cjihrig

@cjihrig cjihrig commented Aug 16, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This PR adds a recursive option to fs.rmdir(), fs.rmdirSync(), and fs.promises.rmdir(). The implementation is a port of the npm module rimraf. I added an option to rmdir() to match the approach taken with core's recursive mkdir().

This is my alternative to #28208 from #28208 (review).

I'm marking this PR as a work in progress, as I haven't added docs yet.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss, silverwind, gengjiawen, sindresorhus, ChALkeR, hakatashi, smockle, styfle, artyuum, saeta-eth, and 11 more reacted with heart emoji kaznovac and bl-ue reacted with rocket emoji
All reactions
  • ❤️ 21 reactions
  • 🚀 2 reactions
@nodejs-github-bot nodejs-github-bot added the lib / src Issues and PRs involving general changes in the lib/ or src/ directories. label Aug 16, 2019
@bcoe bcoe mentioned this pull request Aug 17, 2019
fs: implement fs.rmdir recurisve #28171
Closed
4 tasks done
@Trott

Trott commented Aug 18, 2019

Copy link
Copy Markdown
Member

FWIW, other than the docs and tests that need to be added, this looks good to me.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@silverwind

silverwind commented Aug 19, 2019

Copy link
Copy Markdown
Contributor

Liking this as well, good call with the lazy loading. Waiting for docs/tests as well. Maybe some of the edge cases like the Windows ones can be included in the tests as well, but it's not a strict requirement.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig
cjihrig force-pushed the rimraf branch 2 times, most recently from 97b7a02 to e293b5d Compare August 19, 2019 19:07
@cjihrig
cjihrig marked this pull request as ready for review August 19, 2019 19:09
@cjihrig

cjihrig commented Aug 19, 2019

Copy link
Copy Markdown
Contributor Author

OK, this is ready for review.

It occurred to me that we may want to mark this as experimental for a few releases. Any thoughts?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Aug 19, 2019

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/25108/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

silverwind
silverwind reviewed Aug 19, 2019
View reviewed changes
Comment thread lib/internal/fs/utils.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes Aug 19, 2019
View reviewed changes
@silverwind silverwind added the semver-minor PRs that contain new features and should be released in the next minor version. label Aug 19, 2019
silverwind
silverwind approved these changes Aug 19, 2019
View reviewed changes
Trott
Trott reviewed Aug 20, 2019
View reviewed changes
Comment thread doc/api/fs.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Trott
Trott reviewed Aug 20, 2019
View reviewed changes
Comment thread doc/api/fs.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Trott
Trott reviewed Aug 20, 2019
View reviewed changes
Comment thread doc/api/fs.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Aug 20, 2019

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/25124/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig
cjihrig force-pushed the rimraf branch from 2a2fbd8 to 28dab64 Compare August 20, 2019 15:52
@nodejs-github-bot

nodejs-github-bot commented Aug 20, 2019 •
edited by cjihrig
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/25126/

EDIT: CI was yellow.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig cjihrig added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Aug 20, 2019
@Trott Trott added the notable-change PRs with changes that should be highlighted in changelogs. label Aug 20, 2019
bcoe
bcoe approved these changes Aug 20, 2019
View reviewed changes

@bcoe bcoe left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Having thought about rimraf way too much over the last few months, I ultimately come around to liking the consistency that a recursive option introduces (in relation to our implementation of mkdir recursive)...

I think there's meat to the argument that this makes rmdir with an option combine both unlink and rmdir behavior, which is a bit weird, but I feel this is ultimately the better user experience.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread doc/api/fs.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/fs/rimraf.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/fs/rimraf.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/parallel/test-fs-rmdir-recursive.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

MylesBorins
MylesBorins reviewed Aug 20, 2019
View reviewed changes
Comment thread lib/internal/fs/rimraf.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Aug 20, 2019

Copy link
Copy Markdown
Member

We need to update license-builder.sh and re-run it?

cjihrig reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig
cjihrig force-pushed the rimraf branch from a93476b to a46d568 Compare August 20, 2019 19:17
Trott
Trott approved these changes Aug 20, 2019
View reviewed changes
@cjihrig cjihrig mentioned this pull request Aug 20, 2019
test: use fs rimraf to refresh tmpdir #29235
Closed
3 tasks done
jasnell
jasnell approved these changes Aug 20, 2019
View reviewed changes
gengjiawen
gengjiawen approved these changes Aug 21, 2019
View reviewed changes
@nodejs-github-bot

nodejs-github-bot commented Aug 21, 2019

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/25137/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Trott pushed a commit that referenced this pull request Aug 23, 2019
@cjihrig @Trott
fs: add recursive option to rmdir()
53816cc
This commit adds a recursive option to fs.rmdir(),
fs.rmdirSync(), and fs.promises.rmdir(). The implementation
is a port of the npm module rimraf.

PR-URL: #29168
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Ben Coe <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
@Trott

Trott commented Aug 23, 2019

Copy link
Copy Markdown
Member

Landed in 53816cc

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott Trott closed this Aug 23, 2019
@cjihrig
cjihrig deleted the rimraf branch August 23, 2019 21:36
@iansu iansu mentioned this pull request Aug 23, 2019
lib: port rimraf to core as shutil.rmtree #28208
Closed
2 of 5 tasks
@ljharb

ljharb commented Aug 24, 2019

Copy link
Copy Markdown
Member

Sorry i missed the PR; nobody posted a comment in #28208 indicating this one was opened.

Does this mean that to feature detect this option, i have to try/catch around passing the wrong type of options object into the sync function? Am i missing a less invasive mechanism?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Aug 24, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Sorry i missed the PR; nobody posted a comment in #28208 indicating this one was opened.

Does this mean that to feature detect this option, i have to try/catch around passing the wrong type of options object into the sync function? Am i missing a less invasive mechanism?

Correct. It's the same with the recursive option for mkdir(). We had a lot of discussion around feature detection for that, but when it came down to it, people either didn't need feature detection, kept using the mkdirp package, or did sniffing on process.version/process.versions.node . Not everyone was thrilled about version sniffing but no solution was going to make everyone happy (as the rest of that issue thread and others make clear) and it seems to be working out OK.

bcoe and ljharb reacted with thumbs up emoji ljharb reacted with confused emoji
All reactions
  • 👍 2 reactions
  • 😕 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BridgeAR pushed a commit that referenced this pull request Sep 3, 2019
@cjihrig @BridgeAR
fs: add recursive option to rmdir()
ed2293e
This commit adds a recursive option to fs.rmdir(),
fs.rmdirSync(), and fs.promises.rmdir(). The implementation
is a port of the npm module rimraf.

PR-URL: #29168
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Ben Coe <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
@BridgeAR BridgeAR mentioned this pull request Sep 3, 2019
v12.10.0 proposal #29429
Merged
BridgeAR added a commit that referenced this pull request Sep 3, 2019
@BridgeAR
2019-09-04, Version 12.10.0 (Current)
471f4a9
Notable changes:

* deps:
  * Update npm to 6.10.3 (isaacs)
    #29023
* fs:
  * Add recursive option to rmdir() (cjihrig)
    #29168
  * Allow passing true to emitClose option (Giorgos Ntemiris)
    #29212
  * Add \*timeNs properties to BigInt Stats objects (Joyee Cheung)
    #21387
* net:
  * Allow reading data into a static buffer (Brian White)
    #25436

PR-URL: #29429
BridgeAR added a commit that referenced this pull request Sep 4, 2019
@BridgeAR
2019-09-04, Version 12.10.0 (Current)
3a2e75d
Notable changes:

* deps:
  * Update npm to 6.10.3 (isaacs)
    #29023
* fs:
  * Add recursive option to rmdir() (cjihrig)
    #29168
  * Allow passing true to emitClose option (Giorgos Ntemiris)
    #29212
  * Add \*timeNs properties to BigInt Stats objects (Joyee Cheung)
    #21387
* net:
  * Allow reading data into a static buffer (Brian White)
    #25436

PR-URL: #29429
BridgeAR added a commit that referenced this pull request Sep 4, 2019
@BridgeAR
2019-09-04, Version 12.10.0 (Current)
02c74e7
Notable changes:

* deps:
  * Update npm to 6.10.3 (isaacs)
    #29023
* fs:
  * Add recursive option to rmdir() (cjihrig)
    #29168
  * Allow passing true to emitClose option (Giorgos Ntemiris)
    #29212
  * Add \*timeNs properties to BigInt Stats objects (Joyee Cheung)
    #21387
* net:
  * Allow reading data into a static buffer (Brian White)
    #25436

PR-URL: #29429
@mysticatea

mysticatea commented Sep 4, 2019

Copy link
Copy Markdown

Does this mean that to feature detect this option, i have to try/catch around passing the wrong type of options object into the sync function?

I guess fs.rmdirSync.length can be used to detect because the number of arguments was changed.

ljharb and styfle reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iansu iansu mentioned this pull request Sep 6, 2019
Implement shutil in Node.js core nodejs/tooling#23
Closed
@SimonSchick SimonSchick mentioned this pull request Sep 16, 2019
Add note that module is now shipped in node by default. isaacs/rimraf#204
Closed
@richardlau richardlau mentioned this pull request Nov 7, 2019
An optional parameter that lets us delete folders that aren't empty directly #22686
Closed
@ntwb ntwb mentioned this pull request Nov 28, 2019
Package: Replace fs-extra with rimraf. WordPress/gutenberg#18790
Merged
@silverwind

silverwind commented May 11, 2020

Copy link
Copy Markdown
Contributor

Any chance of a backport to v10 for this (asking for sindresorhus/del#124)?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@silverwind silverwind mentioned this pull request May 11, 2020
Cannot delete dirs containing files with invalid UTF8 sequences in their name sindresorhus/del#124
Closed
@MylesBorins

MylesBorins commented May 11, 2020 via email

Copy link
Copy Markdown
Contributor
10.x is in maintenance already so I think we missed the boat to do another semver minor
…
On Mon, May 11, 2020, 11:02 AM silverwind ***@***.***> wrote: Any chance of a backport to v10 for this (asking for sindresorhus/del#124 <sindresorhus/del#124>)? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#29168 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AADZYV26DAS6E6RI276YBYTRRAHQXANCNFSM4IMMFUTA> .
silverwind reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@silverwind

silverwind commented May 11, 2020

Copy link
Copy Markdown
Contributor

Fine with me. Agree it would be odd to add features like this so late in the cycle.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@RyanZim RyanZim mentioned this pull request Jun 3, 2020
Recursive fs.rmdir / fs.rm jprichardson/node-fs-extra#806
Closed
@bcoe bcoe mentioned this pull request Jul 11, 2020
Rethink recursive flag (and design more generally) for fs.rmdir #34278
Closed
@bcoe bcoe mentioned this pull request Sep 13, 2020
fs: remove experimental language from rmdir recursive #35171
Closed
4 tasks done
@aduh95 aduh95 mentioned this pull request Jun 2, 2021
fs: stop fixing EPERM on Windows #38810
Closed
@live627 live627 mentioned this pull request Jan 23, 2022
Consider replacing del with its dependency rimraf avajs/ava#2952
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jasnell jasnell jasnell approved these changes
@Trott Trott Trott approved these changes
@gengjiawen gengjiawen gengjiawen approved these changes
+4 more reviewers
@silverwind silverwind silverwind approved these changes
@bcoe bcoe bcoe approved these changes
@MylesBorins MylesBorins MylesBorins left review comments
@vsemozhetbyt vsemozhetbyt vsemozhetbyt left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. notable-change PRs with changes that should be highlighted in changelogs. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

11 participants

@cjihrig @Trott @silverwind @nodejs-github-bot @ljharb @mysticatea @MylesBorins @bcoe @jasnell @gengjiawen @vsemozhetbyt
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.