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

glob method errors in the latest release #403

Closed
ZeeshanTamboli opened this issue Jul 4, 2023 · 1 comment
Closed

glob method errors in the latest release #403

ZeeshanTamboli opened this issue Jul 4, 2023 · 1 comment

Comments

@ZeeshanTamboli
Copy link

ZeeshanTamboli commented Jul 4, 2023

Environment

  • OS Version: Windows 10
  • Node.js Version: 18.16.0

Actual behavior

Getting the following error:

TypeError: patterns.reduce is not a function
    at Object.expandPatternsWithBraceExpansion (E:\material-ui\node_modules\fast-glob\out\utils\pattern.js:131:21)
    at processPatterns (E:\material-ui\node_modules\fast-glob\out\managers\tasks.js:27:34)
    at Object.generate (E:\material-ui\node_modules\fast-glob\out\managers\tasks.js:7:20)
    at getWorks (E:\material-ui\node_modules\fast-glob\out\index.js:91:31)
    at FastGlob (E:\material-ui\node_modules\fast-glob\out\index.js:10:19)
    at main (file:///E:/material-ui/scripts/testBuiltTypes.mjs:9:34)
    at file:///E:/material-ui/scripts/testBuiltTypes.mjs:36:1
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

Expected behavior

No errors.

Steps to reproduce

We have a script to check if there is any defect in the generated TypeScript .d.ts build files. We use fast-glob to traverse these build files. You can see the error in mui/material-ui#37789.

Code sample

import glob from 'fast-glob';

const declarationFiles = await glob('**/build/**/*.d.ts', {
   absolute: true,
   cwd: workspaceRoot,
   ignore: 'node_modules',
  });

There is an error in the latest version 3.3.0 which you can see in this GitHub pull request: mui/material-ui#37789.

After some debugging and going through the stack trace, it appears that the error is caused by this line of code in the processPatterns function. The processPatterns function expects a pattern as its first argument (but here it is settings.ignore), and the error pattern.reduce() is not a function occurs in the Object.expandPatternsWithBraceExpansion function. The braceExpansion option is set to true by default, triggering the expandPatternsWithBraceExpansion function. But

@ZeeshanTamboli
Copy link
Author

ZeeshanTamboli commented Jul 4, 2023

Sorry it's an update from my side. settings.ignore expects an array. So changed from ignore: 'node_modules' to ignore: ['node_modules']. Our syntax was wrong since long for settings.ignore. The error started to show up since the latest release because of its usage in processPatterns now.

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

1 participant