FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fs: add recursive option to rmdir() by cjihrig · Pull Request #29168 · nodejs/node · GitHub

/ node Public

fs: add recursive option to rmdir() - #29168

Closed
cjihrig wants to merge 3 commits into
nodejs:masterfrom
cjihrig:rimraf
Closed

fs: add recursive option to rmdir()#29168
cjihrig wants to merge 3 commits into
nodejs:masterfrom
cjihrig:rimraf

Conversation

cjihrig commented Aug 16, 2019
edited
Loading

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

nodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Aug 16, 2019
bcoe mentioned this pull request Aug 17, 2019
4 tasks

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.

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.

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

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?

Copy link
Copy Markdown
Collaborator

Comment thread lib/internal/fs/utils.js Outdated
silverwind added the semver-minor PRs that contain new features and should be released in the next minor version. label Aug 19, 2019
Comment thread doc/api/fs.md Outdated
Comment thread doc/api/fs.md Outdated
Comment thread doc/api/fs.md Outdated

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Collaborator

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

EDIT: CI was yellow.

cjihrig added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Aug 20, 2019
Trott added the notable-change PRs with changes that should be highlighted in changelogs. label Aug 20, 2019

bcoe 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Comment thread doc/api/fs.md Outdated
Comment thread lib/internal/fs/rimraf.js Outdated
Comment thread lib/internal/fs/rimraf.js Outdated
Comment thread lib/internal/fs/rimraf.js Outdated

Trott commented Aug 20, 2019

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Collaborator

Trott pushed a commit that referenced this pull request Aug 23, 2019
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 <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>

Trott commented Aug 23, 2019

Copy link
Copy Markdown
Member

Landed in 53816cc

Trott closed this Aug 23, 2019
cjihrig deleted the rimraf branch August 23, 2019 21:36

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?

Trott commented Aug 24, 2019
edited
Loading

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.

BridgeAR pushed a commit that referenced this pull request Sep 3, 2019
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 <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
BridgeAR mentioned this pull request Sep 3, 2019
BridgeAR added a commit that referenced this pull request Sep 3, 2019
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
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
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

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.

Copy link
Copy Markdown
Contributor

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

MylesBorins commented May 11, 2020 via email

Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor

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

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. lib / src Issues and PRs related to general changes in the lib or src directory. 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

Development

Successfully merging this pull request may close these issues.


Back | FazBrowse Home | New Git URL