node-ignore
node-ignore copied to clipboard
directory ending with / not always correctly ignored
Hi!
Thanks for this awesome package! I think I might found a small bug when using it.
With the following .gitignore
contents
c/*
!c/bar.js
Running git check-ignore -v c/
results in
.gitignore:1:c/* c/
Using ignore.test('c/')
indicates that it's not ignored. This package correctly indicates that c/
is ignored if I change c/*
in the .gitignore
file to c/
.
Kind regards Sam
Confirmed. Really weird behavior of git check-ignore
.
IMO, c/*
means ignoring everything inside of directory c
but not c
itself.
I need to check the spec
However, this issue might not have side effects.
The thing is that git check-ignore c
is different and not ignored. But with /
it is. It seems that once you add a /
it thinks you are IN the directory and it's not the directory itself anymore.
But I think this issue will not cause the situation that we copy wrong files (we always copy files instead of directories), so it is of low priority.
The use case I'm having is that I use isomorphic-git which uses this package under the hood. I'm building git check-ignore
on top of that and that's when I saw that it incorrectly checks the use case explained in the issue.
Would you be open for a PR to try to fix this use case?
yes I would