Skip to main content

bud.globSync

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

Usage

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

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

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