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

Slashes don't work inside logic operators #278

Closed
ntrrgc opened this issue Aug 1, 2016 · 4 comments
Closed

Slashes don't work inside logic operators #278

ntrrgc opened this issue Aug 1, 2016 · 4 comments

Comments

@ntrrgc
Copy link

ntrrgc commented Aug 1, 2016

For instance, querying the following

glob.sync("!(a/b)", {})

will throw this error:

node_modules/glob/sync.js:147
  var dotOk = this.dot || rawGlob.charAt(0) === '.'
                                 ^

TypeError: Cannot read property 'charAt' of undefined
@isaacs
Copy link
Owner

isaacs commented Aug 3, 2016

It is correct that slashes do not work inside of extglob patterns such as !(a|b). Those can only be used to indicate path parts, not entire paths. This is how Bash works as well. In that case, the pattern is read as a file named b) inside of a folder named !(a, which is weird, but not impossible.

That being said, you have found a bug here, because it should not throw if you use a pattern like that.

@ntrrgc
Copy link
Author

ntrrgc commented Aug 3, 2016

I was trying to implement something like gitignore, with a set of filtered patterns. Isn't there a way to do that with node-glob?

@isaacs
Copy link
Owner

isaacs commented Aug 3, 2016

You can take a look at how fstream-ignore does it. That's what npm uses for .npmignore files. https://github.com/npm/fstream-ignore

@ntrrgc
Copy link
Author

ntrrgc commented Aug 4, 2016

On 08/04/2016 01:40 AM, isaacs wrote:

You can take a look at how fstream-ignore does it. That's what npm
uses for .npmignore files. https://github.com/npm/fstream-ignore


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#278 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA9LxIf7fqV4wdRuBi0GP33H2moRfBMWks5qcSbWgaJpZM4JZ6hM.

Thanks for the tip. I couldn't find something like that the last time I
searched.

@isaacs isaacs closed this as completed Aug 8, 2016
isaacs added a commit to isaacs/minimatch that referenced this issue Aug 8, 2016
There were some magic numbers that assumed that every extglob pattern
starts and ends with a specific number of characters in the regular
expression.  Since !(||) patterns are a little bit more complicated,
this led to creating an invalid regular expression and throwing.

Fixes isaacs/node-glob#278
iarna added a commit to npm/npm that referenced this issue Aug 11, 2016
Handle extremely long and terrible patterns more gracefully.

There were some magic numbers that assumed that every extglob pattern starts
and ends with a specific number of characters in the regular expression.
Since !(||) patterns are a little bit more complicated, this led to creating
an invalid regular expression and throwing.
(isaacs/node-glob#278)

Credit: @isaacs
erikkemperman pushed a commit to erikkemperman/fwdmatch that referenced this issue May 8, 2017
There were some magic numbers that assumed that every extglob pattern
starts and ends with a specific number of characters in the regular
expression.  Since !(||) patterns are a little bit more complicated,
this led to creating an invalid regular expression and throwing.

Fixes isaacs/node-glob#278
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants