Skip to main content

bud.globSync

Search for matching files. This function is synchronous but there is an asynchronous version provided by bud.glob. The asynchronous version should be preferred.

Usage​

To look for files relative to the project root:

const results = bud.globSync('**/*.json')

To include additional search terms you can either treat the function as variadic or specify with an array:

const results = bud.globSync('**/*.json', '**/*.yml')

or:

const results = bud.globSync(['**/*.json', '**/*.yml'])

This function is compatible with the base handles used with bud.path.

So, the following would search for js files within the @src directory:

const results = bud.globSync('@src/**/*.js')

Syntax​

You can specify assets using fast-glob syntax.

  • * matches any number of characters, but not /
  • ? matches a single character, but not /
  • ** matches any number of characters, including /, as long as it's the only thing in a path part
  • {} allows for a comma-separated list of "or" expressions
  • ! at the beginning of a pattern will negate the match