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

Unable to exclude files using glob pattern #1763

Open
mohammadalipak opened this issue Jul 21, 2022 · 3 comments
Open

Unable to exclude files using glob pattern #1763

mohammadalipak opened this issue Jul 21, 2022 · 3 comments
Assignees

Comments

@mohammadalipak
Copy link

Language

Typescript | JavaScript | CSS

Sample input source code

// sample file structure
src/
├── app/
│   ├── app.css
│   ├── app.html
│   └── app.js
└── package.json


// sortier command
sortier '**/!(*.json|*.css)'

Expected output

// result
sortier should have only modified the html and js files

Actual output (or error message)

// result
sortier modifies ALL files and does not exclude the css and json files
@k2snowman69
Copy link
Member

Thanks for the heads up, I've got a working reproduction locally. Trying to figure out the fix.

@k2snowman69 k2snowman69 self-assigned this Jul 22, 2022
@k2snowman69
Copy link
Member

k2snowman69 commented Jul 22, 2022

From what I can tell this issue is likely in globby or somewhere lower but I can't tell why. Let me explain, sortier uses globby to perform all glob interpretations and when I debug the code I see the following:

// args =  ['**/!(*.json|*.css)']
 const files = globbySync(args);
// files = ['package.json', 'app/app.css', 'app/app.html', 'app/app.js']

Testing the glob in

Seems to return the correct list of files so I'm not sure why this is happening.

Also, it seems **/*.{json,css} and **/*.(json|css) works perfectly fine

@k2snowman69
Copy link
Member

k2snowman69 commented Jul 22, 2022

I created https://github.com/k2snowman69/issue-sortier-1763/blob/main/app/globby.test.js just to express the issue with globby a bit better. This reproduces the environment described in this bug. I created a test that shows that

  • non-negation globs seem to work fine.
  • Negation globs that have the negation at the beginning all result in 0 results - incorrect
  • Negation globs that have the negation in the middle similar to the initial bug results in more files (3737) than a globstar ** results in (3699)

Not going to lie, I'm confused. This might be something to follow up on the globby library with.

A work around might be temporarily using the .sortierignore file instead but i haven't tested this yet

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

No branches or pull requests

2 participants