Skip to main content
Version: Next (2.x)

Options

Extended by

Properties

PropertyTypeDescription

basename?

boolean

Allow glob patterns without slashes to match a file path based on its basename. Same behavior as minimatch option matchBase.

Default

false

Example

mm(['a/b.js', 'a/c.md'], '*.js');
//=> []

mm(['a/b.js', 'a/c.md'], '*.js', {matchBase: true});
//=> ['a/b.js']

bash?

boolean

Enabled by default, this option enforces bash-like behavior with stars immediately following a bracket expression. Bash bracket expressions are similar to regex character classes, but unlike regex, a star following a bracket expression does not repeat the bracketed characters. Instead, the star is treated the same as an other star.

Default

true

Example

var files = ['abc', 'ajz'];
console.log(mm(files, '[a-c]*'));
//=> ['abc', 'ajz']

console.log(mm(files, '[a-c]*', {bash: false}));

capture?

boolean

Return regex matches in supporting methods.

Default

undefined

contains?

boolean

Allows glob to match any part of the given string(s).

Default

undefined

cwd?

string

Current working directory. Used by picomatch.split()

Default

process.cwd()

debug?

boolean

Debug regular expressions when an error is thrown.

Default

undefined

dot?

boolean

Match dotfiles. Otherwise dotfiles are ignored unless a . is explicitly defined in the pattern.

Default

false

expandRange?

(left, right, options) => string

Custom function for expanding ranges in brace patterns, such as {a..z}. The function receives the range values as two arguments, and it must return a string to be used in the generated regex. It's recommended that returned strings be wrapped in parentheses. This option is overridden by the expandBrace option.

Default

undefined

failglob?

boolean

Similar to the --failglob behavior in Bash, throws an error when no matches are found.

Default

false

fastpaths?

boolean

To speed up processing, full parsing is skipped for a handful common glob patterns. Disable this behavior by setting this option to false.

Default

true

flags?

boolean

Regex flags to use in the generated regex. If defined, the nocase option will be overridden.

Default

undefined

format?

(returnedString) => string

Custom function for formatting the returned string. This is useful for removing leading slashes, converting Windows paths to Posix paths, etc.

Default

undefined

ignore?

string | readonly string[]

One or more glob patterns for excluding strings that should not be matched from the result.

Default

undefined

keepQuotes?

boolean

Retain quotes in the generated regex, since quotes may also be used as an alternative to backslashes.

Default

false

literalBrackets?

boolean

When true, brackets in the glob pattern will be escaped so that only literal brackets will be matched.

Default

undefined

lookbehinds?

boolean

Support regex positive and negative lookbehinds. Note that you must be using Node 8.1.10 or higher to enable regex lookbehinds.

Default

true

matchBase?

boolean

Alias for basename.

Default

false

maxLength?

number

Limit the max length of the input string. An error is thrown if the input string is longer than this value.

Default

65536

nobrace?

boolean

Disable brace matching, so that {a,b} and {1..3} would be treated as literal characters.

Default

false

nobracket?

boolean

Disable matching with regex brackets.

Default

undefined

nocase?

boolean

Perform case-insensitive matching. Equivalent to the regex i flag. Note that this option is ignored when the flags option is defined.

Default

false

noext?

boolean

Alias for noextglob

Default

false

noextglob?

boolean

Disable support for matching with extglobs (like +(a|b))

Default

false

noglobstar?

boolean

Disable matching with globstars (**).

Default

undefined

nonegate?

boolean

Disallow negation (!) patterns, and treat leading ! as a literal character to match.

Default

undefined

noquantifiers?

boolean

Disable support for regex quantifiers (like a{1,2}) and treat them as brace patterns to be expanded.

Default

false

onIgnore?

(item) => void

Function to be called on ignored items.

Default

undefined

onMatch?

(item) => void

Function to be called on matched items.

Default

undefined

onResult?

(item) => void

Function to be called on all items, regardless of whether or not they are matched or ignored.

Default

undefined

posix?

boolean

Support POSIX character classes ("posix brackets").

Default

false

prepend?

boolean

String to prepend to the generated regex used for matching.

Default

undefined

regex?

boolean

Use regular expression rules for + (instead of matching literal +), and for stars that follow closing parentheses or brackets (as in )* and ]*).

Default

false

strictBrackets?

boolean

Throw an error if brackets, braces, or parens are imbalanced.

Default

undefined

strictSlashes?

boolean

When true, picomatch won't match trailing slashes with single stars.

Default

undefined

unescape?

boolean

Remove backslashes from returned matches.

Default

undefined

Example

In this example we want to match a literal *:

mm.match(['abc', 'a\\*c'], 'a\\*c');
//=> ['a\\*c']

mm.match(['abc', 'a\\*c'], 'a\\*c', {unescape: true});
//=> ['a*c']

windows?

boolean

Convert all slashes in file paths to forward slashes. This does not convert slashes in the glob pattern itself

Default

undefined