Skip to content

gitignoreFilter.ts does not handle symlinked paths #76

Description

@jcapogna

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:

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 fixed this for myself by modifying line 26 of gitignoreFilter.ts to use entry.path instead of entry.absolutePath.
https://github.com/gliviu/dir-compare/blob/master/test/extended/gitignoreSupport/gitignoreFilter.ts#L26

You could probably also resolve the absolute paths before calling isGitIgnoredSync.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions