ignore option doesn't work if glob path begins with ./
srolel opened this issue · 4 comments
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?
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 andglobstar
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
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 😛
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.
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.