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

Minor refactor to expandPatterns #15317

Merged
merged 2 commits into from Aug 28, 2023
Merged

Minor refactor to expandPatterns #15317

merged 2 commits into from Aug 28, 2023

Conversation

fisker
Copy link
Member

@fisker fisker commented Aug 28, 2023

Description

I found that fast-glob can't glob any file with **/{*.js} (single extension), the original code works because we always have many extensions and filenames in languages.
I guess better pass an array to fast-glob instead to be safer.

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@fisker
Copy link
Member Author

fisker commented Aug 28, 2023

... This happened fixes #15001 somehow. That's something I didn't expected.

@fisker
Copy link
Member Author

fisker commented Aug 28, 2023

I also tested that using array doesn't effect speed.

Test script
import fg from 'fast-glob'

for (const patterns of [
  'node_modules/**/{*.js,*.json,*.md}',
  ['node_modules/**/*.js','node_modules/**/*.json','node_modules/**/*.md'],
]) {
  fg.sync(patterns) // warm up

  const label = JSON.stringify(patterns)
  console.time(label);
  const result = fg.sync(patterns, {dot: true})
  console.log(`${result.length} files found`)
  console.timeEnd(label)
}
>node test.js
15327 files found
"node_modules/**/{*.js,*.json,*.md}": 214.471ms
15327 files found
["node_modules/**/*.js","node_modules/**/*.json","node_modules/**/*.md"]: 194.193ms

@fisker fisker merged commit 423011d into prettier:main Aug 28, 2023
29 checks passed
@fisker fisker deleted the glob branch August 28, 2023 14:01
medikoo pushed a commit to medikoo/prettier-elastic that referenced this pull request Feb 15, 2024
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.

None yet

2 participants