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 — lib: port rimraf to core as shutil.rmtree by iansu · Pull Request #28208 · nodejs/node

Conversation

@iansu

@iansu iansu commented Jun 13, 2019 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

The @nodejs/tooling group has been working on porting rimraf into Node.js Core: nodejs/tooling#13. We've spoken with @isaacs and this is done with his cooperation: iansu#1 (comment). We've chosen to implement this in a new module called shutil rather than adding it to the existing fs.rmdir code. There seems to be interest in this as a similar PR was recently opened: #28171.

1. Why?

rimraf is one of the most popular third-party modules and is used in millions of projects. The Tooling Group thinks this kind of commonly used module should be included in Node.js Core and not require a third-party package.

2. Why not add a recursive option to fs.rmdir?

By adding a flag rather than a new function feature detection becomes difficult. People have requested a way to detect the recursive option of mkdir for example.

3. Why port rimraf directly?

The rimraf code contains a number of workarounds for bugs and edge cases in platforms like Windows and sunos. These are the result of many issues and bugfixes over the years and we don't want to lose this functionality.

4. Why shutil?

The name itself comes from Python. Something like rimraf is not a filesystem primitive, instead it's an algorithm that is built on top of filesystem primitives. On other platforms these kind of utilities are often grouped under a "shell" namespace, and the Tooling team can imagine several additional utilities added to this module in the future.

5. Why is this not implemented in C++?

Like the recursive mkdir operation, recursive rmdir is not atomic. Unlike recursive mkdir, the number of operations is not bounded by the directory depth; instead, it's one operation for each file and directory encountered. Recursive mkdir cannot run its operations in parallel, either; it must create directories in serial, in descending order.

Recursive rmdir, on the other hand, would benefit from removing files in parallel--userland rimraf takes this strategy to remove files quickly as libuv's fs thread pool can handle it. There's no precedent, AFAIK, for running batch operations across multiple libuv threads in Node.js core. The problem is compounded by the necessity to implement a synchronous version of the API; consider execSync's implementation.

Several attempts have been made at implementing recursive rmdir in C++, but none so far have executed these operations using multiple threads. Because of this, a serial C++ implementation is significantly slower (@boneskull benchmarked his own implementation against userland rimraf) than a parallel, JS implementation.

In addition, a C++ implementation would need to consider the workarounds for various filesystems to provide a builtin on-par with userland rimraf. So far, no C++ implementation has attempted this.

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
  • add rimraf license to combined license

Sorry, something went wrong.

Uh oh!

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

silverwind, RichiCoder1, cvx, jefrydco, niktekusho, shqld, and kaznovac reacted with thumbs up emoji YurySolovyov reacted with thumbs down emoji boneskull, bcoe, johnnyreilly, ruyadorno, zero1five, sindresorhus, octet-stream, jefrydco, niktekusho, and shqld reacted with hooray emoji kaznovac reacted with heart emoji kaznovac reacted with rocket emoji
All reactions
  • 👍 7 reactions
  • 👎 1 reaction
  • 🎉 10 reactions
  • ❤️ 1 reaction
  • 🚀 1 reaction
iansu added 6 commits June 13, 2019 10:46
@iansu
lib: add shutil module with rmtree method
fa504e0
@iansu
Add tests
b04be50
@iansu
Move helper functions to internal module
9c2436e
@iansu
Remove assert
c765d7c
@iansu
Fix lint errors
d98fff1
@iansu
Only validate error argument if it's passed
4c372b6
@nodejs-github-bot nodejs-github-bot added the build Issues and PRs related to Node.js builds or CI infrastructure. label Jun 13, 2019
@boneskull

boneskull commented Jun 13, 2019

Copy link
Copy Markdown
Member

not sure why this is labeled build

All reactions

Sorry, something went wrong.

Uh oh!

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

boneskull
boneskull suggested changes Jun 13, 2019
View reviewed changes

@boneskull boneskull left a comment

Copy link
Copy Markdown
Member

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.

we need the license from rimraf copied over

Sorry, something went wrong.

Uh oh!

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

All reactions
@Trott

Trott commented Jun 13, 2019

Copy link
Copy Markdown
Member

not sure why this is labeled build

The bot added that label because the PR modifies node.gyp.

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

@boneskull

boneskull commented Jun 13, 2019

Copy link
Copy Markdown
Member

@iansu I ticked the "tests are included" checkbox, since some tests are included, but unsure if you intended to add more?

All reactions

Sorry, something went wrong.

Uh oh!

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

Trott
Trott requested changes Jun 13, 2019
View reviewed changes

@Trott Trott left a comment

Copy link
Copy Markdown
Member

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.

Needs documentation. I assume it's not present because this is a work-in-progress and I will label it as such. If that's wrong, please comment.

Sorry, something went wrong.

Uh oh!

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

boneskull reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@Trott Trott added wip Issues and PRs that are still a work in progress. fs Issues and PRs related to file-system APIs and the fs module. labels Jun 13, 2019
@Trott

Trott commented Jun 13, 2019

Copy link
Copy Markdown
Member

I'm a-gonna ping @nodejs/tsc on this one because I'm pretty sure there will be strong opinions and lots of conversation. (Any links to existing previous conversations in the tooling group that might help us avoid rehashing stuff that's already been worked out might be useful.)

All reactions

Sorry, something went wrong.

Uh oh!

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

@boneskull

boneskull commented Jun 13, 2019

Copy link
Copy Markdown
Member

nodejs/tooling#13 nodejs/tooling#23 and otherwise much discussion during meetings (in the minutes/ dir there)

All reactions

Sorry, something went wrong.

Uh oh!

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

@boneskull

boneskull commented Jun 13, 2019

Copy link
Copy Markdown
Member

to expand on "why the new module name", it's to clearly differentiate high-level fs operations (such as rimraf--mkdirp probably should have been done this way) from low-level, atomic operations (the entirety of fs, sans mkdirp)

All reactions

Sorry, something went wrong.

Uh oh!

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

@Trott

Trott commented Jun 13, 2019 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Thanks for the detailed explanation in the description of the PR. Am I reading it correctly that the main reason to choose shutils.rmtree() over fs.rmtree() is the whole "not a primitive/atomic" thing? One might argue that we should put it where someone is most likely to look for it, and fs.rmtree() would be that place, regardless that this isn't a primitive/atomic. Maybe there are also other reasons for keeping it out of fs?

Also, if there are any comments that could be made that might pre-empt "why not rmTree() or removeTree() or rmdirRecursive()" bike-shedding, please make them. On the other hand, if the bike-shedding is unavoidable, that's OK. (Getting the API name right can be important, so "bike-shedding" may be a term I should avoid as it's kind of dismissive.)

addaleax, reconbot, ljharb, niktekusho, and kaznovac reacted with thumbs up emoji ckotzbauer and YurySolovyov reacted with heart emoji
All reactions
  • 👍 5 reactions
  • ❤️ 2 reactions

Sorry, something went wrong.

Uh oh!

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

@Trott

Trott commented Jun 13, 2019

Copy link
Copy Markdown
Member

Unfortunately, shutil is an existing module in the ecosystem: https://www.npmjs.com/package/shutil

Fortunately, it's not widely-used nor actively-maintained. So creating an internal shutil may not be disruptive.

All reactions

Sorry, something went wrong.

Uh oh!

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

Fishrock123
Fishrock123 suggested changes Jun 13, 2019
View reviewed changes

@Fishrock123 Fishrock123 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.

IMO this should just be part of fs, whether rmdir recursive or fs.rimraf or something.

Sorry, something went wrong.

Uh oh!

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

addaleax, YurySolovyov, gengjiawen, sindresorhus, mischnic, mlcdf, tuananh, ljharb, ChALkeR, niktekusho, and 2 more reacted with thumbs up emoji Hoishin reacted with thumbs down emoji addaleax, YurySolovyov, and gengjiawen reacted with heart emoji
All reactions
  • 👍 12 reactions
  • 👎 1 reaction
  • ❤️ 3 reactions
@bcoe bcoe mentioned this pull request Jun 13, 2019
fs: implement fs.rmdir recurisve #28171
Closed
4 tasks done
@sam-github sam-github removed the build Issues and PRs related to Node.js builds or CI infrastructure. label Jun 13, 2019
@bcoe

bcoe commented Jun 13, 2019 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

@Fishrock123, I'm in agreement with @sam-github (who commented on @zero1five's PR) and with @refack who encouraged using shutil, that the behavior of rimraf is a layer of abstraction above fs and should probably be in its own module.

I personally wish it could be in a node:rimraf standard module, as it feels like we're super close to being able to move forward with module namespaces as a home for an expanded API for Node.js and JavaScript ... maybe this is putting the cart in front of the horse though (and I don't want to hold up this work).

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

sam-github
sam-github reviewed Jun 13, 2019
View reviewed changes
Comment thread lib/internal/shutil.js Outdated
@@ -0,0 +1,310 @@
'use strict';

@sam-github sam-github Jun 13, 2019

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.

ISC license and copyright is missing, isn't it?

It's ISC for a reason, so you of course already have permission to take the code, as long as the copyright and permission stick around. If it's easier for Node.js to relicense it as MIT, that's probably doable.

  • lib: add shutil module with rmtree method iansu/node#1 (comment)

Sorry, something went wrong.

Uh oh!

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

All reactions

@iansu iansu Jun 13, 2019

Copy link
Copy Markdown
Contributor Author

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.

I wasn't sure about the correct way to incorporate them so that's why they're missing. It's on the todo list though.

Sorry, something went wrong.

Uh oh!

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

All reactions

@silverwind silverwind Jun 14, 2019 •
edited
Loading

Uh oh!

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

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.

I think it should be enough to add it to LICENSE like this, no need to litter files with licensing comments.

Sorry, something went wrong.

Uh oh!

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

All reactions

@MylesBorins MylesBorins Jun 17, 2019

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.

if we are going to vendor rimraf could we do it similarly to how we've vendored other modules. Please look at the experimental fetch PR for an example of how to do this (including the license)

#27979

Sorry, something went wrong.

Uh oh!

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

All reactions
@iansu

iansu commented Jun 13, 2019

Copy link
Copy Markdown
Contributor Author

Documentation and incorporating the rimraf license are on the todo list. There are some tests already but I'd like to port whatever we can from rimraf as well to cover as much as possible.

All reactions

Sorry, something went wrong.

Uh oh!

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

@addaleax addaleax added the semver-minor PRs that contain new features and should be released in the next minor version. label Jun 13, 2019
@boneskull

boneskull commented Jun 13, 2019

Copy link
Copy Markdown
Member

I'm less opinionated on whether this should be in its own module, or some as-of-yet-unknown other namespace, or live in fs. I am much more interested in just getting the functionality in.

iansu, bcoe, ruyadorno, and ChALkeR reacted with thumbs up emoji Fishrock123 reacted with confused emoji
All reactions
  • 👍 4 reactions
  • 😕 1 reaction

Sorry, something went wrong.

Uh oh!

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

@Fishrock123

Fishrock123 commented Jun 13, 2019

Copy link
Copy Markdown
Contributor

Just because it isn't just a fs operation at an os level doesn't mean that it shouldn't logically be grouped with other file system operations in order to be less confusing to users...

I am much more interested in just getting the functionality in.

That's cool and all but it may be hard or impossible to move later.

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

@sam-github

sam-github commented Jun 13, 2019 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

@iansu you might want to wait a bit before doing all the cleanup, it would be a shame to spend the time if it doesn't land. Not that I am predicting whether it will land or not, I don't know.

I personally am an unapologetic fan of node+npm. I've used multiple languages with "batteries included" standard libraries. There is a short-term pleasure from having so much functionality immediately availlable, but I have watched them struggle to keep both backwards compatible and relevant over time. I think treating a registry (or federation of registries it that is what happens) as a semvered source of features is a strength of node, not a weakness. I prefer for node core to focus on runtime features that enable the ecosystem, rather than absorbing the ecosystem. I won't try to block this if its what people want, but for the record, I prefer it not to be.

This doesn't do anything better than the external rimraf package (it's not faster, it's not avoiding binary addons, etc)., and unless I misread, it appears to have less features, because it lacks globbing. I expect bug reports on that lack almost immediately. But we can vendor in glob, too, is this the way we want to go?

The sole benefit to node users is to avoid having to do npm i rimraf and to transfer the maintenance burden of rimraf from https://github.com/isaacs/rimraf to node core. Not even transfer, rimraf will still need to be maintained indefinitely, "duplicate" would be a better description.

I understand why non-node developers unfamiliar with an easy-to-use and powerful dependency management tool don't understand why node has a small builtin library, but I genuinely don't understand why node developers would be adverse to using npm/yarn to get features. At the tooling meeting in Berlin, it was pointed out that it forces the introduction of npm early when tutoring people on node.js, but I struggle to find that compelling. Shouldn't a dependency manager be introduced early? Is there really that many zero-dependency projects out there?

shalvah and sompylasar reacted with thumbs up emoji RichiCoder1 reacted with thumbs down emoji Akamaozu and sompylasar reacted with heart emoji
All reactions
  • 👍 2 reactions
  • 👎 1 reaction
  • ❤️ 2 reactions

Sorry, something went wrong.

Uh oh!

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

@silverwind

silverwind commented Jun 14, 2019 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Might be something for a future optimization but we can likely eliminate the extra stat calls by using the withFileTypes option of readdir.

What does shutil stand for? Shell Utilities?

All reactions

Sorry, something went wrong.

Uh oh!

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

@iansu

iansu commented Jun 14, 2019

Copy link
Copy Markdown
Contributor Author

@joyeecheung Thanks for pointing that out. I'm definitely in favour of using that if we're going to end up adding a recursive option to rmdir.

All reactions

Sorry, something went wrong.

Uh oh!

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

@jasnell

jasnell commented Jun 14, 2019

Copy link
Copy Markdown
Member

FWIW, according to the LICENSE file, we already incorporate ISC-licensed stuff in the code base. (Still worth checking, I suppose....)

Ah right right. Sorry, scratch what I've said about ISC, I was mentally confusing it with the Artistic License 2 that npm uses. ISC is perfectly fine but the other technical issues still stand :)

All reactions

Sorry, something went wrong.

Uh oh!

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

@iansu

iansu commented Jun 14, 2019

Copy link
Copy Markdown
Contributor Author

@jasnell One issue at a time... 🙂

All reactions

Sorry, something went wrong.

Uh oh!

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

@ljharb

ljharb commented Jun 14, 2019

Copy link
Copy Markdown
Member

New core modules should NOT be added, pending the outcome of #21552.

Separately this is a filesystem action - conceptually imo it belongs on fs, whether it’s a separate function or an option.

ChALkeR, sindresorhus, and RyanZim reacted with thumbs up emoji richardlau and steelbrain reacted with confused emoji
All reactions
  • 👍 3 reactions
  • 😕 2 reactions

Sorry, something went wrong.

Uh oh!

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

@ForsakenHarmony

ForsakenHarmony commented Jun 15, 2019

Copy link
Copy Markdown

The link to rimraf in the original post is broken btw

Also I agree on not getting another core module

The recurse option would be nice, alternatively something like rmdir{Tree,Recurse,...} analogous to the Sync postfix (copy being the same that came to mind when I first saw this because I needed a recursive version at the time)

All reactions

Sorry, something went wrong.

Uh oh!

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

MylesBorins
MylesBorins suggested changes Jun 17, 2019
View reviewed changes

@MylesBorins MylesBorins 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.

I'm similarly -1 on a new module... I think this makes a ton of sense as an option to fs.rmdir. We could still vendor rimraf to do so and use that code path when the option is passed.

I'd prefer to see vendored external code done explicitly, similar to how we've vendored eslint. Please take a look at my fetch PR for an example of how to vendor including updating the license and providing a script for future updates

#27979

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread lib/internal/shutil.js Outdated
@@ -0,0 +1,310 @@
'use strict';

@MylesBorins MylesBorins Jun 17, 2019

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.

if we are going to vendor rimraf could we do it similarly to how we've vendored other modules. Please look at the experimental fetch PR for an example of how to do this (including the license)

#27979

Sorry, something went wrong.

Uh oh!

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

All reactions
@iansu

iansu commented Jun 18, 2019

Copy link
Copy Markdown
Contributor Author

I'm not opposed to moving this into fs but I personally think rmdir is the wrong place for it. The shell version of rmdir does not delete files. Making the Node version do that might surprise some people.

ljharb and addaleax 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.

@targos

targos commented Jun 18, 2019

Copy link
Copy Markdown
Member

What about we call it rm or remove and like the shell version let it remove files or directories, with an recursive option?

All reactions

Sorry, something went wrong.

Uh oh!

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

@iansu

iansu commented Jun 18, 2019

Copy link
Copy Markdown
Contributor Author

@targos unlink is essentially the Node version of rm I think. If we were to add a new function with a recursive option we would also need to add a non-recursive version which is just unlink. That's why I like something like rmtree because it's (maybe?) obvious from the name that it's recursive.

All reactions

Sorry, something went wrong.

Uh oh!

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

@iansu

iansu commented Jun 18, 2019

Copy link
Copy Markdown
Contributor Author

@MylesBorins The idea of vendoring rimraf is interesting. We did make a couple of changes to rimraf though, mainly removing globbing and replacing arg checks using assert with throwing the proper exceptions.

I think long term the thinking was that rimraf would continue to exist to provide globbing and a CLI but would use the underlying Node functionality on supported versions.

All reactions

Sorry, something went wrong.

Uh oh!

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

@silverwind

silverwind commented Jun 18, 2019

Copy link
Copy Markdown
Contributor

I like the idea of a fs.rm. We would be somewhat in line with the shell commands that way. If we strictly follow shell, recursive should be off by default. In a similar vein, we could later introduce fs.cp.

Regarding fork vs. vendoring: I think we want to fork given the reasons above as well as to open the way for further optimization (like removing stat calls).

All reactions

Sorry, something went wrong.

Uh oh!

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

@bcoe

bcoe commented Jun 21, 2019 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Regarding Small Core

@sam-github I care deeply about keeping encouraging a vibrant npm ecosystem.

I'm in @sindresorhus' camp however, that there's a small minority of utility modules (rmraf, mkdirp, fetch, maybe glob) that would make sense in the standard toolbox:

a tooling author almost always needs these dependencies (which has lead to dependency counts in the millions if you look on GitHub):

  • rimraf, 2,800,000.
  • mkdirp, 2,790,000.
  • glob, 2,900,000.

I don't think these numbers are a measure of popularity (in the same way that the community knows about a module like React, or WebPack) it's a measure of the fact that these modules are core building blocks for JavaScript infrastructure.

Given that @isaacs is supportive of moving rimraf into core, I'd advocate it's a good idea; I think we should take on this maintenance burden, it's valuable to the community.

Regarding Naming Things

It sounds like folks are more in favor of an fs.rmtree than a shutil module, why don't we start with:

  • fs.rmtree.
  • fs.rmtreeSync.

And we can revisit whether we add a recursive setting to rmdir in the future.

iansu, ljharb, hybrist, sindresorhus, and niktekusho reacted with thumbs up emoji
All reactions
  • 👍 5 reactions

Sorry, something went wrong.

Uh oh!

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

@iansu

iansu commented Jun 21, 2019

Copy link
Copy Markdown
Contributor Author

@bcoe I'm in favour of moving ahead with fs.rmtree and fs.rmtreeSync. We can also provide a promisified version like other functions in fs.

All reactions

Sorry, something went wrong.

Uh oh!

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

@sindresorhus

sindresorhus commented Jun 21, 2019

Copy link
Copy Markdown

And we can revisit whether we add a recursive setting to rmdir in the future.

I don't think Node.js should have multiple ways to do the exact same thing. So we should go with either a recursive option or fs.rmtree. I would still prefer the option, but I'm totally fine with fs.rmtree if that's what it takes to get it into core.


There should be one-- and preferably only one --obvious way to do it. - Zen of Python.

silverwind and LinusU 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.

@MylesBorins

MylesBorins commented Jun 21, 2019

Copy link
Copy Markdown
Contributor

I'm still very bullish on making it an option. I also have significant reservations about doing a fork over vendoring. There obviously are extra bits that we may not want in core... but it is a much larger maintenance burden for us to keep that up to date and fix bugs, whereas if we simply vendor we can just work upstream and upgrade as neccessary.

bcoe and LinusU 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 commented Jul 2, 2019

Copy link
Copy Markdown
Contributor Author

I spent some time this weekend working on vendoring rimraf, which mostly involved shamelessly copying @MylesBorins node-fetch PR. I ran into some issues though, mainly the fact that rimraf has a dependency on glob. We could also vendor glob but then it has several other dependencies, and so on it goes.

Is there a strategy for handling this kind of thing with other vendored packages? Another option would be to patch rimraf after we pull it in to remove glob. Before I move ahead I'm curious to know what people think about either of these approaches.

I should also mention that I'm planning to move rimraf into fs.rimraf and drop the new top-level module shutill. That was another point of contention with this PR so hopefully that satisfies those concerns.

All reactions

Sorry, something went wrong.

Uh oh!

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

@sindresorhus

sindresorhus commented Jul 2, 2019

Copy link
Copy Markdown

Another option would be to patch rimraf after we pull it in to remove glob.

👍

I should also mention that I'm planning to move rimraf into fs.rimraf

I don't think rimraf is a good name (I'm not alone). It should either be the recursive option or fs.rmtree as discussed previously. (Even fs.rmrf would be better than rimraf).

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.

@bcoe

bcoe commented Jul 2, 2019

Copy link
Copy Markdown
Contributor

I don't think rimraf is a good name (I'm not alone). It should either be the recursive option or fs.rmtree

@sindresorhus python uses rmtree, as does ruby, I think this is a reasonable compromise (even if underneath the hood the vendored package is rimraf).

Another option would be to patch rimraf after we pull it in to remove glob.

Let's work with @isaacs' and see if we can support this in an elegant way; I'm wondering if we could refactor rmraf in such a way that we can maintain a no-glob tag (npm i rimraf@no-glob), but still be pretty much on the mainline module.

A good place to get @isaacs' attention might be in this slack.

All reactions

Sorry, something went wrong.

Uh oh!

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

@iansu

iansu commented Jul 2, 2019

Copy link
Copy Markdown
Contributor Author

I personally prefer the name rmtree. I wasn't sure if we had to keep it the same if we were vendoring rimraf.

Not having to make a patch and keep it updated is appealing. I will try reaching out to @isaacs on Slack.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bcoe bcoe mentioned this pull request Jul 14, 2019
feat: make it possible to omit glob dependency isaacs/rimraf#192
Closed
@iansu iansu mentioned this pull request Jul 24, 2019
An optional parameter that lets us delete folders that aren't empty directly #22686
Closed
@iansu
Vendor rimraf as fs.rmtree
39706c6
@iansu

iansu commented Aug 14, 2019

Copy link
Copy Markdown
Contributor Author

@isaacs published a new version of rimraf yesterday with glob as an optional dependency. Thanks @isaacs and @bcoe for making that happen! ❤️

I've updated this PR to vendor rimraf and wrap it as fs.rmtree and fs.rmtreeSync.

If people are happy with this approach I'll be working on porting some of the existing rimraf tests over with help from my Node.js Mentorship Program mentee @mpaktiti.

All reactions

Sorry, something went wrong.

Uh oh!

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

cjihrig
cjihrig requested changes Aug 14, 2019
View reviewed changes

@cjihrig cjihrig 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.

I'm OK with vendoring in rimraf, but I think it should be a one time thing.

  • rimraf doesn't seem to require a lot of maintenance. It doesn't look like any of the changes in ~2 years would require changes to the vendored code.
  • The source code is only 300-400 lines of JavaScript, which I expect the core team could easily maintain. If bugs are fixed in the rimraf module, I'm sure they would be cherry-picked.
  • My biggest complaint - ongoing vendoring of rimraf would give a slightly inconsistent user experience, mainly around error handling. We've put in a lot of effort to rolling out a new error system, which wouldn't be part of the vendored code. We could also eliminate dead code, such as the handling of the glob dependency.

If no one wants to do the porting of the rimraf codebase to better fit into core, I'll happily take a shot at it.

Sorry, something went wrong.

Uh oh!

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

targos, realityking, Hoishin, and LinusU reacted with thumbs up emoji
All reactions
  • 👍 4 reactions
@cjihrig cjihrig mentioned this pull request Aug 16, 2019
fs: add recursive option to rmdir() #29168
Closed
4 tasks done
@iansu

iansu commented Aug 18, 2019

Copy link
Copy Markdown
Contributor Author

@cjihrig porting rimraf to Node core was actually the approach I originally took in this PR. There was some criticism of that (I think rightly so). It's mostly in this thread but I think the main arguments were:

  • Taking on the maintenance burden of rimraf was undesirable (even if it is small)
  • rimraf is going to have to exist for a long time so two versions of the code will need to be maintained, bug fixes ported, etc.

As far as this being a separate function or an option to rmdir I'm not strongly opinionated. My only argument against adding it as option is that in the unix world rmdir is not the function that recursively deletes files and directories. I could see that creating some (possibly dangerous) confusion.

All reactions

Sorry, something went wrong.

Uh oh!

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

@iansu
Remove last trace of shutil
1908b52
@iansu

iansu commented Aug 23, 2019

Copy link
Copy Markdown
Contributor Author

Since #29168 has been merged I'm going to close this PR.

All reactions

Sorry, something went wrong.

Uh oh!

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

@iansu iansu closed this Aug 23, 2019
@iansu iansu mentioned this pull request Jul 10, 2020
Rethink recursive flag (and design more generally) for fs.rmdir #34278
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jasnell jasnell jasnell requested changes
@Trott Trott Trott requested changes
@cjihrig cjihrig cjihrig requested changes
+5 more reviewers
@sam-github sam-github sam-github left review comments
@silverwind silverwind silverwind left review comments
@MylesBorins MylesBorins MylesBorins requested changes
@boneskull boneskull boneskull requested changes
@Fishrock123 Fishrock123 Fishrock123 requested changes
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

fs Issues and PRs related to file-system APIs and the fs module. semver-minor PRs that contain new features and should be released in the next minor version. wip Issues and PRs that are still a work in progress.

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.

20 participants

@iansu @boneskull @Trott @bcoe @Fishrock123 @sam-github @silverwind @devsnek @jasnell @zero1five @gireeshpunathil @sindresorhus @joyeecheung @ljharb @ForsakenHarmony @targos @MylesBorins @cjihrig @addaleax @nodejs-github-bot
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.