Skip to content

glob method errors in the latest release #403

@ZeeshanTamboli

Description

@ZeeshanTamboli

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions