Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gitignoreFilter.ts does not handle symlinked paths #76

@jcapogna

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.

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