Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to include wildcards in delete? #57

Closed
newmanw opened this issue May 15, 2014 · 9 comments
Closed

Possible to include wildcards in delete? #57

newmanw opened this issue May 15, 2014 · 9 comments

Comments

@newmanw
Copy link
Contributor

newmanw commented May 15, 2014

Would be nice to be able to delete based on wildcards.

fs.remove('/tmp/something.*', function(err) { ...
@jprichardson
Copy link
Owner

Hmm, I agree... this could be handy. I can't make it a priority right now to implement, but I'll leave this open incase someone wants to do a PR. But the way to do it would be to take advantage of the options in rimraf (the module that fs-extra uses to delete) and set options.unlink to function and if the file matches the wildcard then use fs.unlink and if not, just skip deleting. Actually, after typing this out, it wouldn't be that difficult to implement.

@jprichardson
Copy link
Owner

Note to self, reference module to borrow techniques from: https://github.com/sindresorhus/del

@jprichardson
Copy link
Owner

This should actually be possible now that rimraf supports wildcards (fs-extra depends upon rimraf). Closing.

@pomber
Copy link

pomber commented Jan 17, 2017

How do you use wildcards?
Looks like there is no way to set disableGlob to false in remove functions.

@jprichardson
Copy link
Owner

How do you use wildcards?

You can't. Your best bet is to use a file system walker like https://github.com/jprichardson/node-klaw and match using a filter, and then remove.

@pomber
Copy link

pomber commented Jan 20, 2017

Shouldn't it be possible using just rimraf with disableGlob false?

@jprichardson
Copy link
Owner

Shouldn't it be possible using just rimraf with disableGlob false?

Sure, but IIRC, we have it hardcoded to false. So you'd then have to include rimraf if you want to do that.

@jwmann
Copy link

jwmann commented Mar 17, 2020

Are we still not able to use wildcards?
Why can't we pass { glob: true } to fs.remove() so rimraf can do the job?

@RyanZim
Copy link
Collaborator

RyanZim commented Mar 17, 2020

We have a fork of rimraf that doesn't include globbing. Globbing just makes everything far more complicated, and we're not willing to take that on ATM.

Repository owner locked as resolved and limited conversation to collaborators Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants