Skip to main content

bud.glob

Glob for matching files. This function is asyncronous but there is a syncronous version provided by bud.globSync

Usage

To look for files relative to the project, you can simply pass the search:

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

To include additional search terms (matched as AND) 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