Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/abs negative patterns #445

Closed
wants to merge 3 commits into from

Conversation

webpro
Copy link

@webpro webpro commented Jun 16, 2024

What is the purpose of this pull request?

Fixes #441

What changes did you make? (Give an overview)

Use only absolute (negated) patterns when matching against absolute paths to skip in filter.

Without this fix, when using absolute: true, ignore patterns like **/parent may match ancestor path parts (in cwd), but not descendant path parts.

Example:

const options = {
  cwd: '/some/parent/cwd',
  absolute: true,
  ignore: ['**/parent']
}

When globbing src/**/*.ts, it would not match anything, because **/parent is a match against the full path.

@mrmlnc
Copy link
Owner

mrmlnc commented Jul 2, 2024

Thanks for the pull request!

Your idea is correct. The same approach is used in the original glob package.

I created pull request (#449) based on your idea, in which I fixed performance issues (creating regex on each filter call).

Label             import.time (time)  time (time)        memory (memory)     entries (value)  process.time (time)
----------------  ------------------  -----------------  ------------------  ---------------  -------------------
sync current **   10.182ms ±1.171%    105.673ms ±1.861%  10.731 MiB ±0.564%  13813 ±0.000%    152.187ms ±1.351%  
sync previous **  22.290ms ±2.121%    91.915ms ±2.063%   10.762 MiB ±0.550%  13813 ±0.000%    150.477ms ±1.455%  

@mrmlnc mrmlnc closed this Jul 2, 2024
@webpro
Copy link
Author

webpro commented Jul 2, 2024

Thanks @mrmlnc!

@webpro webpro deleted the fix/abs-negative-patterns branch July 2, 2024 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ignore patterns are applied to the absolute path instead of relative to the working directory
2 participants