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

Wrong glob generated when using a nested directory or array of directories in booters options #8201

Closed
vvandens opened this issue Jan 7, 2022 · 3 comments · Fixed by #8205

Comments

@vvandens
Copy link

vvandens commented Jan 7, 2022

Describe the bug

Setting dirs to either a directory or an array of directories in a booter options generates a bad glob pattern under the hood when one of the dir path is deeply nested (i.e. contains a / in its relative path).

When setting dirs: ['dirA/sub', 'dirB'] in a booter options, the glob directories part generated is : @(dirA/sub|dirB) from BaseArtifactBooter.configure(). This breaks the loading of the resources from both directories. Same applies for a single nested directory dirs: 'dirA/sub'. @ pattern matching should not be used for directories, only for extensions.

To solve the issue, a brace expansion should be generated for dirs, i.e. {dirA/sub,dirB}, when dirs is an array and nothing at all when it's a single string.

Logs

No response

Additional information

No response

Reproduction

https://codesandbox.io/s/vigorous-andras-fhpeb?file=/src/application.ts

@vvandens vvandens added the bug label Jan 7, 2022
@achrinza achrinza added the Boot label Jan 8, 2022
achrinza added a commit that referenced this issue Jan 8, 2022
fixes #8201

Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com>
@achrinza
Copy link
Member

achrinza commented Jan 9, 2022

Thanks for opening the issue, @vvandens! I was able to replicate it at my end.

For others' future reference, this behaviour has been acknowledged by the node-glob maintainer: isaacs/node-glob#278 (comment)

A workaround for now is to use glob which will take precedence over the other options.

@vvandens
Copy link
Author

Thanks for the feedback @achrinza.
Reading your pending fix, I don't think that it will work when dirs is set as a string pointing to a nested directory (i.e. dirs: 'dir/sub'). Brace expansion will only work when there is more than one expression passed to it. In this case, I believe that the directory string should be used as-is when constructing the glob.

achrinza added a commit that referenced this issue Jan 11, 2022
fixes #8201

Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com>
achrinza added a commit that referenced this issue Jan 11, 2022
fixes #8201

Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com>
achrinza added a commit that referenced this issue Jan 11, 2022
fixes #8201

Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com>
achrinza added a commit that referenced this issue Jan 11, 2022
fixes #8201

Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com>
@achrinza
Copy link
Member

Thanks for the clarification, @vvandens. You're right, brace expansion does not work for single expressions. I've updated the PR.

achrinza added a commit that referenced this issue Jan 14, 2022
fixes #8201

Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants