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

Add ability to disable glob matching #60

Closed
mofux opened this issue Aug 17, 2017 · 4 comments
Closed

Add ability to disable glob matching #60

mofux opened this issue Aug 17, 2017 · 4 comments

Comments

@mofux
Copy link
Contributor

mofux commented Aug 17, 2017

I already know the files or folders I want to delete, so I simply pass them to trash in an array. Fine. Now consider this:

touch "test*.txt"
touch test1.txt
touch test2.txt
touch test3.txt

And guess what happens if I tell trash to remove the regular file "test*.txt", not good 😅

trash(['test*.txt'])

Therefore I would opt for an option that disables the globber and simply uses the file list I pass.
I'd like to create a PR if you're willing to accept. I propose an interface like this:

trash(['test*.txt'], { glob: false })
@sindresorhus
Copy link
Owner

Sure

@kevva
Copy link
Contributor

kevva commented Aug 18, 2017

You can escape the character like this trash(['test\\*.txt']), which imo is a better choice than adding a new option. This is also how bash for example works.

@mofux
Copy link
Contributor Author

mofux commented Aug 18, 2017

@kevva If it was only for the* I would agree, but there are so many special characters in a glob pattern *, (, ), ?, !, +, @ that it would just feel strange and leave me with a somewhat bad feeling if I did escape them. In the end, this lib is about deleting files - which is the one most sensitive system action that you don't want to mess up 😅.

@sindresorhus
Copy link
Owner

@kevva I could think of a different use-case. When you've already globbed or gotten the list of files using another mechanism and then pass it to trash, it could be helpful to disable globbing for performance reasons.

@kevva kevva closed this as completed in #61 Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants