Skip to content

ignore option doesn't work if glob path begins with ./ #309

New issue

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

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

Already on GitHub? # to your account

Closed
srolel opened this issue Nov 19, 2016 · 4 comments
Closed

ignore option doesn't work if glob path begins with ./ #309

srolel opened this issue Nov 19, 2016 · 4 comments

Comments

@srolel
Copy link

srolel commented Nov 19, 2016

Works as expected:

glob('**/*', {nodir: true, ignore: '**/*.css'}, cb)

All files matching the glob patterns are passed, including files fulfilling the ignored glob:

glob('./**/*', {nodir: true, ignore: '**/*.css'}, cb)

Does it work like this for a reason?

@beverts312
Copy link

I believe this is the same issue I am experiencing. To clearify the problem a bit here is what I am seeing.
When I have:
glob.sync(someDir + '/**/*', { dot: true, ignore: someDir + '/.vscode/launch.json' })
The file launch.json is not ignored, however if I rename it to .launch.json and run:
glob.sync(someDir + '/**/*', { dot: true, ignore: someDir + '/.vscode/.launch.json' })
The file .launch.json is properly ignored (unfortunately thats not what I want to name my file).

I see in the docs:

dot Include .dot files in normal matches and globstar matches. Note that an explicit dot in a portion of the pattern will always match dot files.

Is the Note section of that describing that this is the desired behavior? If not I will take a look at the code base and see if I can identify the issue

@jthegedus
Copy link

https://github.com/prettier/prettier/ uses this package and I keep running into this issue prettier/prettier#2110. Are there any plans to support this? I'm set in my was of prefixing dirs with ./ is all 😛

@adamreisnz
Copy link

adamreisnz commented Apr 3, 2018

Users of https://github.com/adamreisnz/replace-in-file also running into this issue. Happy to add a note in the Readme alerting them of this behaviour, but it seems rather odd to completely disregard ignore paths in this scenario.

@isaacs
Copy link
Owner

isaacs commented Feb 28, 2023

No longer an issue on v9. This was owing to the fact that glob was preserving the excess . and / characters in the pattern, meaning that it would not match against the ignore pattern unless it also contained the same leading ./ character.

@isaacs isaacs closed this as completed Feb 28, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants