Skip to main content

ScanOptions

Extends

Properties

PropertyTypeDescriptionInherited from

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']

Options.basename

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 }));

Options.bash

capture?

boolean

Return regex matches in supporting methods.

Default

undefined;

Options.capture

contains?

boolean

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

Default

undefined;

Options.contains

cwd?

string

Current working directory. Used by picomatch.split()

Default

process.cwd();

Options.cwd

debug?

boolean

Debug regular expressions when an error is thrown.

Default

undefined;

Options.debug

dot?

boolean

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

Default

false;

Options.dot

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;

Options.expandRange

failglob?

boolean

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

Default

false;

Options.failglob

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;

Options.fastpaths

flags?

boolean

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

Default

undefined;

Options.flags

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;

Options.format

ignore?

string | readonly string[]

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

Default

undefined;

Options.ignore

keepQuotes?

boolean

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

Default

false;

Options.keepQuotes

literalBrackets?

boolean

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

Default

undefined;

Options.literalBrackets

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;

Options.lookbehinds

matchBase?

boolean

Alias for basename.

Default

false;

Options.matchBase

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;

Options.maxLength

nobrace?

boolean

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

Default

false;

Options.nobrace

nobracket?

boolean

Disable matching with regex brackets.

Default

undefined;

Options.nobracket

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;

Options.nocase

noext?

boolean

Alias for noextglob

Default

false;

Options.noext

noextglob?

boolean

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

Default

false;

Options.noextglob

noglobstar?

boolean

Disable matching with globstars (**).

Default

undefined;

Options.noglobstar

nonegate?

boolean

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

Default

undefined;

Options.nonegate

noquantifiers?

boolean

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

Default

false;

Options.noquantifiers

onIgnore?

(item) => void

Function to be called on ignored items.

Default

undefined;

Options.onIgnore

onMatch?

(item) => void

Function to be called on matched items.

Default

undefined;

Options.onMatch

onResult?

(item) => void

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

Default

undefined;

Options.onResult

parts?

boolean

When true, the returned object will include an array of strings representing each path "segment" in the scanned glob pattern. This is automatically enabled when options.tokens is true.

Default

false;

posix?

boolean

Support POSIX character classes ("posix brackets").

Default

false;

Options.posix

prepend?

boolean

String to prepend to the generated regex used for matching.

Default

undefined;

Options.prepend

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;

Options.regex

strictBrackets?

boolean

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

Default

undefined;

Options.strictBrackets

strictSlashes?

boolean

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

Default

undefined;

Options.strictSlashes

tokens?

boolean

When true, the returned object will include an array of tokens (objects), representing each path "segment" in the scanned glob pattern.

Default

false;

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']

Options.unescape

windows?

boolean

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

Default

undefined;

Options.windows