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

add support for leading ../ in patterns #18

Merged
merged 2 commits into from
Aug 22, 2024

Conversation

SuperchupuDev
Copy link
Owner

@SuperchupuDev SuperchupuDev commented Aug 12, 2024

Current Status

unsure if it's needed, will only merge if i see actual usecases in the wild that break without this.

if you need this, please let me know!


kinda hacky, but i can't think of anything else. has a notable performance hit if patterns start with ../ unless ignore options are better configured by the user

imagine you do the following:

glob(['../b/*.ts', '*.ts'], {
  cwd: 'users/me/projects/a'
});

// ['../b/a.ts', 'a.ts']

where the projects directory contains a/a.ts and b/a.ts, in addition to a node_modules folder bigger than god knows what.

in this case, tinyglobby infers a common root of users/me/projects, and it will start crawling every file under that root. this includes everything inside node_modules.

as such, it does some extra crawling that can make the whole thing potentially very slow. one solution for this would be for the user to manually ignore everything they don't want:

glob(['../b/*.ts', '*.ts'], {
  cwd: 'users/me/projects/a',
  ignore: ['../node_modules/**']
});

// ['../b/a.ts', 'a.ts']

this makes it fast again. thoughts?

@SuperchupuDev
Copy link
Owner Author

someone's usecase is indeed breaking without this

unocss/unocss#4094 (comment)

@SuperchupuDev SuperchupuDev merged commit 2f36404 into main Aug 22, 2024
4 checks passed
@SuperchupuDev SuperchupuDev deleted the leading-parent-directory branch August 22, 2024 20:32
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.

1 participant