Skip to main content

bud.glob

Search for matching files. This function is asynchronous but there is a synchronous version provided by bud.globSync

Usage

To look for files relative to the project root:

const results = await bud.glob('**/*.json')

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

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

or:

const results = await bud.glob(['**/*.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 = await bud.glob('@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