Error: Path /private/var/folder/a.txt is not in cwd /var/folder
(I shortened the paths for the example)
I discovered that /var/folder is actually a symlink to /private/var/folder. dir-compare turns the symlink into an absolute path, but the GlobbyFilterFunction in gitignoreFilter.ts uses the original symlinked path, not the absolute path, hence the mismatch.
I implemented the gitignoreFilter as specified here https://github.com/gliviu/dir-compare?tab=readme-ov-file#implement-gitignore-filter.
However, I started getting errors like:
(I shortened the paths for the example)
I discovered that
/var/folder
is actually a symlink to/private/var/folder
. dir-compare turns the symlink into an absolute path, but theGlobbyFilterFunction
ingitignoreFilter.ts
uses the original symlinked path, not the absolute path, hence the mismatch.I fixed this for myself by modifying line 26 of
gitignoreFilter.ts
to useentry.path
instead ofentry.absolutePath
. https://github.com/gliviu/dir-compare/blob/master/test/extended/gitignoreSupport/gitignoreFilter.ts#L26You could probably also resolve the absolute paths before calling
isGitIgnoredSync
.