pax_global_header00006660000000000000000000000064142171431250014512gustar00rootroot0000000000000052 comment=002d0d184c95e76775528fa1dbe0c446518879b2 micromatch-4.0.5/000077500000000000000000000000001421714312500136465ustar00rootroot00000000000000micromatch-4.0.5/.editorconfig000066400000000000000000000003271421714312500163250ustar00rootroot00000000000000# http://editorconfig.org/ root = true [*] charset = utf-8 end_of_line = lf indent_size = 2 indent_style = space insert_final_newline = true trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false micromatch-4.0.5/.eslintrc.json000066400000000000000000000073251421714312500164510ustar00rootroot00000000000000{ "extends": [ "eslint:recommended" ], "env": { "browser": false, "es6": true, "node": true, "mocha": true }, "parserOptions":{ "ecmaVersion": 9, "sourceType": "module", "ecmaFeatures": { "modules": true, "experimentalObjectRestSpread": true } }, "globals": { "document": false, "navigator": false, "window": false }, "rules": { "accessor-pairs": 2, "arrow-spacing": [2, { "before": true, "after": true }], "block-spacing": [2, "always"], "brace-style": [2, "1tbs", { "allowSingleLine": true }], "comma-dangle": [2, "never"], "comma-spacing": [2, { "before": false, "after": true }], "comma-style": [2, "last"], "constructor-super": 2, "curly": [2, "multi-line"], "dot-location": [2, "property"], "eol-last": 2, "eqeqeq": [2, "allow-null"], "generator-star-spacing": [2, { "before": true, "after": true }], "handle-callback-err": [2, "^(err|error)$" ], "indent": [2, 2, { "SwitchCase": 1 }], "key-spacing": [2, { "beforeColon": false, "afterColon": true }], "keyword-spacing": [2, { "before": true, "after": true }], "new-cap": [2, { "newIsCap": true, "capIsNew": false }], "new-parens": 2, "no-array-constructor": 2, "no-caller": 2, "no-class-assign": 2, "no-cond-assign": 2, "no-const-assign": 2, "no-control-regex": 2, "no-debugger": 2, "no-delete-var": 2, "no-dupe-args": 2, "no-dupe-class-members": 2, "no-dupe-keys": 2, "no-duplicate-case": 2, "no-empty-character-class": 2, "no-eval": 2, "no-ex-assign": 2, "no-extend-native": 2, "no-extra-bind": 2, "no-extra-boolean-cast": 2, "no-extra-parens": [2, "functions"], "no-fallthrough": 2, "no-floating-decimal": 2, "no-func-assign": 2, "no-implied-eval": 2, "no-inner-declarations": [2, "functions"], "no-invalid-regexp": 2, "no-irregular-whitespace": 2, "no-iterator": 2, "no-label-var": 2, "no-labels": 2, "no-lone-blocks": 2, "no-mixed-spaces-and-tabs": 2, "no-multi-spaces": 2, "no-multi-str": 2, "no-multiple-empty-lines": [2, { "max": 1 }], "no-native-reassign": 0, "no-negated-in-lhs": 2, "no-new": 2, "no-new-func": 2, "no-new-object": 2, "no-new-require": 2, "no-new-wrappers": 2, "no-obj-calls": 2, "no-octal": 2, "no-octal-escape": 2, "no-proto": 0, "no-redeclare": 2, "no-regex-spaces": 2, "no-return-assign": 2, "no-self-compare": 2, "no-sequences": 2, "no-shadow-restricted-names": 2, "no-spaced-func": 2, "no-sparse-arrays": 2, "no-this-before-super": 2, "no-throw-literal": 2, "no-trailing-spaces": 0, "no-undef": 2, "no-undef-init": 2, "no-unexpected-multiline": 2, "no-unneeded-ternary": [2, { "defaultAssignment": false }], "no-unreachable": 2, "no-unused-vars": [2, { "vars": "all", "args": "none" }], "no-useless-call": 0, "no-with": 2, "one-var": [0, { "initialized": "never" }], "operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }], "padded-blocks": [0, "never"], "quotes": [2, "single", "avoid-escape"], "radix": 2, "semi": [2, "always"], "semi-spacing": [2, { "before": false, "after": true }], "space-before-blocks": [2, "always"], "space-before-function-paren": [2, "never"], "space-in-parens": [2, "never"], "space-infix-ops": 2, "space-unary-ops": [2, { "words": true, "nonwords": false }], "spaced-comment": [0, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }], "use-isnan": 2, "valid-typeof": 2, "wrap-iife": [2, "any"], "yoda": [2, "never"] } } micromatch-4.0.5/.gitattributes000077500000000000000000000002001421714312500165340ustar00rootroot00000000000000# Enforce Unix newlines * text eol=lf # binaries *.ai binary *.psd binary *.jpg binary *.gif binary *.png binary *.jpeg binary micromatch-4.0.5/.github/000077500000000000000000000000001421714312500152065ustar00rootroot00000000000000micromatch-4.0.5/.github/FUNDING.yml000066400000000000000000000000371421714312500170230ustar00rootroot00000000000000github: [jonschlinkert, doowb] micromatch-4.0.5/.github/contributing.md000066400000000000000000000121661421714312500202450ustar00rootroot00000000000000# Contributing to micromatch First and foremost, thank you! We appreciate that you want to contribute to micromatch, your time is valuable, and your contributions mean a lot to us. ## Important! By contributing to this project, you: * Agree that you have authored 100% of the content * Agree that you have the necessary rights to the content * Agree that you have received the necessary permissions from your employer to make the contributions (if applicable) * Agree that the content you contribute may be provided under the Project license(s) * Agree that, if you did not author 100% of the content, the appropriate licenses and copyrights have been added along with any other necessary attribution. ## Getting started **What does "contributing" mean?** Creating an issue is the simplest form of contributing to a project. But there are many ways to contribute, including the following: - Updating or correcting documentation - Feature requests - Bug reports If you'd like to learn more about contributing in general, the [Guide to Idiomatic Contributing](https://github.com/jonschlinkert/idiomatic-contributing) has a lot of useful information. **Showing support for micromatch** Please keep in mind that open source software is built by people like you, who spend their free time creating things the rest the community can use. Don't have time to contribute? No worries, here are some other ways to show your support for micromatch: - star the [project](https://github.com/micromatch/micromatch) - tweet your support for micromatch ## Issues Please only create issues for bug reports or feature requests. Issues discussing any other topics may be closed by the project's maintainers without further explanation. Do not create issues about bumping dependencies unless a bug has been identified and you can demonstrate that it effects this library. ### Before creating an issue Please try to determine if the issue is caused by an underlying library, and if so, create the issue there. Sometimes this is difficult to know. We only ask that you attempt to give a reasonable attempt to find out. Oftentimes the readme will have advice about where to go to create issues. Try to follow these guidelines - **Avoid creating issues for implementation help**. It's much better for discoverability, SEO, and semantics - to keep the issue tracker focused on bugs and feature requests - to ask implementation-related questions on [stackoverflow.com][so] - **Investigate the issue**: - **Check the readme** - oftentimes you will find notes about creating issues, and where to go depending on the type of issue. - Create the issue in the appropriate repository. ### Creating an issue Please be as descriptive as possible when creating an issue. Give us the information we need to successfully answer your question or address your issue by answering the following in your issue: - **version**: please note the version of micromatch are you using - **extensions, plugins, helpers, etc** (if applicable): please list any extensions you're using - **error messages**: please paste any error messages into the issue, or a [gist](https://gist.github.com/) ### Closing issues The original poster or the maintainers of micromatch may close an issue at any time. Typically, but not exclusively, issues are closed when: - The issue is resolved - The project's maintainers have determined the issue is out of scope - An issue is clearly a duplicate of another issue, in which case the duplicate issue will be linked. - A discussion has clearly run its course ## Next steps **Tips for creating idiomatic issues** Spending just a little extra time to review best practices and brush up on your contributing skills will, at minimum, make your issue easier to read, easier to resolve, and more likely to be found by others who have the same or similar issue in the future. At best, it will open up doors and potential career opportunities by helping you be at your best. The following resources were hand-picked to help you be the most effective contributor you can be: - The [Guide to Idiomatic Contributing](https://github.com/jonschlinkert/idiomatic-contributing) is a great place for newcomers to start, but there is also information for experienced contributors there. - Take some time to learn basic markdown. We can't stress this enough. Don't start pasting code into GitHub issues before you've taken a moment to review this [markdown cheatsheet](https://gist.github.com/jonschlinkert/5854601) - The GitHub guide to [basic markdown](https://help.github.com/articles/markdown-basics/) is another great markdown resource. - Learn about [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown/). And if you want to really go above and beyond, read [mastering markdown](https://guides.github.com/features/mastering-markdown/). At the very least, please try to: - Use backticks to wrap code. This ensures that it retains its formatting and isn't modified when it's rendered by GitHub, and makes the code more readable to others - When applicable, use syntax highlighting by adding the correct language name after the first "code fence" [so]: http://stackoverflow.com/questions/tagged/micromatch micromatch-4.0.5/.github/issue_template.md000066400000000000000000000005471421714312500205610ustar00rootroot00000000000000_(Thanks for reporting an issue to micromatch! If you haven't already read the [contributor guidelines](contributing.md), Please do that now, then proceed to fill out the details below.)_ ## Please describe the **minimum necessary steps** to reproduce this issue: … ## What is happening that shouldn't be? … ## What should be happening instead? … micromatch-4.0.5/.github/pull_request_template.md000066400000000000000000000057511421714312500221570ustar00rootroot00000000000000Hello, and thanks for contributing to micromatch! ## tldr There are three main goals in this document, depending on the nature of your pr: - [description](#description): please tell us about your pr - [checklist](#checklist): please review the checklist that is most closly related to your pr The following sections provide more detail on each. **Improve this document** Please don't hesitate to [ask questions][issues] for clarification, or to [make suggestions][issues] (or a pull request) to improve this document. ## Description To help the project's maintainers and community to quickly understand the nature of your pull request, please create a description that incorporates the following elements: - [] what is accomplished by the pr - [] if there is something potentially controversial in your pr, please take a moment to tell us about your choices ## Checklist Please use the checklist that is most closely related to your pr _(you only need to use one checklist, and you can skip items that aren't applicable or don't make sense)_: - [fixing typos]() - [documentation]() - [bug fix]() - [new feature]() - [other]() ### Fixing typos - [ ] Please review the [readme advice]() section before submitting changes ### Documentation - [ ] Please review the [readme advice](#readme-advice) section before submitting changes ### Bug Fix - [ ] All existing unit tests are still passing (if applicable) - [ ] Add new passing unit tests to cover the code introduced by your pr - [ ] Update the readme (see [readme advice](#readme-advice)) - [ ] Update or add any necessary API documentation ### New Feature - [ ] If this is a big feature with breaking changes, consider [opening an issue][issues] to discuss first. This is completely up to you, but please keep in mind that your pr might not be accepted. - [ ] Run unit tests to ensure all existing tests are still passing - [ ] Add new passing unit tests to cover the code introduced by your pr - [ ] Update the readme (see [readme advice](#readme-advice)) Thanks for contributing! ## Readme advice Please review this section if you are updating readme documentation. **Readme template** This project uses [verb][] for documentation. Verb generates the project's readme documentation from the [.verb.md](../.verb.md) template in the root of this project. Make all documentation changes in `.verb.md`, and please _do not edit the readme.md directly_, or your changes might accidentally get overwritten. **Code comments** Please add code comments (following the same style as existing comments) to describe any code changes or new code introduced by your pull request. **Optionally build the readme** Any changes made `.verb.md` and/or code comments will be automatically incorporated into the README documentation the next time `verb` is run. We can take care of building the documentation for you when we merge in your changes, or feel free to run [verb][] yourself. Whatever you prefer is fine with us. [issues]: ../../issues [verb]: https://github.com/verbose/verb micromatch-4.0.5/.github/workflows/000077500000000000000000000000001421714312500172435ustar00rootroot00000000000000micromatch-4.0.5/.github/workflows/test.yml000066400000000000000000000007751421714312500207560ustar00rootroot00000000000000name: Tests on: [push, pull_request] env: CI: true jobs: test: name: Node.js ${{ matrix.node-version }} @ ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] node-version: [10, 12, 14, 16, 17] steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test micromatch-4.0.5/.gitignore000066400000000000000000000004561421714312500156430ustar00rootroot00000000000000# always ignore files *.DS_Store .idea .vscode *.sublime-* # test related, or directories generated by tests test/actual actual coverage .nyc* # npm node_modules npm-debug.log # yarn yarn.lock yarn-error.log # misc _gh_pages _draft _drafts bower_components vendor temp tmp TODO.md package-lock.jsonmicromatch-4.0.5/.npmrc000066400000000000000000000000231421714312500147610ustar00rootroot00000000000000package-lock=false micromatch-4.0.5/.verb.md000066400000000000000000000534571421714312500152220ustar00rootroot00000000000000## Quickstart ```js const micromatch = require('micromatch'); // micromatch(list, patterns[, options]); ``` The [main export](#micromatch) takes a list of strings and one or more glob patterns: ```js console.log(micromatch(['foo', 'bar', 'baz', 'qux'], ['f*', 'b*'])) //=> ['foo', 'bar', 'baz'] console.log(micromatch(['foo', 'bar', 'baz', 'qux'], ['*', '!b*'])) //=> ['foo', 'qux'] ``` Use [.isMatch()](#ismatch) to for boolean matching: ```js console.log(micromatch.isMatch('foo', 'f*')) //=> true console.log(micromatch.isMatch('foo', ['b*', 'f*'])) //=> true ``` [Switching](#switching-to-micromatch) from minimatch and multimatch is easy!
## Why use micromatch? > micromatch is a [replacement](#switching-to-micromatch) for minimatch and multimatch - Supports all of the same matching features as [minimatch][] and [multimatch][] - More complete support for the Bash 4.3 specification than minimatch and multimatch. Micromatch passes _all of the spec tests_ from bash, including some that bash still fails. - **Fast & Performant** - Loads in about 5ms and performs [fast matches](#benchmarks). - **Glob matching** - Using wildcards (`*` and `?`), globstars (`**`) for nested directories - **[Advanced globbing](#extended-globbing)** - Supports [extglobs](#extglobs), [braces](#braces-1), and [POSIX brackets](#posix-bracket-expressions), and support for escaping special characters with `\` or quotes. - **Accurate** - Covers more scenarios [than minimatch](https://github.com/yarnpkg/yarn/pull/3339) - **Well tested** - More than 5,000 [test assertions](./test) - **Windows support** - More reliable windows support than minimatch and multimatch. - **[Safe][braces]{#braces-is-safe}** - Micromatch is not subject to DoS with brace patterns like minimatch and multimatch. ### Matching features * Support for multiple glob patterns (no need for wrappers like multimatch) * Wildcards (`**`, `*.js`) * Negation (`'!a/*.js'`, `'*!(b).js'`) * [extglobs](#extglobs) (`+(x|y)`, `!(a|b)`) * [POSIX character classes](#posix-bracket-expressions) (`[[:alpha:][:digit:]]`) * [brace expansion][braces] (`foo/{1..5}.md`, `bar/{a,b,c}.js`) * regex character classes (`foo-[1-5].js`) * regex logical "or" (`foo/(abc|xyz).js`) You can mix and match these features to create whatever patterns you need! ## Switching to micromatch _(There is one notable difference between micromatch and minimatch in regards to how backslashes are handled. See [the notes about backslashes](#backslashes) for more information.)_ ### From minimatch Use [micromatch.isMatch()](#ismatch) instead of `minimatch()`: ```js console.log(micromatch.isMatch('foo', 'b*')); //=> false ``` Use [micromatch.match()](#match) instead of `minimatch.match()`: ```js console.log(micromatch.match(['foo', 'bar'], 'b*')); //=> 'bar' ``` ### From multimatch Same signature: ```js console.log(micromatch(['foo', 'bar', 'baz'], ['f*', '*z'])); //=> ['foo', 'baz'] ``` ## API {%= apidocs("index.js") %} ## Options | **Option** | **Type** | **Default value** | **Description** | | --- | --- | --- | --- | | `basename` | `boolean` | `false` | If set, then patterns without slashes will be matched against the basename of the path if it contains slashes. For example, `a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`. | | `bash` | `boolean` | `false` | Follow bash matching rules more strictly - disallows backslashes as escape characters, and treats single stars as globstars (`**`). | | `capture` | `boolean` | `undefined` | Return regex matches in supporting methods. | | `contains` | `boolean` | `undefined` | Allows glob to match any part of the given string(s). | | `cwd` | `string` | `process.cwd()` | Current working directory. Used by `picomatch.split()` | | `debug` | `boolean` | `undefined` | Debug regular expressions when an error is thrown. | | `dot` | `boolean` | `false` | Match dotfiles. Otherwise dotfiles are ignored unless a `.` is explicitly defined in the pattern. | | `expandRange` | `function` | `undefined` | 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. | | `failglob` | `boolean` | `false` | Similar to the `failglob` behavior in Bash, throws an error when no matches are found. Based on the bash option of the same name. | | `fastpaths` | `boolean` | `true` | To speed up processing, full parsing is skipped for a handful common glob patterns. Disable this behavior by setting this option to `false`. | | `flags` | `boolean` | `undefined` | Regex flags to use in the generated regex. If defined, the `nocase` option will be overridden. | | [format](#optionsformat) | `function` | `undefined` | Custom function for formatting the returned string. This is useful for removing leading slashes, converting Windows paths to Posix paths, etc. | | `ignore` | `array|string` | `undefined` | One or more glob patterns for excluding strings that should not be matched from the result. | | `keepQuotes` | `boolean` | `false` | Retain quotes in the generated regex, since quotes may also be used as an alternative to backslashes. | | `literalBrackets` | `boolean` | `undefined` | When `true`, brackets in the glob pattern will be escaped so that only literal brackets will be matched. | | `lookbehinds` | `boolean` | `true` | Support regex positive and negative lookbehinds. Note that you must be using Node 8.1.10 or higher to enable regex lookbehinds. | | `matchBase` | `boolean` | `false` | Alias for `basename` | | `maxLength` | `boolean` | `65536` | Limit the max length of the input string. An error is thrown if the input string is longer than this value. | | `nobrace` | `boolean` | `false` | Disable brace matching, so that `{a,b}` and `{1..3}` would be treated as literal characters. | | `nobracket` | `boolean` | `undefined` | Disable matching with regex brackets. | | `nocase` | `boolean` | `false` | Perform case-insensitive matching. Equivalent to the regex `i` flag. Note that this option is ignored when the `flags` option is defined. | | `nodupes` | `boolean` | `true` | Deprecated, use `nounique` instead. This option will be removed in a future major release. By default duplicates are removed. Disable uniquification by setting this option to false. | | `noext` | `boolean` | `false` | Alias for `noextglob` | | `noextglob` | `boolean` | `false` | Disable support for matching with [extglobs](#extglobs) (like `+(a|b)`) | | `noglobstar` | `boolean` | `false` | Disable support for matching nested directories with globstars (`**`) | | `nonegate` | `boolean` | `false` | Disable support for negating with leading `!` | | `noquantifiers` | `boolean` | `false` | Disable support for regex quantifiers (like `a{1,2}`) and treat them as brace patterns to be expanded. | | [onIgnore](#optionsonIgnore) | `function` | `undefined` | Function to be called on ignored items. | | [onMatch](#optionsonMatch) | `function` | `undefined` | Function to be called on matched items. | | [onResult](#optionsonResult) | `function` | `undefined` | Function to be called on all items, regardless of whether or not they are matched or ignored. | | `posix` | `boolean` | `false` | Support [POSIX character classes](#posix-bracket-expressions) ("posix brackets"). | | `posixSlashes` | `boolean` | `undefined` | Convert all slashes in file paths to forward slashes. This does not convert slashes in the glob pattern itself | | `prepend` | `string` | `undefined` | String to prepend to the generated regex used for matching. | | `regex` | `boolean` | `false` | Use regular expression rules for `+` (instead of matching literal `+`), and for stars that follow closing parentheses or brackets (as in `)*` and `]*`). | | `strictBrackets` | `boolean` | `undefined` | Throw an error if brackets, braces, or parens are imbalanced. | | `strictSlashes` | `boolean` | `undefined` | When true, picomatch won't match trailing slashes with single stars. | | `unescape` | `boolean` | `undefined` | Remove preceding backslashes from escaped glob characters before creating the regular expression to perform matches. | | `unixify` | `boolean` | `undefined` | Alias for `posixSlashes`, for backwards compatitibility. | ## Options Examples ### options.basename Allow glob patterns without slashes to match a file path based on its basename. Same behavior as [minimatch][] option `matchBase`. **Type**: `Boolean` **Default**: `false` **Example** ```js micromatch(['a/b.js', 'a/c.md'], '*.js'); //=> [] micromatch(['a/b.js', 'a/c.md'], '*.js', { basename: true }); //=> ['a/b.js'] ``` ### options.bash 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 any other star. **Type**: `Boolean` **Default**: `true` **Example** ```js const files = ['abc', 'ajz']; console.log(micromatch(files, '[a-c]*')); //=> ['abc', 'ajz'] console.log(micromatch(files, '[a-c]*', { bash: false })); ``` ### options.expandRange **Type**: `function` **Default**: `undefined` Custom function for expanding ranges in brace patterns. The [fill-range][] library is ideal for this purpose, or you can use custom code to do whatever you need. **Example** The following example shows how to create a glob that matches a numeric folder name between `01` and `25`, with leading zeros. ```js const fill = require('fill-range'); const regex = micromatch.makeRe('foo/{01..25}/bar', { expandRange(a, b) { return `(${fill(a, b, { toRegex: true })})`; } }); console.log(regex) //=> /^(?:foo\/((?:0[1-9]|1[0-9]|2[0-5]))\/bar)$/ console.log(regex.test('foo/00/bar')) // false console.log(regex.test('foo/01/bar')) // true console.log(regex.test('foo/10/bar')) // true console.log(regex.test('foo/22/bar')) // true console.log(regex.test('foo/25/bar')) // true console.log(regex.test('foo/26/bar')) // false ``` ### options.format **Type**: `function` **Default**: `undefined` Custom function for formatting strings before they're matched. **Example** ```js // strip leading './' from strings const format = str => str.replace(/^\.\//, ''); const isMatch = picomatch('foo/*.js', { format }); console.log(isMatch('./foo/bar.js')) //=> true ``` ### options.ignore String or array of glob patterns to match files to ignore. **Type**: `String|Array` **Default**: `undefined` ```js const isMatch = micromatch.matcher('*', { ignore: 'f*' }); console.log(isMatch('foo')) //=> false console.log(isMatch('bar')) //=> true console.log(isMatch('baz')) //=> true ``` ### options.matchBase Alias for [options.basename](#options-basename). ### options.noextglob Disable extglob support, so that [extglobs](#extglobs) are regarded as literal characters. **Type**: `Boolean` **Default**: `undefined` **Examples** ```js console.log(micromatch(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)')); //=> ['a/b', 'a/!(z)'] console.log(micromatch(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)', { noextglob: true })); //=> ['a/!(z)'] (matches only as literal characters) ``` ### options.nonegate Disallow negation (`!`) patterns, and treat leading `!` as a literal character to match. **Type**: `Boolean` **Default**: `undefined` ### options.noglobstar Disable matching with globstars (`**`). **Type**: `Boolean` **Default**: `undefined` ```js micromatch(['a/b', 'a/b/c', 'a/b/c/d'], 'a/**'); //=> ['a/b', 'a/b/c', 'a/b/c/d'] micromatch(['a/b', 'a/b/c', 'a/b/c/d'], 'a/**', {noglobstar: true}); //=> ['a/b'] ``` ### options.nonull Alias for [options.nullglob](#options-nullglob). ### options.nullglob If `true`, when no matches are found the actual (arrayified) glob pattern is returned instead of an empty array. Same behavior as [minimatch][] option `nonull`. **Type**: `Boolean` **Default**: `undefined` ### options.onIgnore ```js const onIgnore = ({ glob, regex, input, output }) => { console.log({ glob, regex, input, output }); // { glob: '*', regex: /^(?:(?!\.)(?=.)[^\/]*?\/?)$/, input: 'foo', output: 'foo' } }; const isMatch = micromatch.matcher('*', { onIgnore, ignore: 'f*' }); isMatch('foo'); isMatch('bar'); isMatch('baz'); ``` ### options.onMatch ```js const onMatch = ({ glob, regex, input, output }) => { console.log({ input, output }); // { input: 'some\\path', output: 'some/path' } // { input: 'some\\path', output: 'some/path' } // { input: 'some\\path', output: 'some/path' } }; const isMatch = micromatch.matcher('**', { onMatch, posixSlashes: true }); isMatch('some\\path'); isMatch('some\\path'); isMatch('some\\path'); ``` ### options.onResult ```js const onResult = ({ glob, regex, input, output }) => { console.log({ glob, regex, input, output }); }; const isMatch = micromatch('*', { onResult, ignore: 'f*' }); isMatch('foo'); isMatch('bar'); isMatch('baz'); ``` ### options.posixSlashes Convert path separators on returned files to posix/unix-style forward slashes. Aliased as `unixify` for backwards compatibility. **Type**: `Boolean` **Default**: `true` on windows, `false` everywhere else. **Example** ```js console.log(micromatch.match(['a\\b\\c'], 'a/**')); //=> ['a/b/c'] console.log(micromatch.match(['a\\b\\c'], { posixSlashes: false })); //=> ['a\\b\\c'] ``` ### options.unescape Remove backslashes from escaped glob characters before creating the regular expression to perform matches. **Type**: `Boolean` **Default**: `undefined` **Example** In this example we want to match a literal `*`: ```js console.log(micromatch.match(['abc', 'a\\*c'], 'a\\*c')); //=> ['a\\*c'] console.log(micromatch.match(['abc', 'a\\*c'], 'a\\*c', { unescape: true })); //=> ['a*c'] ```

## Extended globbing Micromatch supports the following extended globbing features. ### Extglobs Extended globbing, as described by the bash man page: | **pattern** | **regex equivalent** | **description** | | --- | --- | --- | | `?(pattern)` | `(pattern)?` | Matches zero or one occurrence of the given patterns | | `*(pattern)` | `(pattern)*` | Matches zero or more occurrences of the given patterns | | `+(pattern)` | `(pattern)+` | Matches one or more occurrences of the given patterns | | `@(pattern)` | `(pattern)` * | Matches one of the given patterns | | `!(pattern)` | N/A (equivalent regex is much more complicated) | Matches anything except one of the given patterns | * Note that `@` isn't a regex character. ### Braces Brace patterns can be used to match specific ranges or sets of characters. **Example** The pattern `{f,b}*/{1..3}/{b,q}*` would match any of following strings: ``` foo/1/bar foo/2/bar foo/3/bar baz/1/qux baz/2/qux baz/3/qux ``` Visit [braces][] to see the full range of features and options related to brace expansion, or to create brace matching or expansion related issues. ### Regex character classes Given the list: `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`: * `[ac].js`: matches both `a` and `c`, returning `['a.js', 'c.js']` * `[b-d].js`: matches from `b` to `d`, returning `['b.js', 'c.js', 'd.js']` * `a/[A-Z].js`: matches and uppercase letter, returning `['a/E.md']` Learn about [regex character classes][charclass]. ### Regex groups Given `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`: * `(a|c).js`: would match either `a` or `c`, returning `['a.js', 'c.js']` * `(b|d).js`: would match either `b` or `d`, returning `['b.js', 'd.js']` * `(b|[A-Z]).js`: would match either `b` or an uppercase letter, returning `['b.js', 'E.js']` As with regex, parens can be nested, so patterns like `((a|b)|c)/b` will work. Although brace expansion might be friendlier to use, depending on preference. ### POSIX bracket expressions POSIX brackets are intended to be more user-friendly than regex character classes. This of course is in the eye of the beholder. **Example** ```js console.log(micromatch.isMatch('a1', '[[:alpha:][:digit:]]')) //=> true console.log(micromatch.isMatch('a1', '[[:alpha:][:alpha:]]')) //=> false ``` *** ## Notes ### Bash 4.3 parity Whenever possible matching behavior is based on behavior Bash 4.3, which is mostly consistent with minimatch. However, it's suprising how many edge cases and rabbit holes there are with glob matching, and since there is no real glob specification, and micromatch is more accurate than both Bash and minimatch, there are cases where best-guesses were made for behavior. In a few cases where Bash had no answers, we used wildmatch (used by git) as a fallback. ### Backslashes There is an important, notable difference between minimatch and micromatch _in regards to how backslashes are handled_ in glob patterns. - Micromatch exclusively and explicitly reserves backslashes for escaping characters in a glob pattern, even on windows, which is consistent with bash behavior. _More importantly, unescaping globs can result in unsafe regular expressions_. - Minimatch converts all backslashes to forward slashes, which means you can't use backslashes to escape any characters in your glob patterns. We made this decision for micromatch for a couple of reasons: - Consistency with bash conventions. - Glob patterns are not filepaths. They are a type of [regular language][regular-language] that is converted to a JavaScript regular expression. Thus, when forward slashes are defined in a glob pattern, the resulting regular expression will match windows or POSIX path separators just fine. **A note about joining paths to globs** Note that when you pass something like `path.join('foo', '*')` to micromatch, you are creating a filepath and expecting it to still work as a glob pattern. This causes problems on windows, since the `path.sep` is `\\`. In other words, since `\\` is reserved as an escape character in globs, on windows `path.join('foo', '*')` would result in `foo\\*`, which tells micromatch to match `*` as a literal character. This is the same behavior as bash. To solve this, you might be inspired to do something like `'foo\\*'.replace(/\\/g, '/')`, but this causes another, potentially much more serious, problem. ## Benchmarks ### Running benchmarks Install dependencies for running benchmarks: ```sh $ cd bench && npm install ``` Run the benchmarks: ```sh $ npm run bench ``` ### Latest results As of {%= date() %} (longer bars are better): ```sh # .makeRe star micromatch x 2,232,802 ops/sec ±2.34% (89 runs sampled)) minimatch x 781,018 ops/sec ±6.74% (92 runs sampled)) # .makeRe star; dot=true micromatch x 1,863,453 ops/sec ±0.74% (93 runs sampled) minimatch x 723,105 ops/sec ±0.75% (93 runs sampled) # .makeRe globstar micromatch x 1,624,179 ops/sec ±2.22% (91 runs sampled) minimatch x 1,117,230 ops/sec ±2.78% (86 runs sampled)) # .makeRe globstars micromatch x 1,658,642 ops/sec ±0.86% (92 runs sampled) minimatch x 741,224 ops/sec ±1.24% (89 runs sampled)) # .makeRe with leading star micromatch x 1,525,014 ops/sec ±1.63% (90 runs sampled) minimatch x 561,074 ops/sec ±3.07% (89 runs sampled) # .makeRe - braces micromatch x 172,478 ops/sec ±2.37% (78 runs sampled) minimatch x 96,087 ops/sec ±2.34% (88 runs sampled))) # .makeRe braces - range (expanded) micromatch x 26,973 ops/sec ±0.84% (89 runs sampled) minimatch x 3,023 ops/sec ±0.99% (90 runs sampled)) # .makeRe braces - range (compiled) micromatch x 152,892 ops/sec ±1.67% (83 runs sampled) minimatch x 992 ops/sec ±3.50% (89 runs sampled)d)) # .makeRe braces - nested ranges (expanded) micromatch x 15,816 ops/sec ±13.05% (80 runs sampled) minimatch x 2,953 ops/sec ±1.64% (91 runs sampled) # .makeRe braces - nested ranges (compiled) micromatch x 110,881 ops/sec ±1.85% (82 runs sampled) minimatch x 1,008 ops/sec ±1.51% (91 runs sampled) # .makeRe braces - set (compiled) micromatch x 134,930 ops/sec ±3.54% (63 runs sampled)) minimatch x 43,242 ops/sec ±0.60% (93 runs sampled) # .makeRe braces - nested sets (compiled) micromatch x 94,455 ops/sec ±1.74% (69 runs sampled)) minimatch x 27,720 ops/sec ±1.84% (93 runs sampled)) ``` ## Contributing All contributions are welcome! Please read [the contributing guide](.github/contributing.md) to get started. **Bug reports** Please create an issue if you encounter a bug or matching behavior that doesn't seem correct. If you find a matching-related issue, please: - [research existing issues first](../../issues) (open and closed) - visit the [GNU Bash documentation][bash] to see how Bash deals with the pattern - visit the [minimatch][] documentation to cross-check expected behavior in node.js - if all else fails, since there is no real specification for globs we will probably need to discuss expected behavior and decide how to resolve it. which means any detail you can provide to help with this discussion would be greatly appreciated. **Platform issues** It's important to us that micromatch work consistently on all platforms. If you encounter any platform-specific matching or path related issues, please let us know (pull requests are also greatly appreciated). [regular-language]: https://en.wikipedia.org/wiki/Regular_language [bash]: https://www.gnu.org/software/bash/manual/ [charclass]: http://www.regular-expressions.info/charclass.html [extended]: http://mywiki.wooledge.org/BashGuide/Patterns#Extended_Globs [brackets]: https://github.com/micromatch/expand-brackets [braces]: https://github.com/micromatch/braces micromatch-4.0.5/CHANGELOG.md000066400000000000000000000132631421714312500154640ustar00rootroot00000000000000# Release history All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
Guiding Principles - Changelogs are for humans, not machines. - There should be an entry for every single version. - The same types of changes should be grouped. - Versions and sections should be linkable. - The latest version comes first. - The release date of each versions is displayed. - Mention whether you follow Semantic Versioning.
Types of changes Changelog entries are classified using the following labels _(from [keep-a-changelog](http://keepachangelog.com/)_): - `Added` for new features. - `Changed` for changes in existing functionality. - `Deprecated` for soon-to-be removed features. - `Removed` for now removed features. - `Fixed` for any bug fixes. - `Security` in case of vulnerabilities.
## [4.0.0] - 2019-03-20 ### Added - Adds support for `options.onMatch`. See the readme for details - Adds support for `options.onIgnore`. See the readme for details - Adds support for `options.onResult`. See the readme for details ### Breaking changes - Require Node.js >= 8.6 - Removed support for passing an array of brace patterns to `micromatch.braces()`. - To strictly enforce closing brackets (for `{`, `[`, and `(`), you must now use `strictBrackets=true` instead of `strictErrors`. - `cache` - caching and all related options and methods have been removed - `options.unixify` was renamed to `options.windows` - `options.nodupes` Was removed. Duplicates are always removed by default. You can override this with custom behavior by using the `onMatch`, `onResult` and `onIgnore` functions. - `options.snapdragon` was removed, as snapdragon is no longer used. - `options.sourcemap` was removed, as snapdragon is no longer used, which provided sourcemap support. ## [3.0.0] - 2017-04-11 Complete overhaul, with 36,000+ new unit tests validated against actual output generated by Bash and minimatch. More specifically, 35,000+ of the tests: - micromatch results are directly compared to bash results - in rare cases, when micromatch and bash disagree, micromatch's results are compared to minimatch's results - micromatch is much more accurate than minimatch, so there were cases where I had to make assumptions. I'll try to document these. This refactor introduces a parser and compiler that are supersets of more granular parsers and compilers from other sub-modules. Each of these sub-modules has a singular responsibility and focuses on a certain type of matching that aligns with a specific part of the Bash "expansion" API. These sub-modules work like plugins to seamlessly create the micromatch parser/compiler, so that strings are parsed in one pass, an [AST is created](https://gist.github.com/jonschlinkert/099c8914f56529f75bc757cc9e5e8e2a), then a new string is generated by the compiler. Here are those sub-modules with links to related prs on those modules if you want to see how they contribute to this code: [nanomatch](https://github.com/jonschlinkert/nanomatch) (new library) - glob expansion (`*`, `**`, `?` and `[...]`)) [braces](https://github.com/jonschlinkert/braces/pull/10) - brace expansion (`{1..10}`, `{a,b,c}`, etc) [extglob](https://github.com/jonschlinkert/extglob/pull/5) - extended globs (`!(a|b)`, `@(!(foo|bar))`, etc) [expand-brackets](https://github.com/jonschlinkert/expand-brackets/pull/5) - POSIX character classes `[[:alpha:][:digit:]]` **Added** - source map support (optionally created when using parse or compile - I have no idea what the use case is yet, but they come for free) (note that source maps are not generated for brace expansion at present, since the braces compiler uses a different strategy. I'll update if/when this changes). - parser is exposed, so that implementors can customize or override specific micromatch parsers if necessary - compiler is exposed, so that implementors can customize or override specific micromatch compilers if necessary **Fixed** - more accurate matching (passes 100% of Bash 4.3 of the brace expansion and extglob unit tests, as well as all Bash glob tests that are relevant to node.js usage, all minimatch tests, all brace-expansion tests, and also passes a couple of tests that bash fails) - even safer - micromatch has always generated optimized patterns so it's not subject to DoS exploits like minimatch (completely different than the regex DoS issue, minimatch and multimatch are still openly exposed to being used for DoS attacks), but more safeguards were built into this refactor **Changed** - the public API of this library did not change in this version and should be safe to upgrade without changing implentor code. However, we have released this as a major version for the following reasons: - out of an abundance of caution due to the large amount of code changed in this release - we have improved parser accuracy to such a degree that some implementors using invalid globs have noted change in behavior. If this is the case for you, please check that you are using a valid glob expression before logging a bug with this library ## [1.0.1] - 2016-12-12 **Added** - Support for windows path edge cases where backslashes are used in brackets or other unusual combinations. ## [1.0.0] - 2016-12-12 Stable release. ## [0.1.0] - 2016-10-08 First release. [Unreleased]: https://github.com/jonschlinkert/micromatch/compare/0.1.0...HEAD [0.2.0]: https://github.com/jonschlinkert/micromatch/compare/0.1.0...0.2.0 [keep-a-changelog]: https://github.com/olivierlacan/keep-a-changelog micromatch-4.0.5/LICENSE000077500000000000000000000021031421714312500146520ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014-present, Jon Schlinkert. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. micromatch-4.0.5/README.md000066400000000000000000001131031421714312500151240ustar00rootroot00000000000000# micromatch [![NPM version](https://img.shields.io/npm/v/micromatch.svg?style=flat)](https://www.npmjs.com/package/micromatch) [![NPM monthly downloads](https://img.shields.io/npm/dm/micromatch.svg?style=flat)](https://npmjs.org/package/micromatch) [![NPM total downloads](https://img.shields.io/npm/dt/micromatch.svg?style=flat)](https://npmjs.org/package/micromatch) [![Tests](https://github.com/micromatch/micromatch/actions/workflows/test.yml/badge.svg)](https://github.com/micromatch/micromatch/actions/workflows/test.yml) > Glob matching for javascript/node.js. A replacement and faster alternative to minimatch and multimatch. Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support. ## Table of Contents
Details - [Install](#install) - [Quickstart](#quickstart) - [Why use micromatch?](#why-use-micromatch) * [Matching features](#matching-features) - [Switching to micromatch](#switching-to-micromatch) * [From minimatch](#from-minimatch) * [From multimatch](#from-multimatch) - [API](#api) - [Options](#options) - [Options Examples](#options-examples) * [options.basename](#optionsbasename) * [options.bash](#optionsbash) * [options.expandRange](#optionsexpandrange) * [options.format](#optionsformat) * [options.ignore](#optionsignore) * [options.matchBase](#optionsmatchbase) * [options.noextglob](#optionsnoextglob) * [options.nonegate](#optionsnonegate) * [options.noglobstar](#optionsnoglobstar) * [options.nonull](#optionsnonull) * [options.nullglob](#optionsnullglob) * [options.onIgnore](#optionsonignore) * [options.onMatch](#optionsonmatch) * [options.onResult](#optionsonresult) * [options.posixSlashes](#optionsposixslashes) * [options.unescape](#optionsunescape) - [Extended globbing](#extended-globbing) * [Extglobs](#extglobs) * [Braces](#braces) * [Regex character classes](#regex-character-classes) * [Regex groups](#regex-groups) * [POSIX bracket expressions](#posix-bracket-expressions) - [Notes](#notes) * [Bash 4.3 parity](#bash-43-parity) * [Backslashes](#backslashes) - [Benchmarks](#benchmarks) * [Running benchmarks](#running-benchmarks) * [Latest results](#latest-results) - [Contributing](#contributing) - [About](#about)
## Install Install with [npm](https://www.npmjs.com/) (requires [Node.js](https://nodejs.org/en/) >=8.6): ```sh $ npm install --save micromatch ``` ## Quickstart ```js const micromatch = require('micromatch'); // micromatch(list, patterns[, options]); ``` The [main export](#micromatch) takes a list of strings and one or more glob patterns: ```js console.log(micromatch(['foo', 'bar', 'baz', 'qux'], ['f*', 'b*'])) //=> ['foo', 'bar', 'baz'] console.log(micromatch(['foo', 'bar', 'baz', 'qux'], ['*', '!b*'])) //=> ['foo', 'qux'] ``` Use [.isMatch()](#ismatch) to for boolean matching: ```js console.log(micromatch.isMatch('foo', 'f*')) //=> true console.log(micromatch.isMatch('foo', ['b*', 'f*'])) //=> true ``` [Switching](#switching-to-micromatch) from minimatch and multimatch is easy!
## Why use micromatch? > micromatch is a [replacement](#switching-to-micromatch) for minimatch and multimatch * Supports all of the same matching features as [minimatch](https://github.com/isaacs/minimatch) and [multimatch](https://github.com/sindresorhus/multimatch) * More complete support for the Bash 4.3 specification than minimatch and multimatch. Micromatch passes _all of the spec tests_ from bash, including some that bash still fails. * **Fast & Performant** - Loads in about 5ms and performs [fast matches](#benchmarks). * **Glob matching** - Using wildcards (`*` and `?`), globstars (`**`) for nested directories * **[Advanced globbing](#extended-globbing)** - Supports [extglobs](#extglobs), [braces](#braces-1), and [POSIX brackets](#posix-bracket-expressions), and support for escaping special characters with `\` or quotes. * **Accurate** - Covers more scenarios [than minimatch](https://github.com/yarnpkg/yarn/pull/3339) * **Well tested** - More than 5,000 [test assertions](./test) * **Windows support** - More reliable windows support than minimatch and multimatch. * **[Safe](https://github.com/micromatch/braces#braces-is-safe)** - Micromatch is not subject to DoS with brace patterns like minimatch and multimatch. ### Matching features * Support for multiple glob patterns (no need for wrappers like multimatch) * Wildcards (`**`, `*.js`) * Negation (`'!a/*.js'`, `'*!(b).js'`) * [extglobs](#extglobs) (`+(x|y)`, `!(a|b)`) * [POSIX character classes](#posix-bracket-expressions) (`[[:alpha:][:digit:]]`) * [brace expansion](https://github.com/micromatch/braces) (`foo/{1..5}.md`, `bar/{a,b,c}.js`) * regex character classes (`foo-[1-5].js`) * regex logical "or" (`foo/(abc|xyz).js`) You can mix and match these features to create whatever patterns you need! ## Switching to micromatch _(There is one notable difference between micromatch and minimatch in regards to how backslashes are handled. See [the notes about backslashes](#backslashes) for more information.)_ ### From minimatch Use [micromatch.isMatch()](#ismatch) instead of `minimatch()`: ```js console.log(micromatch.isMatch('foo', 'b*')); //=> false ``` Use [micromatch.match()](#match) instead of `minimatch.match()`: ```js console.log(micromatch.match(['foo', 'bar'], 'b*')); //=> 'bar' ``` ### From multimatch Same signature: ```js console.log(micromatch(['foo', 'bar', 'baz'], ['f*', '*z'])); //=> ['foo', 'baz'] ``` ## API **Params** * `list` **{String|Array}**: List of strings to match. * `patterns` **{String|Array}**: One or more glob patterns to use for matching. * `options` **{Object}**: See available [options](#options) * `returns` **{Array}**: Returns an array of matches **Example** ```js const mm = require('micromatch'); // mm(list, patterns[, options]); console.log(mm(['a.js', 'a.txt'], ['*.js'])); //=> [ 'a.js' ] ``` ### [.matcher](index.js#L104) Returns a matcher function from the given glob `pattern` and `options`. The returned function takes a string to match as its only argument and returns true if the string is a match. **Params** * `pattern` **{String}**: Glob pattern * `options` **{Object}** * `returns` **{Function}**: Returns a matcher function. **Example** ```js const mm = require('micromatch'); // mm.matcher(pattern[, options]); const isMatch = mm.matcher('*.!(*a)'); console.log(isMatch('a.a')); //=> false console.log(isMatch('a.b')); //=> true ``` ### [.isMatch](index.js#L123) Returns true if **any** of the given glob `patterns` match the specified `string`. **Params** * `str` **{String}**: The string to test. * `patterns` **{String|Array}**: One or more glob patterns to use for matching. * `[options]` **{Object}**: See available [options](#options). * `returns` **{Boolean}**: Returns true if any patterns match `str` **Example** ```js const mm = require('micromatch'); // mm.isMatch(string, patterns[, options]); console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true console.log(mm.isMatch('a.a', 'b.*')); //=> false ``` ### [.not](index.js#L148) Returns a list of strings that _**do not match any**_ of the given `patterns`. **Params** * `list` **{Array}**: Array of strings to match. * `patterns` **{String|Array}**: One or more glob pattern to use for matching. * `options` **{Object}**: See available [options](#options) for changing how matches are performed * `returns` **{Array}**: Returns an array of strings that **do not match** the given patterns. **Example** ```js const mm = require('micromatch'); // mm.not(list, patterns[, options]); console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a')); //=> ['b.b', 'c.c'] ``` ### [.contains](index.js#L188) Returns true if the given `string` contains the given pattern. Similar to [.isMatch](#isMatch) but the pattern can match any part of the string. **Params** * `str` **{String}**: The string to match. * `patterns` **{String|Array}**: Glob pattern to use for matching. * `options` **{Object}**: See available [options](#options) for changing how matches are performed * `returns` **{Boolean}**: Returns true if any of the patterns matches any part of `str`. **Example** ```js var mm = require('micromatch'); // mm.contains(string, pattern[, options]); console.log(mm.contains('aa/bb/cc', '*b')); //=> true console.log(mm.contains('aa/bb/cc', '*d')); //=> false ``` ### [.matchKeys](index.js#L230) Filter the keys of the given object with the given `glob` pattern and `options`. Does not attempt to match nested keys. If you need this feature, use [glob-object](https://github.com/jonschlinkert/glob-object) instead. **Params** * `object` **{Object}**: The object with keys to filter. * `patterns` **{String|Array}**: One or more glob patterns to use for matching. * `options` **{Object}**: See available [options](#options) for changing how matches are performed * `returns` **{Object}**: Returns an object with only keys that match the given patterns. **Example** ```js const mm = require('micromatch'); // mm.matchKeys(object, patterns[, options]); const obj = { aa: 'a', ab: 'b', ac: 'c' }; console.log(mm.matchKeys(obj, '*b')); //=> { ab: 'b' } ``` ### [.some](index.js#L259) Returns true if some of the strings in the given `list` match any of the given glob `patterns`. **Params** * `list` **{String|Array}**: The string or array of strings to test. Returns as soon as the first match is found. * `patterns` **{String|Array}**: One or more glob patterns to use for matching. * `options` **{Object}**: See available [options](#options) for changing how matches are performed * `returns` **{Boolean}**: Returns true if any `patterns` matches any of the strings in `list` **Example** ```js const mm = require('micromatch'); // mm.some(list, patterns[, options]); console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js'])); // true console.log(mm.some(['foo.js'], ['*.js', '!foo.js'])); // false ``` ### [.every](index.js#L295) Returns true if every string in the given `list` matches any of the given glob `patterns`. **Params** * `list` **{String|Array}**: The string or array of strings to test. * `patterns` **{String|Array}**: One or more glob patterns to use for matching. * `options` **{Object}**: See available [options](#options) for changing how matches are performed * `returns` **{Boolean}**: Returns true if all `patterns` matches all of the strings in `list` **Example** ```js const mm = require('micromatch'); // mm.every(list, patterns[, options]); console.log(mm.every('foo.js', ['foo.js'])); // true console.log(mm.every(['foo.js', 'bar.js'], ['*.js'])); // true console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js'])); // false console.log(mm.every(['foo.js'], ['*.js', '!foo.js'])); // false ``` ### [.all](index.js#L334) Returns true if **all** of the given `patterns` match the specified string. **Params** * `str` **{String|Array}**: The string to test. * `patterns` **{String|Array}**: One or more glob patterns to use for matching. * `options` **{Object}**: See available [options](#options) for changing how matches are performed * `returns` **{Boolean}**: Returns true if any patterns match `str` **Example** ```js const mm = require('micromatch'); // mm.all(string, patterns[, options]); console.log(mm.all('foo.js', ['foo.js'])); // true console.log(mm.all('foo.js', ['*.js', '!foo.js'])); // false console.log(mm.all('foo.js', ['*.js', 'foo.js'])); // true console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js'])); // true ``` ### [.capture](index.js#L361) Returns an array of matches captured by `pattern` in `string, or`null` if the pattern did not match. **Params** * `glob` **{String}**: Glob pattern to use for matching. * `input` **{String}**: String to match * `options` **{Object}**: See available [options](#options) for changing how matches are performed * `returns` **{Array|null}**: Returns an array of captures if the input matches the glob pattern, otherwise `null`. **Example** ```js const mm = require('micromatch'); // mm.capture(pattern, string[, options]); console.log(mm.capture('test/*.js', 'test/foo.js')); //=> ['foo'] console.log(mm.capture('test/*.js', 'foo/bar.css')); //=> null ``` ### [.makeRe](index.js#L387) Create a regular expression from the given glob `pattern`. **Params** * `pattern` **{String}**: A glob pattern to convert to regex. * `options` **{Object}** * `returns` **{RegExp}**: Returns a regex created from the given pattern. **Example** ```js const mm = require('micromatch'); // mm.makeRe(pattern[, options]); console.log(mm.makeRe('*.js')); //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/ ``` ### [.scan](index.js#L403) Scan a glob pattern to separate the pattern into segments. Used by the [split](#split) method. **Params** * `pattern` **{String}** * `options` **{Object}** * `returns` **{Object}**: Returns an object with **Example** ```js const mm = require('micromatch'); const state = mm.scan(pattern[, options]); ``` ### [.parse](index.js#L419) Parse a glob pattern to create the source string for a regular expression. **Params** * `glob` **{String}** * `options` **{Object}** * `returns` **{Object}**: Returns an object with useful properties and output to be used as regex source string. **Example** ```js const mm = require('micromatch'); const state = mm.parse(pattern[, options]); ``` ### [.braces](index.js#L446) Process the given brace `pattern`. **Params** * `pattern` **{String}**: String with brace pattern to process. * `options` **{Object}**: Any [options](#options) to change how expansion is performed. See the [braces](https://github.com/micromatch/braces) library for all available options. * `returns` **{Array}** **Example** ```js const { braces } = require('micromatch'); console.log(braces('foo/{a,b,c}/bar')); //=> [ 'foo/(a|b|c)/bar' ] console.log(braces('foo/{a,b,c}/bar', { expand: true })); //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ] ``` ## Options | **Option** | **Type** | **Default value** | **Description** | | --- | --- | --- | --- | | `basename` | `boolean` | `false` | If set, then patterns without slashes will be matched against the basename of the path if it contains slashes. For example, `a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`. | | `bash` | `boolean` | `false` | Follow bash matching rules more strictly - disallows backslashes as escape characters, and treats single stars as globstars (`**`). | | `capture` | `boolean` | `undefined` | Return regex matches in supporting methods. | | `contains` | `boolean` | `undefined` | Allows glob to match any part of the given string(s). | | `cwd` | `string` | `process.cwd()` | Current working directory. Used by `picomatch.split()` | | `debug` | `boolean` | `undefined` | Debug regular expressions when an error is thrown. | | `dot` | `boolean` | `false` | Match dotfiles. Otherwise dotfiles are ignored unless a `.` is explicitly defined in the pattern. | | `expandRange` | `function` | `undefined` | 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. | | `failglob` | `boolean` | `false` | Similar to the `failglob` behavior in Bash, throws an error when no matches are found. Based on the bash option of the same name. | | `fastpaths` | `boolean` | `true` | To speed up processing, full parsing is skipped for a handful common glob patterns. Disable this behavior by setting this option to `false`. | | `flags` | `boolean` | `undefined` | Regex flags to use in the generated regex. If defined, the `nocase` option will be overridden. | | [format](#optionsformat) | `function` | `undefined` | Custom function for formatting the returned string. This is useful for removing leading slashes, converting Windows paths to Posix paths, etc. | | `ignore` | `array\|string` | `undefined` | One or more glob patterns for excluding strings that should not be matched from the result. | | `keepQuotes` | `boolean` | `false` | Retain quotes in the generated regex, since quotes may also be used as an alternative to backslashes. | | `literalBrackets` | `boolean` | `undefined` | When `true`, brackets in the glob pattern will be escaped so that only literal brackets will be matched. | | `lookbehinds` | `boolean` | `true` | Support regex positive and negative lookbehinds. Note that you must be using Node 8.1.10 or higher to enable regex lookbehinds. | | `matchBase` | `boolean` | `false` | Alias for `basename` | | `maxLength` | `boolean` | `65536` | Limit the max length of the input string. An error is thrown if the input string is longer than this value. | | `nobrace` | `boolean` | `false` | Disable brace matching, so that `{a,b}` and `{1..3}` would be treated as literal characters. | | `nobracket` | `boolean` | `undefined` | Disable matching with regex brackets. | | `nocase` | `boolean` | `false` | Perform case-insensitive matching. Equivalent to the regex `i` flag. Note that this option is ignored when the `flags` option is defined. | | `nodupes` | `boolean` | `true` | Deprecated, use `nounique` instead. This option will be removed in a future major release. By default duplicates are removed. Disable uniquification by setting this option to false. | | `noext` | `boolean` | `false` | Alias for `noextglob` | | `noextglob` | `boolean` | `false` | Disable support for matching with [extglobs](#extglobs) (like `+(a\|b)`) | | `noglobstar` | `boolean` | `false` | Disable support for matching nested directories with globstars (`**`) | | `nonegate` | `boolean` | `false` | Disable support for negating with leading `!` | | `noquantifiers` | `boolean` | `false` | Disable support for regex quantifiers (like `a{1,2}`) and treat them as brace patterns to be expanded. | | [onIgnore](#optionsonIgnore) | `function` | `undefined` | Function to be called on ignored items. | | [onMatch](#optionsonMatch) | `function` | `undefined` | Function to be called on matched items. | | [onResult](#optionsonResult) | `function` | `undefined` | Function to be called on all items, regardless of whether or not they are matched or ignored. | | `posix` | `boolean` | `false` | Support [POSIX character classes](#posix-bracket-expressions) ("posix brackets"). | | `posixSlashes` | `boolean` | `undefined` | Convert all slashes in file paths to forward slashes. This does not convert slashes in the glob pattern itself | | `prepend` | `string` | `undefined` | String to prepend to the generated regex used for matching. | | `regex` | `boolean` | `false` | Use regular expression rules for `+` (instead of matching literal `+`), and for stars that follow closing parentheses or brackets (as in `)*` and `]*`). | | `strictBrackets` | `boolean` | `undefined` | Throw an error if brackets, braces, or parens are imbalanced. | | `strictSlashes` | `boolean` | `undefined` | When true, picomatch won't match trailing slashes with single stars. | | `unescape` | `boolean` | `undefined` | Remove preceding backslashes from escaped glob characters before creating the regular expression to perform matches. | | `unixify` | `boolean` | `undefined` | Alias for `posixSlashes`, for backwards compatitibility. | ## Options Examples ### options.basename Allow glob patterns without slashes to match a file path based on its basename. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `matchBase`. **Type**: `Boolean` **Default**: `false` **Example** ```js micromatch(['a/b.js', 'a/c.md'], '*.js'); //=> [] micromatch(['a/b.js', 'a/c.md'], '*.js', { basename: true }); //=> ['a/b.js'] ``` ### options.bash 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 any other star. **Type**: `Boolean` **Default**: `true` **Example** ```js const files = ['abc', 'ajz']; console.log(micromatch(files, '[a-c]*')); //=> ['abc', 'ajz'] console.log(micromatch(files, '[a-c]*', { bash: false })); ``` ### options.expandRange **Type**: `function` **Default**: `undefined` Custom function for expanding ranges in brace patterns. The [fill-range](https://github.com/jonschlinkert/fill-range) library is ideal for this purpose, or you can use custom code to do whatever you need. **Example** The following example shows how to create a glob that matches a numeric folder name between `01` and `25`, with leading zeros. ```js const fill = require('fill-range'); const regex = micromatch.makeRe('foo/{01..25}/bar', { expandRange(a, b) { return `(${fill(a, b, { toRegex: true })})`; } }); console.log(regex) //=> /^(?:foo\/((?:0[1-9]|1[0-9]|2[0-5]))\/bar)$/ console.log(regex.test('foo/00/bar')) // false console.log(regex.test('foo/01/bar')) // true console.log(regex.test('foo/10/bar')) // true console.log(regex.test('foo/22/bar')) // true console.log(regex.test('foo/25/bar')) // true console.log(regex.test('foo/26/bar')) // false ``` ### options.format **Type**: `function` **Default**: `undefined` Custom function for formatting strings before they're matched. **Example** ```js // strip leading './' from strings const format = str => str.replace(/^\.\//, ''); const isMatch = picomatch('foo/*.js', { format }); console.log(isMatch('./foo/bar.js')) //=> true ``` ### options.ignore String or array of glob patterns to match files to ignore. **Type**: `String|Array` **Default**: `undefined` ```js const isMatch = micromatch.matcher('*', { ignore: 'f*' }); console.log(isMatch('foo')) //=> false console.log(isMatch('bar')) //=> true console.log(isMatch('baz')) //=> true ``` ### options.matchBase Alias for [options.basename](#options-basename). ### options.noextglob Disable extglob support, so that [extglobs](#extglobs) are regarded as literal characters. **Type**: `Boolean` **Default**: `undefined` **Examples** ```js console.log(micromatch(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)')); //=> ['a/b', 'a/!(z)'] console.log(micromatch(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)', { noextglob: true })); //=> ['a/!(z)'] (matches only as literal characters) ``` ### options.nonegate Disallow negation (`!`) patterns, and treat leading `!` as a literal character to match. **Type**: `Boolean` **Default**: `undefined` ### options.noglobstar Disable matching with globstars (`**`). **Type**: `Boolean` **Default**: `undefined` ```js micromatch(['a/b', 'a/b/c', 'a/b/c/d'], 'a/**'); //=> ['a/b', 'a/b/c', 'a/b/c/d'] micromatch(['a/b', 'a/b/c', 'a/b/c/d'], 'a/**', {noglobstar: true}); //=> ['a/b'] ``` ### options.nonull Alias for [options.nullglob](#options-nullglob). ### options.nullglob If `true`, when no matches are found the actual (arrayified) glob pattern is returned instead of an empty array. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `nonull`. **Type**: `Boolean` **Default**: `undefined` ### options.onIgnore ```js const onIgnore = ({ glob, regex, input, output }) => { console.log({ glob, regex, input, output }); // { glob: '*', regex: /^(?:(?!\.)(?=.)[^\/]*?\/?)$/, input: 'foo', output: 'foo' } }; const isMatch = micromatch.matcher('*', { onIgnore, ignore: 'f*' }); isMatch('foo'); isMatch('bar'); isMatch('baz'); ``` ### options.onMatch ```js const onMatch = ({ glob, regex, input, output }) => { console.log({ input, output }); // { input: 'some\\path', output: 'some/path' } // { input: 'some\\path', output: 'some/path' } // { input: 'some\\path', output: 'some/path' } }; const isMatch = micromatch.matcher('**', { onMatch, posixSlashes: true }); isMatch('some\\path'); isMatch('some\\path'); isMatch('some\\path'); ``` ### options.onResult ```js const onResult = ({ glob, regex, input, output }) => { console.log({ glob, regex, input, output }); }; const isMatch = micromatch('*', { onResult, ignore: 'f*' }); isMatch('foo'); isMatch('bar'); isMatch('baz'); ``` ### options.posixSlashes Convert path separators on returned files to posix/unix-style forward slashes. Aliased as `unixify` for backwards compatibility. **Type**: `Boolean` **Default**: `true` on windows, `false` everywhere else. **Example** ```js console.log(micromatch.match(['a\\b\\c'], 'a/**')); //=> ['a/b/c'] console.log(micromatch.match(['a\\b\\c'], { posixSlashes: false })); //=> ['a\\b\\c'] ``` ### options.unescape Remove backslashes from escaped glob characters before creating the regular expression to perform matches. **Type**: `Boolean` **Default**: `undefined` **Example** In this example we want to match a literal `*`: ```js console.log(micromatch.match(['abc', 'a\\*c'], 'a\\*c')); //=> ['a\\*c'] console.log(micromatch.match(['abc', 'a\\*c'], 'a\\*c', { unescape: true })); //=> ['a*c'] ```

## Extended globbing Micromatch supports the following extended globbing features. ### Extglobs Extended globbing, as described by the bash man page: | **pattern** | **regex equivalent** | **description** | | --- | --- | --- | | `?(pattern)` | `(pattern)?` | Matches zero or one occurrence of the given patterns | | `*(pattern)` | `(pattern)*` | Matches zero or more occurrences of the given patterns | | `+(pattern)` | `(pattern)+` | Matches one or more occurrences of the given patterns | | `@(pattern)` | `(pattern)` * | Matches one of the given patterns | | `!(pattern)` | N/A (equivalent regex is much more complicated) | Matches anything except one of the given patterns | * Note that `@` isn't a regex character. ### Braces Brace patterns can be used to match specific ranges or sets of characters. **Example** The pattern `{f,b}*/{1..3}/{b,q}*` would match any of following strings: ``` foo/1/bar foo/2/bar foo/3/bar baz/1/qux baz/2/qux baz/3/qux ``` Visit [braces](https://github.com/micromatch/braces) to see the full range of features and options related to brace expansion, or to create brace matching or expansion related issues. ### Regex character classes Given the list: `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`: * `[ac].js`: matches both `a` and `c`, returning `['a.js', 'c.js']` * `[b-d].js`: matches from `b` to `d`, returning `['b.js', 'c.js', 'd.js']` * `a/[A-Z].js`: matches and uppercase letter, returning `['a/E.md']` Learn about [regex character classes](http://www.regular-expressions.info/charclass.html). ### Regex groups Given `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`: * `(a|c).js`: would match either `a` or `c`, returning `['a.js', 'c.js']` * `(b|d).js`: would match either `b` or `d`, returning `['b.js', 'd.js']` * `(b|[A-Z]).js`: would match either `b` or an uppercase letter, returning `['b.js', 'E.js']` As with regex, parens can be nested, so patterns like `((a|b)|c)/b` will work. Although brace expansion might be friendlier to use, depending on preference. ### POSIX bracket expressions POSIX brackets are intended to be more user-friendly than regex character classes. This of course is in the eye of the beholder. **Example** ```js console.log(micromatch.isMatch('a1', '[[:alpha:][:digit:]]')) //=> true console.log(micromatch.isMatch('a1', '[[:alpha:][:alpha:]]')) //=> false ``` *** ## Notes ### Bash 4.3 parity Whenever possible matching behavior is based on behavior Bash 4.3, which is mostly consistent with minimatch. However, it's suprising how many edge cases and rabbit holes there are with glob matching, and since there is no real glob specification, and micromatch is more accurate than both Bash and minimatch, there are cases where best-guesses were made for behavior. In a few cases where Bash had no answers, we used wildmatch (used by git) as a fallback. ### Backslashes There is an important, notable difference between minimatch and micromatch _in regards to how backslashes are handled_ in glob patterns. * Micromatch exclusively and explicitly reserves backslashes for escaping characters in a glob pattern, even on windows, which is consistent with bash behavior. _More importantly, unescaping globs can result in unsafe regular expressions_. * Minimatch converts all backslashes to forward slashes, which means you can't use backslashes to escape any characters in your glob patterns. We made this decision for micromatch for a couple of reasons: * Consistency with bash conventions. * Glob patterns are not filepaths. They are a type of [regular language](https://en.wikipedia.org/wiki/Regular_language) that is converted to a JavaScript regular expression. Thus, when forward slashes are defined in a glob pattern, the resulting regular expression will match windows or POSIX path separators just fine. **A note about joining paths to globs** Note that when you pass something like `path.join('foo', '*')` to micromatch, you are creating a filepath and expecting it to still work as a glob pattern. This causes problems on windows, since the `path.sep` is `\\`. In other words, since `\\` is reserved as an escape character in globs, on windows `path.join('foo', '*')` would result in `foo\\*`, which tells micromatch to match `*` as a literal character. This is the same behavior as bash. To solve this, you might be inspired to do something like `'foo\\*'.replace(/\\/g, '/')`, but this causes another, potentially much more serious, problem. ## Benchmarks ### Running benchmarks Install dependencies for running benchmarks: ```sh $ cd bench && npm install ``` Run the benchmarks: ```sh $ npm run bench ``` ### Latest results As of March 24, 2022 (longer bars are better): ```sh # .makeRe star micromatch x 2,232,802 ops/sec ±2.34% (89 runs sampled)) minimatch x 781,018 ops/sec ±6.74% (92 runs sampled)) # .makeRe star; dot=true micromatch x 1,863,453 ops/sec ±0.74% (93 runs sampled) minimatch x 723,105 ops/sec ±0.75% (93 runs sampled) # .makeRe globstar micromatch x 1,624,179 ops/sec ±2.22% (91 runs sampled) minimatch x 1,117,230 ops/sec ±2.78% (86 runs sampled)) # .makeRe globstars micromatch x 1,658,642 ops/sec ±0.86% (92 runs sampled) minimatch x 741,224 ops/sec ±1.24% (89 runs sampled)) # .makeRe with leading star micromatch x 1,525,014 ops/sec ±1.63% (90 runs sampled) minimatch x 561,074 ops/sec ±3.07% (89 runs sampled) # .makeRe - braces micromatch x 172,478 ops/sec ±2.37% (78 runs sampled) minimatch x 96,087 ops/sec ±2.34% (88 runs sampled))) # .makeRe braces - range (expanded) micromatch x 26,973 ops/sec ±0.84% (89 runs sampled) minimatch x 3,023 ops/sec ±0.99% (90 runs sampled)) # .makeRe braces - range (compiled) micromatch x 152,892 ops/sec ±1.67% (83 runs sampled) minimatch x 992 ops/sec ±3.50% (89 runs sampled)d)) # .makeRe braces - nested ranges (expanded) micromatch x 15,816 ops/sec ±13.05% (80 runs sampled) minimatch x 2,953 ops/sec ±1.64% (91 runs sampled) # .makeRe braces - nested ranges (compiled) micromatch x 110,881 ops/sec ±1.85% (82 runs sampled) minimatch x 1,008 ops/sec ±1.51% (91 runs sampled) # .makeRe braces - set (compiled) micromatch x 134,930 ops/sec ±3.54% (63 runs sampled)) minimatch x 43,242 ops/sec ±0.60% (93 runs sampled) # .makeRe braces - nested sets (compiled) micromatch x 94,455 ops/sec ±1.74% (69 runs sampled)) minimatch x 27,720 ops/sec ±1.84% (93 runs sampled)) ``` ## Contributing All contributions are welcome! Please read [the contributing guide](.github/contributing.md) to get started. **Bug reports** Please create an issue if you encounter a bug or matching behavior that doesn't seem correct. If you find a matching-related issue, please: * [research existing issues first](../../issues) (open and closed) * visit the [GNU Bash documentation](https://www.gnu.org/software/bash/manual/) to see how Bash deals with the pattern * visit the [minimatch](https://github.com/isaacs/minimatch) documentation to cross-check expected behavior in node.js * if all else fails, since there is no real specification for globs we will probably need to discuss expected behavior and decide how to resolve it. which means any detail you can provide to help with this discussion would be greatly appreciated. **Platform issues** It's important to us that micromatch work consistently on all platforms. If you encounter any platform-specific matching or path related issues, please let us know (pull requests are also greatly appreciated). ## About
Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.
Running Tests Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: ```sh $ npm install && npm test ```
Building docs _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ To generate the readme, run the following command: ```sh $ npm install -g verbose/verb#dev verb-generate-readme && verb ```
### Related projects You might also be interested in these projects: * [braces](https://www.npmjs.com/package/braces): Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support… [more](https://github.com/micromatch/braces) | [homepage](https://github.com/micromatch/braces "Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support for the Bash 4.3 braces specification, without sacrificing speed.") * [expand-brackets](https://www.npmjs.com/package/expand-brackets): Expand POSIX bracket expressions (character classes) in glob patterns. | [homepage](https://github.com/micromatch/expand-brackets "Expand POSIX bracket expressions (character classes) in glob patterns.") * [extglob](https://www.npmjs.com/package/extglob): Extended glob support for JavaScript. Adds (almost) the expressive power of regular expressions to glob… [more](https://github.com/micromatch/extglob) | [homepage](https://github.com/micromatch/extglob "Extended glob support for JavaScript. Adds (almost) the expressive power of regular expressions to glob patterns.") * [fill-range](https://www.npmjs.com/package/fill-range): Fill in a range of numbers or letters, optionally passing an increment or `step` to… [more](https://github.com/jonschlinkert/fill-range) | [homepage](https://github.com/jonschlinkert/fill-range "Fill in a range of numbers or letters, optionally passing an increment or `step` to use, or create a regex-compatible range with `options.toRegex`") * [nanomatch](https://www.npmjs.com/package/nanomatch): Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but complete Bash… [more](https://github.com/micromatch/nanomatch) | [homepage](https://github.com/micromatch/nanomatch "Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but complete Bash 4.3 wildcard support only (no support for exglobs, posix brackets or braces)") ### Contributors | **Commits** | **Contributor** | | --- | --- | | 512 | [jonschlinkert](https://github.com/jonschlinkert) | | 12 | [es128](https://github.com/es128) | | 9 | [danez](https://github.com/danez) | | 8 | [doowb](https://github.com/doowb) | | 6 | [paulmillr](https://github.com/paulmillr) | | 5 | [mrmlnc](https://github.com/mrmlnc) | | 3 | [DrPizza](https://github.com/DrPizza) | | 2 | [TrySound](https://github.com/TrySound) | | 2 | [mceIdo](https://github.com/mceIdo) | | 2 | [Glazy](https://github.com/Glazy) | | 2 | [MartinKolarik](https://github.com/MartinKolarik) | | 2 | [antonyk](https://github.com/antonyk) | | 2 | [Tvrqvoise](https://github.com/Tvrqvoise) | | 1 | [amilajack](https://github.com/amilajack) | | 1 | [Cslove](https://github.com/Cslove) | | 1 | [devongovett](https://github.com/devongovett) | | 1 | [DianeLooney](https://github.com/DianeLooney) | | 1 | [UltCombo](https://github.com/UltCombo) | | 1 | [frangio](https://github.com/frangio) | | 1 | [joyceerhl](https://github.com/joyceerhl) | | 1 | [juszczykjakub](https://github.com/juszczykjakub) | | 1 | [muescha](https://github.com/muescha) | | 1 | [sebdeckers](https://github.com/sebdeckers) | | 1 | [tomByrer](https://github.com/tomByrer) | | 1 | [fidian](https://github.com/fidian) | | 1 | [curbengh](https://github.com/curbengh) | | 1 | [simlu](https://github.com/simlu) | | 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) | | 1 | [yvele](https://github.com/yvele) | ### Author **Jon Schlinkert** * [GitHub Profile](https://github.com/jonschlinkert) * [Twitter Profile](https://twitter.com/jonschlinkert) * [LinkedIn Profile](https://linkedin.com/in/jonschlinkert) ### License Copyright © 2022, [Jon Schlinkert](https://github.com/jonschlinkert). Released under the [MIT License](LICENSE). *** _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on March 24, 2022._micromatch-4.0.5/bench/000077500000000000000000000000001421714312500147255ustar00rootroot00000000000000micromatch-4.0.5/bench/.npmrc000066400000000000000000000000231421714312500160400ustar00rootroot00000000000000package-lock=false micromatch-4.0.5/bench/first-match-micromatch.js000066400000000000000000000002301421714312500216230ustar00rootroot00000000000000console.time('micromatch'); console.log(require('..').makeRe('**/*').test('foo/bar/baz/qux.js')); console.timeEnd('micromatch'); // micromatch: 7.429ms micromatch-4.0.5/bench/first-match-minimatch.js000066400000000000000000000002341421714312500214520ustar00rootroot00000000000000console.time('minimatch'); console.log(require('minimatch').makeRe('**/*').test('foo/bar/baz/qux.js')); console.timeEnd('minimatch'); // minimatch: 9.275ms micromatch-4.0.5/bench/index.js000066400000000000000000000056711421714312500164030ustar00rootroot00000000000000'use strict'; const { Suite } = require('benchmark'); const { green } = require('ansi-colors'); const argv = require('minimist')(process.argv.slice(2)); const mm = require('minimatch'); const mi = require('..'); /** * Setup */ const cycle = (e, newline) => { process.stdout.write(`\u001b[G ${e.target}${newline ? '\n' : ''}`); }; const bench = (name, options) => { const config = { name, ...options }; const suite = new Suite(config); const add = suite.add.bind(suite); suite.on('error', console.error); if (argv.run && !new RegExp(argv.run).test(name)) { suite.add = () => suite; return suite; } console.log(`\n# ${config.name}`); suite.add = (key, fn, opts) => { if (typeof fn !== 'function') opts = fn; add(key, { onCycle: e => cycle(e), onComplete: e => cycle(e, true), fn, ...opts }); return suite; }; return suite; }; bench(green('.makeRe') + ' star') .add('micromatch', () => mi.makeRe('*')) .add('minimatch', () => mm.makeRe('*')) .run(); bench(green('.makeRe') + ' star; dot=true') .add('micromatch', () => mi.makeRe('*', { dot: true })) .add('minimatch', () => mm.makeRe('*', { dot: true })) .run(); bench(green('.makeRe') + ' globstar') .add('micromatch', () => mi.makeRe('**')) .add('minimatch', () => mm.makeRe('**')) .run(); bench(green('.makeRe') + ' globstars') .add('micromatch', () => mi.makeRe('**/**/**')) .add('minimatch', () => mm.makeRe('**/**/**')) .run(); bench(green('.makeRe') + ' with leading star') .add('micromatch', () => mi.makeRe('*.txt')) .add('minimatch', () => mm.makeRe('*.txt')) .run(); bench(green('.makeRe') + ' - braces') .add('micromatch', () => mi.makeRe('{a,b,c}*.txt')) .add('minimatch', () => mm.makeRe('{a,b,c}*.txt')) .run(); bench(green('.makeRe') + ' braces - range (expanded)') .add('micromatch', () => mi.braces('foo/{1..250}/bar', { expand: true })) .add('minimatch', () => mm.braceExpand('foo/{1..250}/bar')) .run(); bench(green('.makeRe') + ' braces - range (compiled)') .add('micromatch', () => mi.makeRe('foo/{1..250}/bar')) .add('minimatch', () => mm.makeRe('foo/{1..250}/bar')) .run(); bench(green('.makeRe') + ' braces - nested ranges (expanded)') .add('micromatch', () => mi.braces('foo/{a,b,{1..250}}/bar', { expand: true })) .add('minimatch', () => mm.braceExpand('foo/{a,b,{1..250}}/bar')) .run(); bench(green('.makeRe') + ' braces - nested ranges (compiled)') .add('micromatch', () => mi.makeRe('foo/{a,b,{1..250}}/bar')) .add('minimatch', () => mm.makeRe('foo/{a,b,{1..250}}/bar')) .run(); bench(green('.makeRe') + ' braces - set (compiled)') .add('micromatch', () => mi.makeRe('foo/{a,b,c,d,e}/bar')) .add('minimatch', () => mm.makeRe('foo/{a,b,c,d,e}/bar')) .run(); bench(green('.makeRe') + ' braces - nested sets (compiled)') .add('micromatch', () => mi.makeRe('foo/{a,b,c,d,e,{x,y,z}}/bar')) .add('minimatch', () => mm.makeRe('foo/{a,b,c,d,e,{x,y,z}}/bar')) .run(); micromatch-4.0.5/bench/load-time.js000066400000000000000000000003361421714312500171400ustar00rootroot00000000000000console.log('# Load time'); console.time('minimatch'); exports.mm = require('minimatch'); console.timeEnd('minimatch'); console.time('micromatch'); exports.mi = require('..'); console.timeEnd('micromatch'); console.log(); micromatch-4.0.5/bench/package.json000066400000000000000000000007111421714312500172120ustar00rootroot00000000000000{ "name": "picomatch-benchmarks", "version": "0.0.0", "private": true, "main": "index.js", "scripts": { "bench": "node ." }, "dependencies": { "ansi-colors": "^4.1.1", "benchmark": "^2.1.4", "minimatch": "^5.0.1", "minimist": "^1.2.6" }, "devDependencies": { "glob-parent": "^6.0.2" }, "lintDeps": { "devDependencies": { "files": { "patterns": [ "*.js" ] } } } } micromatch-4.0.5/examples/000077500000000000000000000000001421714312500154645ustar00rootroot00000000000000micromatch-4.0.5/examples/micromatch.braces.js000066400000000000000000000003371421714312500214110ustar00rootroot00000000000000'use strict'; const { braces } = require('..'); console.log(braces('foo/{a,b,c}/bar')); //=> [ 'foo/(a|b|c)/bar' ] console.log(braces('foo/{a,b,c}/bar', { expand: true })); //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ] micromatch-4.0.5/examples/option-expandRange.js000066400000000000000000000010701421714312500215620ustar00rootroot00000000000000'use strict'; const fill = require('fill-range'); const micromatch = require('..'); const regex = micromatch.makeRe('foo/{01..25}/bar', { expandRange(a, b) { return `(${fill(a, b, { toRegex: true })})`; } }); console.log(regex); //=> /^(?:foo\/((?:0[1-9]|1[0-9]|2[0-5]))\/bar)$/ console.log(regex.test('foo/00/bar')) // false console.log(regex.test('foo/01/bar')) // true console.log(regex.test('foo/10/bar')) // true console.log(regex.test('foo/22/bar')) // true console.log(regex.test('foo/25/bar')) // true console.log(regex.test('foo/26/bar')) // false micromatch-4.0.5/examples/option-ignore.js000066400000000000000000000003431421714312500206130ustar00rootroot00000000000000'use strict'; const micromatch = require('..'); const isMatch = micromatch.matcher('*', { ignore: 'f*' }); console.log(isMatch('foo')); //=> false console.log(isMatch('bar')); //=> true console.log(isMatch('baz')); //=> true micromatch-4.0.5/examples/option-onIgnore.js000066400000000000000000000005471421714312500211160ustar00rootroot00000000000000'use strict'; const micromatch = require('..'); const onIgnore = ({ glob, regex, input, output }) => { console.log({ glob, regex, input, output }); // { glob: '*', regex: /^(?:(?!\.)(?=.)[^\/]*?\/?)$/, input: 'foo', output: 'foo' } }; const isMatch = micromatch.matcher('*', { onIgnore, ignore: 'f*' }); isMatch('foo'); isMatch('bar'); isMatch('baz'); micromatch-4.0.5/examples/option-onMatch.js000066400000000000000000000006641421714312500207270ustar00rootroot00000000000000'use strict'; const micromatch = require('..'); const onMatch = ({ glob, regex, input, output }) => { console.log({ input, output }); // { input: 'some\\path', output: 'some/path' } // { input: 'some\\path', output: 'some/path' } // { input: 'some\\path', output: 'some/path' } }; const isMatch = micromatch.matcher('**', { onMatch, posixSlashes: true }); isMatch('some\\path'); isMatch('some\\path'); isMatch('some\\path'); micromatch-4.0.5/examples/option-onResult.js000066400000000000000000000004041421714312500211410ustar00rootroot00000000000000'use strict'; const micromatch = require('..'); const onResult = ({ glob, regex, input, output }) => { console.log({ input, output }); }; const isMatch = micromatch.matcher('*', { onResult, ignore: 'f*' }); isMatch('foo'); isMatch('bar'); isMatch('baz'); micromatch-4.0.5/index.js000066400000000000000000000326551421714312500153260ustar00rootroot00000000000000'use strict'; const util = require('util'); const braces = require('braces'); const picomatch = require('picomatch'); const utils = require('picomatch/lib/utils'); const isEmptyString = val => val === '' || val === './'; /** * Returns an array of strings that match one or more glob patterns. * * ```js * const mm = require('micromatch'); * // mm(list, patterns[, options]); * * console.log(mm(['a.js', 'a.txt'], ['*.js'])); * //=> [ 'a.js' ] * ``` * @param {String|Array} `list` List of strings to match. * @param {String|Array} `patterns` One or more glob patterns to use for matching. * @param {Object} `options` See available [options](#options) * @return {Array} Returns an array of matches * @summary false * @api public */ const micromatch = (list, patterns, options) => { patterns = [].concat(patterns); list = [].concat(list); let omit = new Set(); let keep = new Set(); let items = new Set(); let negatives = 0; let onResult = state => { items.add(state.output); if (options && options.onResult) { options.onResult(state); } }; for (let i = 0; i < patterns.length; i++) { let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true); let negated = isMatch.state.negated || isMatch.state.negatedExtglob; if (negated) negatives++; for (let item of list) { let matched = isMatch(item, true); let match = negated ? !matched.isMatch : matched.isMatch; if (!match) continue; if (negated) { omit.add(matched.output); } else { omit.delete(matched.output); keep.add(matched.output); } } } let result = negatives === patterns.length ? [...items] : [...keep]; let matches = result.filter(item => !omit.has(item)); if (options && matches.length === 0) { if (options.failglob === true) { throw new Error(`No matches found for "${patterns.join(', ')}"`); } if (options.nonull === true || options.nullglob === true) { return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns; } } return matches; }; /** * Backwards compatibility */ micromatch.match = micromatch; /** * Returns a matcher function from the given glob `pattern` and `options`. * The returned function takes a string to match as its only argument and returns * true if the string is a match. * * ```js * const mm = require('micromatch'); * // mm.matcher(pattern[, options]); * * const isMatch = mm.matcher('*.!(*a)'); * console.log(isMatch('a.a')); //=> false * console.log(isMatch('a.b')); //=> true * ``` * @param {String} `pattern` Glob pattern * @param {Object} `options` * @return {Function} Returns a matcher function. * @api public */ micromatch.matcher = (pattern, options) => picomatch(pattern, options); /** * Returns true if **any** of the given glob `patterns` match the specified `string`. * * ```js * const mm = require('micromatch'); * // mm.isMatch(string, patterns[, options]); * * console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true * console.log(mm.isMatch('a.a', 'b.*')); //=> false * ``` * @param {String} `str` The string to test. * @param {String|Array} `patterns` One or more glob patterns to use for matching. * @param {Object} `[options]` See available [options](#options). * @return {Boolean} Returns true if any patterns match `str` * @api public */ micromatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str); /** * Backwards compatibility */ micromatch.any = micromatch.isMatch; /** * Returns a list of strings that _**do not match any**_ of the given `patterns`. * * ```js * const mm = require('micromatch'); * // mm.not(list, patterns[, options]); * * console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a')); * //=> ['b.b', 'c.c'] * ``` * @param {Array} `list` Array of strings to match. * @param {String|Array} `patterns` One or more glob pattern to use for matching. * @param {Object} `options` See available [options](#options) for changing how matches are performed * @return {Array} Returns an array of strings that **do not match** the given patterns. * @api public */ micromatch.not = (list, patterns, options = {}) => { patterns = [].concat(patterns).map(String); let result = new Set(); let items = []; let onResult = state => { if (options.onResult) options.onResult(state); items.push(state.output); }; let matches = new Set(micromatch(list, patterns, { ...options, onResult })); for (let item of items) { if (!matches.has(item)) { result.add(item); } } return [...result]; }; /** * Returns true if the given `string` contains the given pattern. Similar * to [.isMatch](#isMatch) but the pattern can match any part of the string. * * ```js * var mm = require('micromatch'); * // mm.contains(string, pattern[, options]); * * console.log(mm.contains('aa/bb/cc', '*b')); * //=> true * console.log(mm.contains('aa/bb/cc', '*d')); * //=> false * ``` * @param {String} `str` The string to match. * @param {String|Array} `patterns` Glob pattern to use for matching. * @param {Object} `options` See available [options](#options) for changing how matches are performed * @return {Boolean} Returns true if any of the patterns matches any part of `str`. * @api public */ micromatch.contains = (str, pattern, options) => { if (typeof str !== 'string') { throw new TypeError(`Expected a string: "${util.inspect(str)}"`); } if (Array.isArray(pattern)) { return pattern.some(p => micromatch.contains(str, p, options)); } if (typeof pattern === 'string') { if (isEmptyString(str) || isEmptyString(pattern)) { return false; } if (str.includes(pattern) || (str.startsWith('./') && str.slice(2).includes(pattern))) { return true; } } return micromatch.isMatch(str, pattern, { ...options, contains: true }); }; /** * Filter the keys of the given object with the given `glob` pattern * and `options`. Does not attempt to match nested keys. If you need this feature, * use [glob-object][] instead. * * ```js * const mm = require('micromatch'); * // mm.matchKeys(object, patterns[, options]); * * const obj = { aa: 'a', ab: 'b', ac: 'c' }; * console.log(mm.matchKeys(obj, '*b')); * //=> { ab: 'b' } * ``` * @param {Object} `object` The object with keys to filter. * @param {String|Array} `patterns` One or more glob patterns to use for matching. * @param {Object} `options` See available [options](#options) for changing how matches are performed * @return {Object} Returns an object with only keys that match the given patterns. * @api public */ micromatch.matchKeys = (obj, patterns, options) => { if (!utils.isObject(obj)) { throw new TypeError('Expected the first argument to be an object'); } let keys = micromatch(Object.keys(obj), patterns, options); let res = {}; for (let key of keys) res[key] = obj[key]; return res; }; /** * Returns true if some of the strings in the given `list` match any of the given glob `patterns`. * * ```js * const mm = require('micromatch'); * // mm.some(list, patterns[, options]); * * console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js'])); * // true * console.log(mm.some(['foo.js'], ['*.js', '!foo.js'])); * // false * ``` * @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found. * @param {String|Array} `patterns` One or more glob patterns to use for matching. * @param {Object} `options` See available [options](#options) for changing how matches are performed * @return {Boolean} Returns true if any `patterns` matches any of the strings in `list` * @api public */ micromatch.some = (list, patterns, options) => { let items = [].concat(list); for (let pattern of [].concat(patterns)) { let isMatch = picomatch(String(pattern), options); if (items.some(item => isMatch(item))) { return true; } } return false; }; /** * Returns true if every string in the given `list` matches * any of the given glob `patterns`. * * ```js * const mm = require('micromatch'); * // mm.every(list, patterns[, options]); * * console.log(mm.every('foo.js', ['foo.js'])); * // true * console.log(mm.every(['foo.js', 'bar.js'], ['*.js'])); * // true * console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js'])); * // false * console.log(mm.every(['foo.js'], ['*.js', '!foo.js'])); * // false * ``` * @param {String|Array} `list` The string or array of strings to test. * @param {String|Array} `patterns` One or more glob patterns to use for matching. * @param {Object} `options` See available [options](#options) for changing how matches are performed * @return {Boolean} Returns true if all `patterns` matches all of the strings in `list` * @api public */ micromatch.every = (list, patterns, options) => { let items = [].concat(list); for (let pattern of [].concat(patterns)) { let isMatch = picomatch(String(pattern), options); if (!items.every(item => isMatch(item))) { return false; } } return true; }; /** * Returns true if **all** of the given `patterns` match * the specified string. * * ```js * const mm = require('micromatch'); * // mm.all(string, patterns[, options]); * * console.log(mm.all('foo.js', ['foo.js'])); * // true * * console.log(mm.all('foo.js', ['*.js', '!foo.js'])); * // false * * console.log(mm.all('foo.js', ['*.js', 'foo.js'])); * // true * * console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js'])); * // true * ``` * @param {String|Array} `str` The string to test. * @param {String|Array} `patterns` One or more glob patterns to use for matching. * @param {Object} `options` See available [options](#options) for changing how matches are performed * @return {Boolean} Returns true if any patterns match `str` * @api public */ micromatch.all = (str, patterns, options) => { if (typeof str !== 'string') { throw new TypeError(`Expected a string: "${util.inspect(str)}"`); } return [].concat(patterns).every(p => picomatch(p, options)(str)); }; /** * Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match. * * ```js * const mm = require('micromatch'); * // mm.capture(pattern, string[, options]); * * console.log(mm.capture('test/*.js', 'test/foo.js')); * //=> ['foo'] * console.log(mm.capture('test/*.js', 'foo/bar.css')); * //=> null * ``` * @param {String} `glob` Glob pattern to use for matching. * @param {String} `input` String to match * @param {Object} `options` See available [options](#options) for changing how matches are performed * @return {Array|null} Returns an array of captures if the input matches the glob pattern, otherwise `null`. * @api public */ micromatch.capture = (glob, input, options) => { let posix = utils.isWindows(options); let regex = picomatch.makeRe(String(glob), { ...options, capture: true }); let match = regex.exec(posix ? utils.toPosixSlashes(input) : input); if (match) { return match.slice(1).map(v => v === void 0 ? '' : v); } }; /** * Create a regular expression from the given glob `pattern`. * * ```js * const mm = require('micromatch'); * // mm.makeRe(pattern[, options]); * * console.log(mm.makeRe('*.js')); * //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/ * ``` * @param {String} `pattern` A glob pattern to convert to regex. * @param {Object} `options` * @return {RegExp} Returns a regex created from the given pattern. * @api public */ micromatch.makeRe = (...args) => picomatch.makeRe(...args); /** * Scan a glob pattern to separate the pattern into segments. Used * by the [split](#split) method. * * ```js * const mm = require('micromatch'); * const state = mm.scan(pattern[, options]); * ``` * @param {String} `pattern` * @param {Object} `options` * @return {Object} Returns an object with * @api public */ micromatch.scan = (...args) => picomatch.scan(...args); /** * Parse a glob pattern to create the source string for a regular * expression. * * ```js * const mm = require('micromatch'); * const state = mm.parse(pattern[, options]); * ``` * @param {String} `glob` * @param {Object} `options` * @return {Object} Returns an object with useful properties and output to be used as regex source string. * @api public */ micromatch.parse = (patterns, options) => { let res = []; for (let pattern of [].concat(patterns || [])) { for (let str of braces(String(pattern), options)) { res.push(picomatch.parse(str, options)); } } return res; }; /** * Process the given brace `pattern`. * * ```js * const { braces } = require('micromatch'); * console.log(braces('foo/{a,b,c}/bar')); * //=> [ 'foo/(a|b|c)/bar' ] * * console.log(braces('foo/{a,b,c}/bar', { expand: true })); * //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ] * ``` * @param {String} `pattern` String with brace pattern to process. * @param {Object} `options` Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options. * @return {Array} * @api public */ micromatch.braces = (pattern, options) => { if (typeof pattern !== 'string') throw new TypeError('Expected a string'); if ((options && options.nobrace === true) || !/\{.*\}/.test(pattern)) { return [pattern]; } return braces(pattern, options); }; /** * Expand braces */ micromatch.braceExpand = (pattern, options) => { if (typeof pattern !== 'string') throw new TypeError('Expected a string'); return micromatch.braces(pattern, { ...options, expand: true }); }; /** * Expose micromatch */ module.exports = micromatch; micromatch-4.0.5/package.json000066400000000000000000000051301421714312500161330ustar00rootroot00000000000000{ "name": "micromatch", "description": "Glob matching for javascript/node.js. A replacement and faster alternative to minimatch and multimatch.", "version": "4.0.5", "homepage": "https://github.com/micromatch/micromatch", "author": "Jon Schlinkert (https://github.com/jonschlinkert)", "contributors": [ "(https://github.com/DianeLooney)", "Amila Welihinda (amilajack.com)", "Bogdan Chadkin (https://github.com/TrySound)", "Brian Woodward (https://twitter.com/doowb)", "Devon Govett (http://badassjs.com)", "Elan Shanker (https://github.com/es128)", "Fabrício Matté (https://ultcombo.js.org)", "Jon Schlinkert (http://twitter.com/jonschlinkert)", "Martin Kolárik (https://kolarik.sk)", "Olsten Larck (https://i.am.charlike.online)", "Paul Miller (paulmillr.com)", "Tom Byrer (https://github.com/tomByrer)", "Tyler Akins (http://rumkin.com)", "Peter Bright (https://github.com/drpizza)", "Kuba Juszczyk (https://github.com/ku8ar)" ], "repository": "micromatch/micromatch", "bugs": { "url": "https://github.com/micromatch/micromatch/issues" }, "license": "MIT", "files": [ "index.js" ], "main": "index.js", "engines": { "node": ">=8.6" }, "scripts": { "test": "mocha" }, "dependencies": { "braces": "^3.0.2", "picomatch": "^2.3.1" }, "devDependencies": { "fill-range": "^7.0.1", "gulp-format-md": "^2.0.0", "minimatch": "^5.0.1", "mocha": "^9.2.2", "time-require": "github:jonschlinkert/time-require" }, "keywords": [ "bash", "bracket", "character-class", "expand", "expansion", "expression", "extglob", "extglobs", "file", "files", "filter", "find", "glob", "globbing", "globs", "globstar", "lookahead", "lookaround", "lookbehind", "match", "matcher", "matches", "matching", "micromatch", "minimatch", "multimatch", "negate", "negation", "path", "pattern", "patterns", "posix", "regex", "regexp", "regular", "shell", "star", "wildcard" ], "verb": { "toc": "collapsible", "layout": "default", "tasks": [ "readme" ], "plugins": [ "gulp-format-md" ], "lint": { "reflinks": true }, "related": { "list": [ "braces", "expand-brackets", "extglob", "fill-range", "nanomatch" ] }, "reflinks": [ "extglob", "fill-range", "glob-object", "minimatch", "multimatch" ] } } micromatch-4.0.5/test/000077500000000000000000000000001421714312500146255ustar00rootroot00000000000000micromatch-4.0.5/test/_fixtures.js000066400000000000000000000020671421714312500172000ustar00rootroot00000000000000'use strict'; const path = require('path'); if (!process.env.ORIGINAL_PATH_SEP) { process.env.ORIGINAL_PATH_SEP = path.sep } module.exports = [ 'a', 'a.md', 'a.js', 'a/', 'a/b', 'a/b/.c.md', 'a/b/c', 'a/b/c.md', 'a/b/c/', 'a/b/c/d', 'a/b/c/d/', 'a/b/c/d/e/f/z.js', 'a/b/c/z.js', 'a/bb', 'a/cb', 'abbbz', 'abc', 'abd', 'z.js', 'za.js', // literal "!" '!a.js', '!a/b', '!a/b/', '!a/b/c', '!a/b/c/', '!a/!b', '!a/!b/c', '!a/!b/c/d', '!a/b/.c.md', // root '/a/', '/a/b', '/a/cb', '/a/bb', '/a/b/c', '/a/b/c/', '/a/b/c/d', '/a/b/c/d/', // cwd '.', './', // ancestor directories '..', '../c', '../c', './../c', './a/../c', '/..', '/../c', '/../.c', '/../.c/', '/a/../c', 'a/../c', // dot files '../.b/.c', '../b/.c', './.b/.c', './b/.c', '.b', '.b.c', '.b.c/', '.b/', '.b/.c', '.b/c', 'b/.c', 'b/.c/', // wildcards in filepaths 'a/+b/c', '+a/+b/c', 'a (foo)', 'a (foo)/(bar)', 'a/b/c (1)', 'a/b (2)/c (1)', 'a/b/c [def]' ]; micromatch-4.0.5/test/_patterns.js000066400000000000000000000054351421714312500171710ustar00rootroot00000000000000'use strict'; module.exports = [ '!**', '!**/*', '!**/*.md', '!*.*', '!*.js', '!*/**/*', '!*/**/*/', '!*/*/*', '!/**', '!/**/', '!/*/', '!/*/**/*/', '!/*/*/', '!a/!b*', '!a/!b/*', '!a/*?b', '!a/?', '!a/?*b', '!a/??b', '!a/?b', '!a/b/!*', '!a/b/*', '!a/b/c*', '*', '**', '***', '**********', '**/', '**/*', '**/**', '**/**/**', '**/*.md', '**/*?.md', '**/.?.md', '**/?.md', '**/z*.js', '*.js', '*/', '*/*', '*/*/*', '*/*/*/*', '/*', '/**', '/**/', '/**/*', '/*/', '/*/*', '/*/**/', '/*/**/*', '/*/*/', '/*/*/*', '/*/*/*/*', '/*/*/*/*/', '?', '?*?******?', '?*?***?', '?*?***?***????', '?*?*?', '?/', '?/.?', '?/.?*', '?/?', '?/?/?', '??', '??/??', '???', '????', 'a/*', 'a/*/', 'a/b/*', 'a/**/', 'a/**/b', 'a/**b', 'a/*/', 'a/*?b', 'a/?', 'a/?*b', 'a/??b', 'a/?b', 'a/b', 'a/b*', 'a/b/*', 'a/b/c', 'a/b/c/*', 'a/b/c/**/*.js', 'a/b/c/*.js' ]; module.exports.other = [ 'code/{for,while,*-{test,exec}}*.js', 'code/{for-*,while*}.js', '**/a/*/b/c/.js', '**/a/*/b/c.d/.js', '**/*.{*,gitignore}', '**/*.{js,gitignore}', '**/{a,/.gitignore}', '**/{a..z..2}/*.js', '**/{a..c}/*.js', '**/{1..10}/*.js', '**/{1..10..2}/*.js', 'a/{b..s}/xyz/*-{01..10}.js', 'a', 'a/', 'a/*', '.*', '**/**/.*', '**/**/.*', '**/.*/.*', '**/.*', '**/*.*', '**/*.', '**/*.a', '**/*.js', '**/*.md', '**/.*', '**/.*.js', '**/.*.md', '**/.a', '**/.a.js', '**/.gitignore', '*.*', '*.a', '*.gitignore', '*.{gitignore,*}', '*.{*,gitignore,js}', '*.{*,gitignore}', '.{*,gitignore}', '**/.{*,gitignore}', '**/.{js,gitignore}', '**/.{js,md}', '**/*.{js,md}', '**/(a|b)/*.{js,md}', '**/[a-z]/*.{js,md}', '*.js', '*.md', '*.{js,txt}', '*/*.gitignore', '*/.gitignore', '.a', '.gitignore', '.js', '.md', 'a/**/c/*.js', 'a/**/c/*.md', 'a/**/j/**/z/*.js', 'a/**/j/**/z/*.md', 'a/**/z/*.js', 'a/**/z/*.md', 'a/*.js', 'a/*.md', 'a/*.txt', 'a/*/.b', 'a/*/.b.a', 'a/*/?/**/e.js', 'a/*/?/**/e.md', 'a/*/b', 'a/*/c/*.js', 'a/*/c/*.md', 'a/.*/b', 'a/?/**/e.js', 'a/?/**/e.md', 'a/?/c.js', 'a/?/c.md', 'a/?/c/?/*/e.js', 'a/?/c/?/*/e.md', 'a/?/c/?/e.js', 'a/?/c/?/e.md', 'a/?/c/???/e.js', 'a/?/c/???/e.md', 'a/??/c.js', 'a/??/c.md', 'a/???/c.js', 'a/???/c.md', 'a/????/c.js', 'a/????/c.md', 'a/b/**/c{d,e}/**/xyz.js', 'a/b/**/c{d,e}/**/xyz.md', 'a/b/c/*.js', 'A/b/C/*.js', 'a/b/c/*.md', 'A/b/C/*.md', 'A/b/C/*.MD', 'a/b/c{d,e{f,g}}/*.js', 'a/b/c{d,e{f,g}}/*.md', 'a/b/c{d,e}/*.js', 'a/b/c{d,e}/*.md', 'a/b/c{d,e}/xyz.js', 'a/b/c{d,e}/xyz.md', 'a/{c..e}.js', 'E:**/*.js', 'E:**/*.md', 'E:\\\\**/*.js', 'E:\\\\**/*.md' ]; micromatch-4.0.5/test/api.all.js000066400000000000000000000014421421714312500165040ustar00rootroot00000000000000'use strict'; process.env.PICOMATCH_NO_CACHE = 'true'; require('mocha'); const path = require('path'); const assert = require('assert'); const { all } = require('..'); if (!process.env.ORIGINAL_PATH_SEP) { process.env.ORIGINAL_PATH_SEP = path.sep; } describe('.all()', () => {it('should throw an error when value is not a string', () => { assert.throws(() => all()); }); it('should return true when all patterns match the given string', () => { assert(all('z', ['z', '*', '[a-z]'])); assert(all('b', 'b')); assert(all('b', '*')); }); it('should return false when some patterns do not match', () => { assert(!all('a', ['a', 'b', '*'])); assert(!all('a', ['a*', 'z*'])); }); it('should arrayify a string pattern', () => { assert(all('a', '*')); }); }); micromatch-4.0.5/test/api.braceExpand.js000066400000000000000000000007351421714312500201540ustar00rootroot00000000000000'use strict'; require('mocha'); const path = require('path'); const assert = require('assert'); const { braceExpand } = require('..'); if (!process.env.ORIGINAL_PATH_SEP) { process.env.ORIGINAL_PATH_SEP = path.sep } describe('.braceExpand()', () => {it('should throw an error when arguments are invalid', () => { assert.throws(() => braceExpand()); }); it('should expand a brace pattern', () => { assert.deepEqual(braceExpand('{a,b}'), ['a', 'b']); }); }); micromatch-4.0.5/test/api.braces.js000066400000000000000000000010751421714312500171750ustar00rootroot00000000000000'use strict'; require('mocha'); const assert = require('assert'); const { braces } = require('..'); if (!process.env.ORIGINAL_PATH_SEP) { process.env.ORIGINAL_PATH_SEP = path.sep } describe('.braces()', () => {it('should throw an error when arguments are invalid', () => { assert.throws(() => braces()); }); it('should create a regex source string from a brace pattern', () => { assert.deepEqual(braces('{a,b}'), ['(a|b)']); }); it('should expand a brace pattern', () => { assert.deepEqual(braces('{a,b}', {expand: true}), ['a', 'b']); }); }); micromatch-4.0.5/test/api.capture.js000066400000000000000000000056511421714312500174050ustar00rootroot00000000000000'use strict'; const assert = require('assert'); const { capture } = require('..'); describe('.capture()', () => { it('should return null if no match', () => { assert.equal(capture('test/*', 'hi/123'), null); }); it('should return an empty array if there are no captures', () => { assert.deepEqual(capture('test/hi', 'test/hi'), []); }); it('should capture stars', () => { assert.deepEqual(capture('test/*', 'test/foo'), ['foo']); assert.deepEqual(capture('test/*/bar', 'test/foo/bar'), ['foo']); assert.deepEqual(capture('test/*/bar/*', 'test/foo/bar/baz'), ['foo', 'baz']); assert.deepEqual(capture('test/*.js', 'test/foo.js'), ['foo']); assert.deepEqual(capture('test/*-controller.js', 'test/foo-controller.js'), ['foo']); }); it('should capture globstars', () => { assert.deepEqual(capture('test/**/*.js', 'test/a.js'), ['', 'a']); assert.deepEqual(capture('test/**/*.js', 'test/dir/a.js'), ['dir', 'a']); assert.deepEqual(capture('test/**/*.js', 'test/dir/test/a.js'), ['dir/test', 'a']); assert.deepEqual(capture('**/*.js', 'test/dir/a.js'), ['test/dir', 'a']); }); it('should capture extglobs', () => { assert.deepEqual(capture('test/+(a|b)/*.js', 'test/a/x.js'), ['a', 'x']); assert.deepEqual(capture('test/+(a|b)/*.js', 'test/b/x.js'), ['b', 'x']); assert.deepEqual(capture('test/+(a|b)/*.js', 'test/ab/x.js'), ['ab', 'x']); }); it('should capture paren groups', () => { assert.deepEqual(capture('test/(a|b)/x.js', 'test/a/x.js'), ['a']); assert.deepEqual(capture('test/(a|b)/x.js', 'test/b/x.js'), ['b']); }); it('should capture star groups', () => { assert.deepEqual(capture('test/a*(a|b)/x.js', 'test/a/x.js'), ['']); assert.deepEqual(capture('test/a*(a|b)/x.js', 'test/aa/x.js'), ['a']); assert.deepEqual(capture('test/a*(a|b)/x.js', 'test/ab/x.js'), ['b']); assert.deepEqual(capture('test/a*(a|b)/x.js', 'test/aba/x.js'), ['ba']); }); it('should capture plus groups', () => { assert.deepEqual(capture('test/+(a|b)/x.js', 'test/a/x.js'), ['a']); assert.deepEqual(capture('test/+(a|b)/x.js', 'test/b/x.js'), ['b']); assert.deepEqual(capture('test/+(a|b)/x.js', 'test/ab/x.js'), ['ab']); assert.deepEqual(capture('test/+(a|b)/x.js', 'test/aba/x.js'), ['aba']); }); it('should capture optional groups', () => { assert.deepEqual(capture('test/a?(a|b)/x.js', 'test/a/x.js'), ['']); assert.deepEqual(capture('test/a?(a|b)/x.js', 'test/ab/x.js'), ['b']); assert.deepEqual(capture('test/a?(a|b)/x.js', 'test/aa/x.js'), ['a']); }); it('should capture @ groups', () => { assert.deepEqual(capture('test/@(a|b)/x.js', 'test/a/x.js'), ['a']); assert.deepEqual(capture('test/@(a|b)/x.js', 'test/b/x.js'), ['b']); }); it('should capture negated groups', () => { assert.deepEqual(capture('test/!(a|b)/x.js', 'test/x/x.js'), ['x']); assert.deepEqual(capture('test/!(a|b)/x.js', 'test/y/x.js'), ['y']); }); }); micromatch-4.0.5/test/api.contains.js000066400000000000000000000336061421714312500175610ustar00rootroot00000000000000'use strict'; const path = require('path'); const assert = require('assert'); const mm = require('..'); const sep = path.sep; describe('.contains()', () => { afterEach(() => (path.sep = sep)); after(() => (path.sep = sep)); describe('errors', () => { it('should throw an error arguments are invalid', () => { assert.throws(() => mm.contains()); }); }); describe('patterns', () => { it('should correctly deal with empty patterns', () => { assert(!mm.contains('ab', '')); assert(!mm.contains('a', '')); assert(!mm.contains('.', '')); }); it('should return true when the path contains the pattern', () => { assert(mm.contains('ab', 'b')); assert(mm.contains('.', '.')); assert(mm.contains('a/b/c', 'a/b')); assert(mm.contains('/ab', '/a')); assert(mm.contains('a', 'a')); assert(mm.contains('ab', 'a')); assert(mm.contains('ab', 'ab')); assert(mm.contains('abcd', 'd')); assert(mm.contains('abcd', 'c')); assert(mm.contains('abcd', 'cd')); assert(mm.contains('abcd', 'bc')); assert(mm.contains('abcd', 'ab')); }); it('should be true when a glob pattern partially matches the path', () => { assert(mm.contains('a/b/c', 'a/*')); assert(mm.contains('/ab', '/a')); assert(mm.contains('/ab', '/*')); assert(mm.contains('/cd', '/*')); assert(mm.contains('ab', '*')); assert(mm.contains('ab', 'ab')); assert(mm.contains('/ab', '*/a')); assert(mm.contains('/ab', '*/')); assert(mm.contains('/ab', '*/*')); assert(mm.contains('/ab', '/')); assert(mm.contains('/ab', '/??')); assert(mm.contains('/ab', '/?b')); assert(mm.contains('/ab', '/?')); assert(mm.contains('a/b', '?/?')); }); it('should return false when the path does not contain the pattern', () => { assert(!mm.contains('/ab', '?/?')); assert(!mm.contains('ab', '*/*')); assert(!mm.contains('abcd', 'f')); assert(!mm.contains('ab', 'c')); assert(!mm.contains('ab', '/a')); assert(!mm.contains('/ab', 'a/*')); assert(!mm.contains('ef', '/*')); }); it('should match files that contain the given extension', () => { assert(mm.contains('ab', './*')); assert(mm.contains('.c.md', '*.md')); assert(mm.contains('.c.md', '.*.md')); assert(mm.contains('.c.md', '.c.')); assert(mm.contains('.c.md', '.md')); assert(mm.contains('.md', '.m')); assert(mm.contains('a/b/c.md', '**/*.md')); assert(mm.contains('a/b/c.md', '*.md')); assert(mm.contains('a/b/c.md', '.md')); assert(mm.contains('a/b/c.md', 'a/*/*.md')); assert(mm.contains('a/b/c/c.md', '*.md')); assert(mm.contains('c.md', '*.md')); }); it('should not match files that do not contain the given extension', () => { assert(!mm.contains('.md', '*.md')); assert(!mm.contains('a/b/c/c.md', 'c.js')); assert(!mm.contains('a/b/c.md', 'a/*.md')); }); it('should match dotfiles when a dot is explicitly defined in the pattern', () => { assert(mm.contains('.a', '.a')); assert(mm.contains('.ab', '.*')); assert(mm.contains('.ab', '.a*')); assert(mm.contains('.abc', '.a')); assert(mm.contains('.b', '.b*')); assert(mm.contains('.c.md', '*.md')); assert(mm.contains('.md', '.md')); assert(mm.contains('a/.c.md', '*.md')); assert(mm.contains('a/.c.md', 'a/.c.md')); assert(mm.contains('a/b/c/.xyz.md', 'a/b/c/.*.md')); assert(mm.contains('a/b/c/d.a.md', 'a/b/c/*.md')); }); it('should match dotfiles when `dot` or `dotfiles` is set', () => { assert(mm.contains('.c.md', '*.md', { dot: true })); assert(mm.contains('.c.md', '.*', { dot: true })); assert(mm.contains('a/b/c/.xyz.md', '**/*.md', { dot: true })); assert(mm.contains('a/b/c/.xyz.md', '**/.*.md', { dot: true })); assert(mm.contains('a/b/c/.xyz.md', '.*.md', { dot: true })); assert(mm.contains('a/b/c/.xyz.md', 'a/b/c/*.md', { dot: true })); assert(mm.contains('a/b/c/.xyz.md', 'a/b/c/.*.md', { dot: true })); }); it('should not match dotfiles when `dot` or `dotfiles` is not set', () => { assert(!mm.contains('.a', '*.md')); assert(!mm.contains('.ba', '.a')); assert(!mm.contains('.a.md', 'a/b/c/*.md')); assert(!mm.contains('.ab', '*.*')); assert(!mm.contains('.md', 'a/b/c/*.md')); assert(!mm.contains('.txt', '.md')); assert(!mm.contains('.verb.txt', '*.md')); assert(!mm.contains('a/b/d/.md', 'a/b/c/*.md')); }); it('should match file paths', () => { assert(mm.contains('a/b/c/xyz.md', 'a/b/c/*.md')); assert(mm.contains('a/bb/c/xyz.md', 'a/*/c/*.md')); assert(mm.contains('a/bbbb/c/xyz.md', 'a/*/c/*.md')); assert(mm.contains('a/bb.bb/c/xyz.md', 'a/*/c/*.md')); assert(mm.contains('a/bb.bb/aa/bb/aa/c/xyz.md', 'a/**/c/*.md')); assert(mm.contains('a/bb.bb/aa/b.b/aa/c/xyz.md', 'a/**/c/*.md')); }); it('should return true when full file paths are matched', () => { assert(mm.contains('a/.b', 'a/.*')); assert(mm.contains('a/.b', 'a/')); assert(mm.contains('a/b/z/.a', 'b/z')); assert(mm.contains('a/b/z/.a', 'a/*/z/.a')); assert(mm.contains('a/b/c/d/e/z/c.md', 'a/**/z/*.md')); assert(mm.contains('a/b/c/d/e/z/c.md', 'b/c/d/e')); assert(mm.contains('a/b/c/d/e/j/n/p/o/z/c.md', 'a/**/j/**/z/*.md')); }); it('should match path segments', () => { assert(mm.contains('aaa', 'aaa')); assert(mm.contains('aaa', 'aa')); assert(mm.contains('aaa/bbb', 'aaa/bbb')); assert(mm.contains('aaa/bbb', 'aaa/*')); assert(mm.contains('aaa/bba/ccc', '**/*/ccc')); assert(mm.contains('aaa/bba/ccc', '*/*a')); assert(mm.contains('aaa/bba/ccc', 'aaa*')); assert(mm.contains('aaa/bba/ccc', 'aaa**')); assert(mm.contains('aaa/bba/ccc', 'aaa/*')); assert(mm.contains('aaa/bba/ccc', 'aaa/**')); assert(mm.contains('aaa/bba/ccc', 'aaa/*/ccc')); assert(mm.contains('aaa/bba/ccc', 'bb')); assert(mm.contains('aaa/bba/ccc', 'bb*')); assert(!mm.contains('aaa/bba/ccc', 'aaa/*ccc')); assert(!mm.contains('aaa/bba/ccc', 'aaa/**ccc')); assert(!mm.contains('aaa/bba/ccc', 'aaa/*z')); assert(!mm.contains('aaa/bba/ccc', 'aaa/**z')); assert(mm.contains('aaa/bbb', 'aaa[/]bbb')); assert(!mm.contains('aaa', '*/*/*')); assert(!mm.contains('aaa/bbb', '*/*/*')); assert(mm.contains('aaa/bba/ccc', '*/*/*')); assert(mm.contains('aaa/bb/aa/rr', '*/*/*')); assert(mm.contains('abzzzejklhi', '*j*i')); assert(mm.contains('ab/zzz/ejkl/hi', '*/*z*/*/*i')); assert(mm.contains('ab/zzz/ejkl/hi', '*/*jk*/*i')); }); it('should return false when full file paths are not matched', () => { assert(!mm.contains('a/b/z/.a', 'b/a')); assert(!mm.contains('a/.b', 'a/**/z/*.md')); assert(!mm.contains('a/b/z/.a', 'a/**/z/*.a')); assert(!mm.contains('a/b/z/.a', 'a/*/z/*.a')); assert(!mm.contains('a/b/c/j/e/z/c.txt', 'a/**/j/**/z/*.md')); }); it('should match paths with leading `./`', () => { assert(!mm.contains('./.a', 'a/**/z/*.md')); assert(mm.contains('./a/b/z/.a', 'a/**/z/.a')); assert(mm.contains('./a/b/z/.a', './a/**/z/.a')); assert(mm.contains('./a/b/c/d/e/z/c.md', 'a/**/z/*.md')); assert(mm.contains('./a/b/c/d/e/z/c.md', './a/**/z/*.md')); assert(!mm.contains('./a/b/c/d/e/z/c.md', './a/**/j/**/z/*.md')); assert(mm.contains('./a/b/c/j/e/z/c.md', './a/**/j/**/z/*.md')); assert(mm.contains('./a/b/c/j/e/z/c.md', 'a/**/j/**/z/*.md')); assert(mm.contains('./a/b/c/d/e/j/n/p/o/z/c.md', './a/**/j/**/z/*.md')); assert(!mm.contains('./a/b/c/j/e/z/c.txt', './a/**/j/**/z/*.md')); }); }); describe('windows paths', () => { beforeEach(() => { path.sep = '\\'; }); afterEach(() => { path.sep = sep; }); it('should match with common glob patterns', () => { assert(mm.contains('\\ab', '*/')); assert(mm.contains('ab\\', '*/')); assert(mm.contains('\\ab', '*/*')); assert(mm.contains('\\ab', '*/[a-z]*')); assert(mm.contains('\\ab', '*/*[a-z]')); assert(mm.contains('\\ab', '*/a')); assert(mm.contains('\\ab', '/')); assert(mm.contains('\\ab', '/*')); assert(mm.contains('\\ab', '/?')); assert(mm.contains('\\ab', '/??')); assert(mm.contains('\\ab', '/?b')); assert(mm.contains('\\ab', '/a')); assert(mm.contains('\\cd', '/*')); assert(mm.contains('a\\b', '?/?')); assert(mm.contains('a\\b\\c', 'a/*')); assert(!mm.contains('\\ab', '*/', { windows: false })); assert(!mm.contains('\\ab', '*/*', { windows: false })); assert(!mm.contains('\\ab', '*/[a-z]*', { windows: false })); assert(!mm.contains('\\ab', '*/a', { windows: false })); assert(!mm.contains('\\ab', '/', { windows: false })); assert(!mm.contains('\\ab', '/*', { windows: false })); assert(!mm.contains('\\ab', '/?', { windows: false })); assert(!mm.contains('\\ab', '/??', { windows: false })); assert(!mm.contains('\\ab', '/?b', { windows: false })); assert(!mm.contains('\\ab', '/a', { windows: false })); assert(!mm.contains('\\cd', '/*', { windows: false })); assert(!mm.contains('a\\b', '?/?', { windows: false })); assert(!mm.contains('a\\b\\c', 'a/*', { windows: false })); }); it('should match files that contain the given extension', () => { assert(mm.contains('a\\b\\c.md', '**/*.md')); assert(mm.contains('a\\b\\c.md', '*.md')); assert(mm.contains('a\\b\\c.md', '.md')); assert(mm.contains('a\\b\\c.md', 'a/*/*.md')); assert(mm.contains('a\\b\\c\\c.md', '*.md')); }); it('should match dotfiles when `dot` is true', () => { assert(mm.contains('a\\b\\c\\.xyz.md', '.*.md', { windows: true, dot: true })); assert(mm.contains('a\\b\\c\\.xyz.md', '**/*.md', { windows: true, dot: true })); assert(mm.contains('a\\b\\c\\.xyz.md', '**/.*.md', { windows: true, dot: true })); assert(mm.contains('a\\b\\c\\.xyz.md', 'a/b/c/*.md', { windows: true, dot: true })); assert(mm.contains('a\\b\\c\\.xyz.md', 'a/b/c/.*.md', { windows: true, dot: true })); }); it('should not match dotfiles when `dot` or `dotfiles` is not set', () => { assert(!mm.contains('a\\b\\d\\.md', 'a/b/c/*.md')); }); it('should match file paths', () => { assert(mm.contains('a\\b\\c\\xyz.md', 'a/b/c/*.md')); assert(mm.contains('a\\bb\\c\\xyz.md', 'a/*/c/*.md')); assert(mm.contains('a\\bbbb\\c\\xyz.md', 'a/*/c/*.md')); assert(mm.contains('a\\bb.bb\\c\\xyz.md', 'a/*/c/*.md')); assert(mm.contains('a\\bb.bb\\aa\\bb\\aa\\c\\xyz.md', 'a/**/c/*.md')); assert(mm.contains('a\\bb.bb\\aa\\b.b\\aa\\c\\xyz.md', 'a/**/c/*.md')); }); it('should return true when full file paths are matched', () => { assert(mm.contains('a\\.b', 'a/.*')); assert(mm.contains('a\\.b', 'a/')); assert(mm.contains('a\\b\\z\\.a', 'b/z')); assert(mm.contains('a\\b\\z\\.a', 'a/*/z/.a')); assert(mm.contains('a\\b\\c\\d\\e\\z\\c.md', 'a/**/z/*.md')); assert(mm.contains('a\\b\\c\\d\\e\\z\\c.md', 'b/c/d/e')); assert(mm.contains('a\\b\\c\\d\\e\\j\\n\\p\\o\\z\\c.md', 'a/**/j/**/z/*.md')); }); it('should match path segments', () => { assert(mm.contains('aaa\\bbb', 'aaa/bbb')); assert(mm.contains('aaa\\bbb', 'aaa/*')); assert(mm.contains('aaa\\bba\\ccc', '**/*/ccc')); assert(mm.contains('aaa\\bba\\ccc', '*/*a')); assert(mm.contains('aaa\\bba\\ccc', 'aaa*')); assert(mm.contains('aaa\\bba\\ccc', 'aaa**')); assert(mm.contains('aaa\\bba\\ccc', 'aaa/*')); assert(mm.contains('aaa\\bba\\ccc', 'aaa/**')); assert(mm.contains('aaa\\bba\\ccc', 'aaa/*/ccc')); assert(mm.contains('aaa\\bba\\ccc', 'bb')); assert(mm.contains('aaa\\bba\\ccc', 'bb*')); assert(mm.contains('aaa\\bbb', 'aaa[/]bbb')); assert(mm.contains('aaa\\bbb', 'aaa[\\\\/]bbb')); assert(!mm.contains('aaa\\bba\\ccc', 'aaa/*ccc')); assert(!mm.contains('aaa\\bba\\ccc', 'aaa/**ccc')); assert(!mm.contains('aaa\\bba\\ccc', 'aaa/*z')); assert(!mm.contains('aaa\\bba\\ccc', 'aaa/**z')); assert(!mm.contains('\\aaa', '*/*/*')); assert(!mm.contains('aaa\\bbb', '*/*/*')); assert(mm.contains('aaa\\bba\\ccc', '*/*/*')); assert(mm.contains('aaa\\bb\\aa\\rr', '*/*/*')); assert(mm.contains('ab\\zzz\\ejkl\\hi', '*/*z*/*/*i')); assert(mm.contains('ab\\zzz\\ejkl\\hi', '*/*jk*/*i')); }); it('should return false when full file paths are not matched', () => { assert(!mm.contains('a\\b\\z\\.a', 'b/a')); assert(!mm.contains('a\\.b', 'a/**/z/*.md')); assert(!mm.contains('a\\b\\z\\.a', 'a/**/z/*.a')); assert(!mm.contains('a\\b\\z\\.a', 'a/*/z/*.a')); assert(!mm.contains('a\\b\\c\\j\\e\\z\\c.txt', 'a/**/j/**/z/*.md')); }); it('should match dotfiles when a dot is explicitly defined in the pattern', () => { assert(mm.contains('a\\.c.md', 'a/.c.md')); assert(mm.contains('a\\b\\c\\.xyz.md', 'a/b/c/.*.md')); assert(mm.contains('a\\.c.md', '*.md')); assert(mm.contains('a\\b\\c\\d.a.md', 'a/b/c/*.md')); }); it('should match paths with leading `./`', () => { assert(!mm.contains('.\\.a', 'a/**/z/*.md')); assert(!mm.contains('.\\a\\b\\c\\d\\e\\z\\c.md', './a/**/j/**/z/*.md')); assert(mm.contains('.\\a\\b\\c\\d\\e\\j\\n\\p\\o\\z\\c.md', './a/**/j/**/z/*.md')); assert(mm.contains('.\\a\\b\\c\\d\\e\\z\\c.md', './a/**/z/*.md')); assert(mm.contains('.\\a\\b\\c\\d\\e\\z\\c.md', 'a/**/z/*.md')); assert(mm.contains('.\\a\\b\\c\\j\\e\\z\\c.md', './a/**/j/**/z/*.md')); assert(mm.contains('.\\a\\b\\c\\j\\e\\z\\c.md', 'a/**/j/**/z/*.md')); assert(mm.contains('.\\a\\b\\z\\.a', './a/**/z/.a')); assert(mm.contains('.\\a\\b\\z\\.a', 'a/**/z/.a')); }); }); }); micromatch-4.0.5/test/api.every.js000066400000000000000000000011351421714312500170650ustar00rootroot00000000000000'use strict'; const assert = require('assert'); const mm = require('..'); describe('.every()', () => { it('should return true if every string matches', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c']; assert(!mm.every(fixtures, ['z', '*/*'])); }); it('should return false when not all strings match', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c']; assert(!mm.every(fixtures, ['a/*', 'x/*'])); assert(mm.every(fixtures, ['(a|b)/*', '*/*'])); }); it('should arrayify a string value', () => { assert(mm.every('a', '*')); }); }); micromatch-4.0.5/test/api.isMatch.js000066400000000000000000000544121421714312500173310ustar00rootroot00000000000000'use strict'; const assert = require('assert'); const { isMatch, any } = require('..'); describe('.isMatch():', () => { describe('error handling:', () => { it('should throw on bad args', () => { assert.throws(() => isMatch({}), /Expected/i); }); }); describe('alias:', () => { it('should have the alias .any(...)', () => { assert.strictEqual(isMatch, any); }); }); describe('matching:', () => { it('should escape plus signs to match string literals', () => { assert(isMatch('a+b/src/glimini.js', 'a+b/src/*.js')); assert(isMatch('+b/src/glimini.js', '+b/src/*.js')); assert(isMatch('coffee+/src/glimini.js', 'coffee+/src/*.js')); assert(isMatch('coffee+/src/glimini.js', 'coffee+/src/*.js')); assert(isMatch('coffee+/src/glimini.js', 'coffee+/src/*')); }); it('should not escape plus signs that follow brackets', () => { assert(isMatch('a', '[a]+')); assert(isMatch('aa', '[a]+')); assert(isMatch('aaa', '[a]+')); assert(isMatch('az', '[a-z]+')); assert(isMatch('zzz', '[a-z]+')); }); it('should support stars following brackets', () => { assert(isMatch('a', '[a]*')); assert(isMatch('aa', '[a]*')); assert(isMatch('aaa', '[a]*')); assert(isMatch('az', '[a-z]*')); assert(isMatch('zzz', '[a-z]*')); }); it('should not escape plus signs that follow parens', () => { assert(isMatch('a', '(a)+')); assert(isMatch('ab', '(a|b)+')); assert(isMatch('aa', '(a)+')); assert(isMatch('aaab', '(a|b)+')); assert(isMatch('aaabbb', '(a|b)+')); }); it('should support stars following parens', () => { assert(isMatch('a', '(a)*')); assert(isMatch('ab', '(a|b)*')); assert(isMatch('aa', '(a)*')); assert(isMatch('aaab', '(a|b)*')); assert(isMatch('aaabbb', '(a|b)*')); }); it('should not match slashes with single stars', () => { assert(!isMatch('a/b', '(a)*')); assert(!isMatch('a/b', '[a]*')); assert(!isMatch('a/b', 'a*')); assert(!isMatch('a/b', '(a|b)*')); }); it('should not match dots with stars by default', () => { assert(!isMatch('.a', '(a)*')); assert(!isMatch('.a', '*[a]*')); assert(!isMatch('.a', '*[a]')); assert(!isMatch('.a', '*a*')); assert(!isMatch('.a', '*a')); assert(!isMatch('.a', '*(a|b)')); }); it('should match with non-glob patterns', () => { assert(isMatch('.', '.')); assert(isMatch('/a', '/a')); assert(!isMatch('/ab', '/a')); assert(isMatch('a', 'a')); assert(!isMatch('ab', '/a')); assert(!isMatch('ab', 'a')); assert(isMatch('ab', 'ab')); assert(!isMatch('abcd', 'cd')); assert(!isMatch('abcd', 'bc')); assert(!isMatch('abcd', 'ab')); }); it('should match non-leading dots', () => { assert(isMatch('a.b', 'a.b')); assert(isMatch('a.b', '*.b')); assert(isMatch('a.b', 'a.*')); assert(isMatch('a.b', '*.*')); assert(isMatch('a-b.c-d', 'a*.c*')); assert(isMatch('a-b.c-d', '*b.*d')); assert(isMatch('a-b.c-d', '*.*')); assert(isMatch('a-b.c-d', '*.*-*')); assert(isMatch('a-b.c-d', '*-*.*-*')); assert(isMatch('a-b.c-d', '*.c-*')); assert(isMatch('a-b.c-d', '*.*-d')); assert(isMatch('a-b.c-d', 'a-*.*-d')); assert(isMatch('a-b.c-d', '*-b.c-*')); assert(isMatch('a-b.c-d', '*-b*c-*')); // false assert(!isMatch('a-b.c-d', '*-bc-*')); }); it('should match with common glob patterns', () => { assert(!isMatch('/ab', './*/')); assert(!isMatch('/ef', '*')); assert(!isMatch('ab', './*/')); assert(!isMatch('ef', '/*')); assert(isMatch('/ab', '/*')); assert(isMatch('/cd', '/*')); assert(isMatch('ab', '*')); assert(isMatch('ab', './*')); assert(isMatch('ab', 'ab')); assert(isMatch('ab/', './*/')); }); it('should exactly match leading slash', () => { assert(!isMatch('ef', '/*')); assert(isMatch('/ef', '/*')); }); it('should match files with the given extension', () => { assert(!isMatch('.c.md', '*.md')); assert(!isMatch('.md', '*.md')); assert(!isMatch('a/b/c.md', 'a/*.md')); assert(!isMatch('a/b/c/c.md', '*.md')); assert(isMatch('.c.md', '.*.md')); assert(isMatch('.md', '.md')); assert(isMatch('a/b/c.js', 'a/**/*.*')); assert(isMatch('a/b/c.md', '**/*.md')); assert(isMatch('a/b/c.md', 'a/*/*.md')); assert(isMatch('c.md', '*.md')); assert(isMatch('c.md', '*.md')); }); it('should match wildcards', () => { assert(!isMatch('a/b/c/z.js', '*.js')); assert(!isMatch('a/b/z.js', '*.js')); assert(!isMatch('a/z.js', '*.js')); assert(isMatch('z.js', '*.js')); assert(isMatch('z.js', 'z*.js')); assert(isMatch('a/z.js', 'a/z*.js')); assert(isMatch('a/z.js', '*/z*.js')); assert(isMatch('a/b', 'a/b*')); assert(isMatch('a/b', 'a/b*', { dot: true })); }); it('should match globstars', () => { assert(isMatch('a/b/c/z.js', '**/*.js')); assert(isMatch('a/b/z.js', '**/*.js')); assert(isMatch('a/z.js', '**/*.js')); assert(isMatch('a/b/c/d/e/z.js', 'a/b/**/*.js')); assert(isMatch('a/b/c/d/z.js', 'a/b/**/*.js')); assert(isMatch('a/b/c/z.js', 'a/b/c/**/*.js')); assert(isMatch('a/b/c/z.js', 'a/b/c**/*.js')); assert(isMatch('a/b/c/z.js', 'a/b/**/*.js')); assert(isMatch('a/b/z.js', 'a/b/**/*.js')); assert(!isMatch('a/z.js', 'a/b/**/*.js')); assert(!isMatch('z.js', 'a/b/**/*.js')); // https://github.com/micromatch/micromatch/issues/15 assert(isMatch('z.js', 'z*')); assert(isMatch('z.js', '**/z*')); assert(isMatch('z.js', '**/z*.js')); assert(isMatch('z.js', '**/*.js')); assert(isMatch('foo', '**/foo')); }); it('issue #23', () => { assert(!isMatch('zzjs', 'z*.js')); assert(!isMatch('zzjs', '*z.js')); }); it('issue #24', () => { assert(isMatch('a', '**')); assert(isMatch('a', 'a/**')); assert(isMatch('a/', '**')); assert(isMatch('a/b/c/d', '**')); assert(isMatch('a/b/c/d/', '**')); assert(isMatch('a/b/c/d/', '**/**')); assert(isMatch('a/b/c/d/', '**/b/**')); assert(isMatch('a/b/c/d/', 'a/b/**')); assert(isMatch('a/b/c/d/', 'a/b/**/')); assert(isMatch('a/b/c/d/', 'a/b/**/c/**/')); assert(isMatch('a/b/c/d/', 'a/b/**/c/**/d/')); assert(!isMatch('a/b/c/d/', 'a/b/**/f')); assert(isMatch('a/b/c/d/e.f', 'a/b/**/**/*.*')); assert(isMatch('a/b/c/d/e.f', 'a/b/**/*.*')); assert(isMatch('a/b/c/d/e.f', 'a/b/**/c/**/d/*.*')); assert(isMatch('a/b/c/d/e.f', 'a/b/**/d/**/*.*')); assert(isMatch('a/b/c/d/g/e.f', 'a/b/**/d/**/*.*')); assert(isMatch('a/b/c/d/g/g/e.f', 'a/b/**/d/**/*.*')); assert(isMatch('a/b-c/z.js', 'a/b-*/**/z.js')); assert(isMatch('a/b-c/d/e/z.js', 'a/b-*/**/z.js')); }); it('should match slashes', () => { assert(!isMatch('bar/baz/foo', '*/foo')); assert(!isMatch('deep/foo/bar', '**/bar/*')); assert(!isMatch('deep/foo/bar/baz/x', '*/bar/**')); assert(!isMatch('foo/bar', 'foo?bar')); assert(!isMatch('foo/bar/baz', '**/bar*')); assert(!isMatch('foo/bar/baz', '**/bar**')); assert(!isMatch('foo/baz/bar', 'foo**bar')); assert(!isMatch('foo/baz/bar', 'foo*bar')); assert(isMatch('foo', 'foo/**')); assert(isMatch('a/b/j/c/z/x.md', 'a/**/j/**/z/*.md')); assert(isMatch('a/j/z/x.md', 'a/**/j/**/z/*.md')); assert(isMatch('bar/baz/foo', '**/foo')); assert(isMatch('deep/foo/bar/', '**/bar/**')); assert(isMatch('deep/foo/bar/baz', '**/bar/*')); assert(isMatch('deep/foo/bar/baz/', '**/bar/*/')); assert(isMatch('deep/foo/bar/baz/', '**/bar/**')); assert(isMatch('deep/foo/bar/baz/x', '**/bar/*/*')); assert(isMatch('foo/b/a/z/bar', 'foo/**/**/bar')); assert(isMatch('foo/b/a/z/bar', 'foo/**/bar')); assert(isMatch('foo/bar', 'foo/**/**/bar')); assert(isMatch('foo/bar', 'foo/**/bar')); assert(isMatch('foo/bar', 'foo[/]bar')); assert(isMatch('foo/bar/baz/x', '*/bar/**')); assert(isMatch('foo/baz/bar', 'foo/**/**/bar')); assert(isMatch('foo/baz/bar', 'foo/**/bar')); assert(isMatch('foobazbar', 'foo**bar')); assert(isMatch('XXX/foo', '**/foo')); // https://github.com/micromatch/micromatch/issues/89 assert(isMatch('foo//baz.md', 'foo//baz.md')); assert(isMatch('foo//baz.md', 'foo//*baz.md')); assert(!isMatch('foo//baz.md', 'foo/baz.md')); assert(!isMatch('foo/baz.md', 'foo//baz.md')); }); it('question marks should not match slashes', () => { assert(!isMatch('aaa/bbb', 'aaa?bbb')); }); it('should not match dotfiles when `dot` or `dotfiles` are not set', () => { assert(!isMatch('.c.md', '*.md')); assert(!isMatch('a/.c.md', '*.md')); assert(isMatch('a/.c.md', 'a/.c.md')); assert(!isMatch('.a', '*.md')); assert(!isMatch('.verb.txt', '*.md')); assert(isMatch('a/b/c/.xyz.md', 'a/b/c/.*.md')); assert(isMatch('.md', '.md')); assert(!isMatch('.txt', '.md')); assert(isMatch('.md', '.md')); assert(isMatch('.a', '.a')); assert(isMatch('.b', '.b*')); assert(isMatch('.ab', '.a*')); assert(isMatch('.ab', '.*')); assert(!isMatch('.ab', '*.*')); assert(!isMatch('.md', 'a/b/c/*.md')); assert(!isMatch('.a.md', 'a/b/c/*.md')); assert(isMatch('a/b/c/d.a.md', 'a/b/c/*.md')); assert(!isMatch('a/b/d/.md', 'a/b/c/*.md')); }); it('should match dotfiles when `dot` or `dotfiles` is set', () => { assert(isMatch('.c.md', '*.md', { dot: true })); assert(isMatch('.c.md', '.*', { dot: true })); assert(isMatch('a/b/c/.xyz.md', 'a/b/c/.*.md', { dot: true })); assert(isMatch('a/b/c/.xyz.md', 'a/b/c/*.md', { dot: true })); }); it('should match file paths', () => { assert(isMatch('a/b/c/xyz.md', 'a/b/c/*.md')); assert(isMatch('a/bb/c/xyz.md', 'a/*/c/*.md')); assert(isMatch('a/bbbb/c/xyz.md', 'a/*/c/*.md')); assert(isMatch('a/bb.bb/c/xyz.md', 'a/*/c/*.md')); assert(isMatch('a/bb.bb/aa/bb/aa/c/xyz.md', 'a/**/c/*.md')); assert(isMatch('a/bb.bb/aa/b.b/aa/c/xyz.md', 'a/**/c/*.md')); }); it('should match full file paths', () => { assert(!isMatch('a/.b', 'a/**/z/*.md')); assert(isMatch('a/.b', 'a/.*')); assert(!isMatch('a/b/z/.a', 'a/**/z/*.a')); assert(!isMatch('a/b/z/.a', 'a/*/z/*.a')); assert(isMatch('a/b/z/.a', 'a/*/z/.a')); assert(isMatch('a/b/c/d/e/z/c.md', 'a/**/z/*.md')); assert(isMatch('a/b/c/d/e/j/n/p/o/z/c.md', 'a/**/j/**/z/*.md')); assert(!isMatch('a/b/c/j/e/z/c.txt', 'a/**/j/**/z/*.md')); }); it('should match paths with leading `./` when pattern has `./`', () => { let format = str => str.replace(/^\.\//, ''); assert(isMatch('./a/b/c/d/e/j/n/p/o/z/c.md', './a/**/j/**/z/*.md', { format })); assert(isMatch('./a/b/c/d/e/z/c.md', './a/**/z/*.md', { format })); assert(isMatch('./a/b/c/j/e/z/c.md', './a/**/j/**/z/*.md', { format })); assert(isMatch('./a/b/z/.a', './a/**/z/.a', { format })); assert(!isMatch('./a/b/c/d/e/z/c.md', './a/**/j/**/z/*.md', { format })); assert(!isMatch('./a/b/c/j/e/z/c.txt', './a/**/j/**/z/*.md', { format })); }); it('should match paths with leading `./`', () => { let format = str => str.replace(/^\.\//, ''); assert(!isMatch('./.a', '*.a', { format })); assert(!isMatch('./.a', './*.a', { format })); assert(!isMatch('./.a', 'a/**/z/*.md', { format })); assert(!isMatch('./a/b/c/d/e/z/c.md', './a/**/j/**/z/*.md', { format })); assert(!isMatch('./a/b/c/j/e/z/c.txt', './a/**/j/**/z/*.md', { format })); assert(!isMatch('a/b/c/d/e/z/c.md', './a/**/j/**/z/*.md', { format })); assert(isMatch('./.a', './.a', { format })); assert(isMatch('./a/b/c.md', 'a/**/*.md', { format })); assert(isMatch('./a/b/c/d/e/j/n/p/o/z/c.md', './a/**/j/**/z/*.md', { format })); assert(isMatch('./a/b/c/d/e/z/c.md', '**/*.md', { format })); assert(isMatch('./a/b/c/d/e/z/c.md', './a/**/z/*.md', { format })); assert(isMatch('./a/b/c/d/e/z/c.md', 'a/**/z/*.md', { format })); assert(isMatch('./a/b/c/j/e/z/c.md', './a/**/j/**/z/*.md', { format })); assert(isMatch('./a/b/c/j/e/z/c.md', '?(./)a/**/j/**/z/*.md', { format })); assert(isMatch('./a/b/z/.a', './a/**/z/.a', { format })); assert(isMatch('./a/b/z/.a', '?(./)a/**/z/.a', { format })); assert(isMatch('.a', './.a', { format })); assert(isMatch('a/b/c.md', './a/**/*.md', { format })); assert(isMatch('a/b/c.md', 'a/**/*.md', { format })); assert(isMatch('a/b/c/d/e/z/c.md', 'a/**/z/*.md', { format })); assert(isMatch('a/b/c/j/e/z/c.md', 'a/**/j/**/z/*.md', { format })); }); }); describe('errors', () => { it('should throw an error when value is not a string', () => { assert.throws(() => isMatch()); }); }); describe('empty patterns', () => { it('should throw an error when empty patterns are defined', () => { assert.throws(() => isMatch('', '')); assert.throws(() => isMatch('', [''])); assert.throws(() => isMatch('.', '')); assert.throws(() => isMatch('.', [''])); assert.throws(() => isMatch('a', '')); assert.throws(() => isMatch('a', [''])); assert.throws(() => isMatch('ab', '')); assert.throws(() => isMatch('ab', [''])); assert.throws(() => isMatch('./', '')); assert.throws(() => isMatch('./', [''])); }); }); describe('non-globs', () => { it('should match literal paths', () => { assert(!isMatch('aaa', 'aa')); assert(isMatch('aaa', 'aaa')); assert(isMatch('aaa', ['aa', 'aaa'])); assert(isMatch('aaa/bbb', 'aaa/bbb')); assert(isMatch('aaa/bbb', 'aaa[/]bbb')); assert(isMatch('aaa/bbb', ['aaa\\bbb', 'aaa/bbb'])); assert(isMatch('aaa\\bbb', ['aaa\\bbb', 'aaa/bbb'])); }); }); describe('dots', () => { it('should match a dots with dots in the pattern', () => { assert(isMatch('.', '.')); }); }); describe('stars (single pattern)', () => { it('should return true when one of the given patterns matches the string', () => { assert(!isMatch('a/.b', 'a/')); assert(!isMatch('a/b/c/d/e/z/c.md', 'b/c/d/e')); assert(!isMatch('a/b/z/.a', 'b/z')); assert(isMatch('/ab', '*/*')); assert(isMatch('/ab', '*/*')); assert(isMatch('/ab', '/*')); assert(isMatch('/cd', '/*')); assert(isMatch('a', 'a')); assert(isMatch('a/.b', 'a/.*')); assert(isMatch('a/b/c/d/e/j/n/p/o/z/c.md', 'a/**/j/**/z/*.md')); assert(isMatch('a/b/c/d/e/z/c.md', 'a/**/z/*.md')); assert(isMatch('a/b/c/xyz.md', 'a/b/c/*.md')); assert(isMatch('a/b/c/xyz.md', ['foo', 'a/b/c/*.md'])); assert(isMatch('a/b/z/.a', 'a/*/z/.a')); assert(isMatch('a/bb.bb/aa/b.b/aa/c/xyz.md', 'a/**/c/*.md')); assert(isMatch('a/bb.bb/aa/bb/aa/c/xyz.md', 'a/**/c/*.md')); assert(isMatch('a/bb.bb/c/xyz.md', 'a/*/c/*.md')); assert(isMatch('a/bb/c/xyz.md', 'a/*/c/*.md')); assert(isMatch('a/bbbb/c/xyz.md', 'a/*/c/*.md')); assert(isMatch('aaa', ['foo', '*'])); assert(isMatch('ab', '*')); assert(isMatch('ab', './*')); assert(isMatch('ab', 'ab')); assert(isMatch('ab/', './*/')); }); it('should return false when the path does not match the pattern', () => { assert(!isMatch('ab/', '*/*')); assert(!isMatch('/ab', '*/')); assert(!isMatch('/ab', '*/a')); assert(!isMatch('/ab', '/')); assert(!isMatch('/ab', '/a')); assert(!isMatch('/ab', 'a/*')); assert(!isMatch('a/.b', 'a/')); assert(!isMatch('a/b/c', 'a/*')); assert(!isMatch('a/b/c', 'a/b')); assert(!isMatch('a/b/c/d/e/z/c.md', 'b/c/d/e')); assert(!isMatch('a/b/z/.a', 'b/z')); assert(!isMatch('ab', '*/*')); assert(!isMatch('ab', '/a')); assert(!isMatch('ab', 'a')); assert(!isMatch('ab', 'b')); assert(!isMatch('ab', 'c')); assert(!isMatch('abcd', 'ab')); assert(!isMatch('abcd', 'bc')); assert(!isMatch('abcd', 'c')); assert(!isMatch('abcd', 'cd')); assert(!isMatch('abcd', 'd')); assert(!isMatch('abcd', 'f')); assert(!isMatch('ef', '/*')); }); it('should match a path segment for each single star', () => { assert(!isMatch('aaa', '*/*/*')); assert(!isMatch('aaa/bb/aa/rr', '*/*/*')); assert(!isMatch('aaa/bba/ccc', 'aaa*')); assert(!isMatch('aaa/bba/ccc', 'aaa**')); assert(!isMatch('aaa/bba/ccc', 'aaa/*')); assert(!isMatch('aaa/bba/ccc', 'aaa/*ccc')); assert(!isMatch('aaa/bba/ccc', 'aaa/*z')); assert(!isMatch('aaa/bbb', '*/*/*')); assert(!isMatch('ab/zzz/ejkl/hi', '*/*jk*/*i')); assert(isMatch('aaa/bba/ccc', '*/*/*')); assert(isMatch('aaa/bba/ccc', 'aaa/**')); assert(isMatch('aaa/bbb', 'aaa/*')); assert(isMatch('ab/zzz/ejkl/hi', '*/*z*/*/*i')); assert(isMatch('abzzzejklhi', '*j*i')); }); it('should regard non-exclusive double-stars as single stars', () => { assert(!isMatch('aaa/bba/ccc', 'aaa/**ccc')); assert(!isMatch('aaa/bba/ccc', 'aaa/**z')); }); it('should return false when full file paths are not matched', () => { assert(!isMatch('a/b/z/.a', 'a/**/z/*.a')); assert(!isMatch('a/b/z/.a', 'a/*/z/*.a')); assert(!isMatch('a/.b', 'a/**/z/*.md')); assert(!isMatch('a/b/c/j/e/z/c.txt', 'a/**/j/**/z/*.md')); assert(!isMatch('a/b/c/xyz.md', 'a/b/**/c{d,e}/**/xyz.md')); assert(!isMatch('a/b/d/xyz.md', 'a/b/**/c{d,e}/**/xyz.md')); assert(!isMatch('a/b/z/.a', 'b/a')); }); }); describe('stars (multiple patterns)', () => { it('should return true when any of the patterns match', () => { assert(isMatch('.', ['.', 'foo'])); assert(isMatch('a', ['a', 'foo'])); assert(isMatch('ab', ['*', 'foo', 'bar'])); assert(isMatch('ab', ['*b', 'foo', 'bar'])); assert(isMatch('ab', ['./*', 'foo', 'bar'])); assert(isMatch('ab', ['a*', 'foo', 'bar'])); assert(isMatch('ab', ['ab', 'foo'])); }); it('should return false when none of the patterns match', () => { assert(!isMatch('/ab', ['/a', 'foo'])); assert(!isMatch('a/b/c', ['a/b', 'foo'])); assert(!isMatch('ab', ['*/*', 'foo', 'bar'])); assert(!isMatch('ab', ['/a', 'foo', 'bar'])); assert(!isMatch('ab', ['a', 'foo'])); assert(!isMatch('ab', ['b', 'foo'])); assert(!isMatch('ab', ['c', 'foo', 'bar'])); assert(!isMatch('abcd', ['ab', 'foo'])); assert(!isMatch('abcd', ['bc', 'foo'])); assert(!isMatch('abcd', ['c', 'foo'])); assert(!isMatch('abcd', ['cd', 'foo'])); assert(!isMatch('abcd', ['d', 'foo'])); assert(!isMatch('abcd', ['f', 'foo', 'bar'])); assert(!isMatch('ef', ['/*', 'foo', 'bar'])); }); }); describe('file extensions', () => { it('should match files that contain the given extension', () => { assert(isMatch('.c.md', '.*.md')); assert(isMatch('a/b/c.md', '**/*.md')); assert(isMatch('a/b/c.md', 'a/*/*.md')); assert(isMatch('c.md', '*.md')); }); it('should not match files that do not contain the given extension', () => { assert(!isMatch('.c.md', '*.md')); assert(!isMatch('.c.md', '.c.')); assert(!isMatch('.c.md', '.md')); assert(!isMatch('.md', '*.md')); assert(!isMatch('.md', '.m')); assert(!isMatch('a/b/c.md', '*.md')); assert(!isMatch('a/b/c.md', '.md')); assert(!isMatch('a/b/c.md', 'a/*.md')); assert(!isMatch('a/b/c/c.md', '*.md')); assert(!isMatch('a/b/c/c.md', 'c.js')); }); }); describe('dot files', () => { it('should match dotfiles when a dot is explicitly defined in the pattern', () => { assert(isMatch('.a', '.a')); assert(isMatch('.ab', '.*')); assert(isMatch('.ab', '.a*')); assert(isMatch('.b', '.b*')); assert(isMatch('.md', '.md')); assert(isMatch('a/.c.md', 'a/.c.md')); assert(isMatch('a/b/c/.xyz.md', 'a/b/c/.*.md')); assert(isMatch('a/b/c/d.a.md', 'a/b/c/*.md')); }); it('should not match dotfiles when a dot is not defined in the pattern', () => { assert(!isMatch('.abc', '.a')); assert(!isMatch('.c.md', '*.md')); assert(!isMatch('a/.c.md', '*.md')); }); it('should match dotfiles when `dot` is set', () => { assert(!isMatch('a/b/c/.xyz.md', '.*.md', { dot: true })); assert(isMatch('.c.md', '*.md', { dot: true })); assert(isMatch('.c.md', '.*', { dot: true })); assert(isMatch('a/b/c/.xyz.md', '**/*.md', { dot: true })); assert(isMatch('a/b/c/.xyz.md', '**/.*.md', { dot: true })); assert(isMatch('a/b/c/.xyz.md', 'a/b/c/*.md', { dot: true })); assert(isMatch('a/b/c/.xyz.md', 'a/b/c/.*.md', { dot: true })); }); it('should not match dotfiles when `dot` is not set', () => { assert(!isMatch('.a', '*.md')); assert(!isMatch('.ba', '.a')); assert(!isMatch('.a.md', 'a/b/c/*.md')); assert(!isMatch('.ab', '*.*')); assert(!isMatch('.md', 'a/b/c/*.md')); assert(!isMatch('.txt', '.md')); assert(!isMatch('.verb.txt', '*.md')); assert(!isMatch('a/b/d/.md', 'a/b/c/*.md')); }); }); describe('dot-slash', () => { it('should match paths with leading `./`', () => { let format = str => str.replace(/^\.\//, ''); assert(isMatch('./a', ['a', '?(./)*'], { format })); assert(isMatch('a', ['a', '?(./)*'], { format })); assert(isMatch('a', ['?(./)*'], { format })); assert(!isMatch('./.a', 'a/**/z/*.md', { format })); assert(!isMatch('./a/b/c/d/e/z/c.md', './a/**/j/**/z/*.md', { format })); assert(!isMatch('./a/b/c/j/e/z/c.txt', './a/**/j/**/z/*.md', { format })); assert(isMatch('./a/b/c/d/e/j/n/p/o/z/c.md', './a/**/j/**/z/*.md', { format })); assert(isMatch('./a/b/c/d/e/z/c.md', './a/**/z/*.md', { format })); assert(isMatch('./a/b/c/d/e/z/c.md', '?(./)a/**/z/*.md', { format })); assert(isMatch('./a/b/c/j/e/z/c.md', './a/**/j/**/z/*.md', { format })); assert(isMatch('./a/b/c/j/e/z/c.md', '?(./)a/**/j/**/z/*.md', { format })); assert(isMatch('./a/b/z/.a', './a/**/z/.a', { format })); assert(isMatch('./a/b/z/.a', '?(./)a/**/z/.a', { format })); }); }); }); micromatch-4.0.5/test/api.makeRe.js000066400000000000000000000005111421714312500171340ustar00rootroot00000000000000'use strict'; const assert = require('assert'); const mm = require('..'); describe('.makeRe()', () => { it('should throw an error when value is not a string', () => { assert.throws(() => mm.makeRe()); }); it('should create a regex for a glob pattern', () => { assert(mm.makeRe('*') instanceof RegExp); }); }); micromatch-4.0.5/test/api.match.js000066400000000000000000000112121421714312500170240ustar00rootroot00000000000000'use strict'; const path = require('path'); const assert = require('assert'); const mm = require('..'); const sep = path.sep; describe('.match()', () => { afterEach(() => (path.sep = sep)); after(() => (path.sep = sep)); describe('posix paths', () => { it('should return an array of matches for a literal string', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c']; assert.deepEqual(mm(fixtures, '(a/b)'), ['a/b']); assert.deepEqual(mm(fixtures, 'a/b'), ['a/b']); }); it('should support regex logical or', () => { let fixtures = ['a/a', 'a/b', 'a/c']; assert.deepEqual(mm(fixtures, 'a/(a|c)'), ['a/a', 'a/c']); assert.deepEqual(mm(fixtures, 'a/(a|b|c)'), ['a/a', 'a/b', 'a/c']); }); it('should support regex ranges', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'a/x/y', 'a/x']; assert.deepEqual(mm(fixtures, 'a/[b-c]'), ['a/b', 'a/c']); assert.deepEqual(mm(fixtures, 'a/[a-z]'), ['a/a', 'a/b', 'a/c', 'a/x']); }); it('should support negation patterns', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c']; assert.deepEqual(mm(fixtures, '!*/*'), []); assert.deepEqual(mm(fixtures, '!*/b'), ['a/a', 'a/c', 'b/a', 'b/c']); assert.deepEqual(mm(fixtures, '!a/*'), ['b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!a/b'), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!a/(b)'), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!a/(*)'), ['b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!(*/b)'), ['a/a', 'a/c', 'b/a', 'b/c']); assert.deepEqual(mm(fixtures, '!(a/b)'), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); }); }); describe('windows paths', () => { beforeEach(() => { path.sep = '\\'; }); afterEach(() => { path.sep = sep; }); it('should return an array of matches for a literal string', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']; assert.deepEqual(mm(fixtures, '(a/b)', { windows: false }), []); assert.deepEqual(mm(fixtures, '(a/b)'), ['a/b']); assert.deepEqual(mm(fixtures, 'a/b', { windows: false }), []); assert.deepEqual(mm(fixtures, 'a/b'), ['a/b']); }); it('should support regex logical or', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c']; assert.deepEqual(mm(fixtures, 'a/(a|c)', { windows: false }), []); assert.deepEqual(mm(fixtures, 'a\\\\(a|c)', { windows: false }), ['a\\a', 'a\\c']); assert.deepEqual(mm(fixtures, 'a/(a|c)'), ['a/a', 'a/c']); assert.deepEqual(mm(fixtures, 'a/(a|b|c)', { windows: false }), []); assert.deepEqual(mm(fixtures, 'a/(a|b|c)'), ['a/a', 'a/b', 'a/c']); }); it('should support regex ranges', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c', 'a\\x\\y', 'a\\x']; assert.deepEqual(mm(fixtures, 'a/[b-c]', { windows: false }), []); assert.deepEqual(mm(fixtures, 'a/[b-c]'), ['a/b', 'a/c']); assert.deepEqual(mm(fixtures, 'a/[a-z]', { windows: false }), []); assert.deepEqual(mm(fixtures, 'a/[a-z]'), ['a/a', 'a/b', 'a/c', 'a/x']); }); it('should support negation patterns', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']; assert.deepEqual(mm(fixtures, '!*/*'), []); assert.deepEqual(mm(fixtures, '!*/b', { windows: false }), ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']); assert.deepEqual(mm(fixtures, '!*/b'), ['a/a', 'a/c', 'b/a', 'b/c']); assert.deepEqual(mm(fixtures, '!a/*', { windows: false }), ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']); assert.deepEqual(mm(fixtures, '!a/*'), ['b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!a/b', { windows: false }), ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']); assert.deepEqual(mm(fixtures, '!a/b'), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!a/(b)', { windows: false }), ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']); assert.deepEqual(mm(fixtures, '!a/(b)'), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!a/(*)', { windows: false }), ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']); assert.deepEqual(mm(fixtures, '!a/(*)'), ['b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!(*/b)', { windows: false }), ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']); assert.deepEqual(mm(fixtures, '!(*/b)'), ['a/a', 'a/c', 'b/a', 'b/c']); assert.deepEqual(mm(fixtures, '!(a/b)', { windows: false }), ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']); assert.deepEqual(mm(fixtures, '!(a/b)'), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); }); }); }); micromatch-4.0.5/test/api.matchKeys.js000066400000000000000000000021451421714312500176650ustar00rootroot00000000000000'use strict'; const assert = require('assert'); const mm = require('..'); describe('.matchKeys()', () => { describe('error handling', () => { it('should throw when the first argument is not an object', () => { assert.throws(() => mm.matchKeys(), /Expected the first argument to be an object/); assert.throws(() => mm.matchKeys('foo'), /Expected the first argument to be an object/); assert.throws(() => mm.matchKeys(['foo']), /Expected the first argument to be an object/); }); }); describe('match object keys', () => { it('should return a new object with only keys that match the given glob pattern', () => { assert.deepEqual(mm.matchKeys({ a: 'a', b: 'b', c: 'c' }, '*'), { a: 'a', b: 'b', c: 'c' }); assert.deepEqual(mm.matchKeys({ a: 'a', b: 'b', c: 'c' }, 'a'), { a: 'a' }); assert.deepEqual(mm.matchKeys({ a: 'a', b: 'b', c: 'c' }, '[a-b]'), { a: 'a', b: 'b' }); assert.deepEqual(mm.matchKeys({ a: 'a', b: 'b', c: 'c' }, '(a|c)'), { a: 'a', c: 'c' }); assert.notDeepEqual(mm.matchKeys({ a: 'a', b: 'b', c: 'c' }, 'a'), { b: 'b' }); }); }); }); micromatch-4.0.5/test/api.matcher.js000066400000000000000000000171221421714312500173610ustar00rootroot00000000000000'use strict'; const path = require('path'); const assert = require('assert'); const mm = require('..'); const sep = path.sep; describe('.matcher()', () => { afterEach(() => (path.sep = sep)); after(() => (path.sep = sep)); describe('errors', () => { it('should throw an error when arguments are invalid', () => { assert.throws(() => mm.matcher({})); assert.throws(() => mm.matcher(null)); assert.throws(() => mm.matcher()); }); }); describe('posix paths', () => { it('should return an array of matches for a literal string', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c']; assert.deepEqual(mm(fixtures, '(a/b)'), ['a/b']); assert.deepEqual(mm(fixtures, 'a/b'), ['a/b']); }); it('should support regex logical or', () => { let fixtures = ['a/a', 'a/b', 'a/c']; assert.deepEqual(mm(fixtures, 'a/(a|c)'), ['a/a', 'a/c']); assert.deepEqual(mm(fixtures, 'a/(a|b|c)'), ['a/a', 'a/b', 'a/c']); }); it('should support regex ranges', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'a/x/y', 'a/x']; assert.deepEqual(mm(fixtures, 'a/[b-c]'), ['a/b', 'a/c']); assert.deepEqual(mm(fixtures, 'a/[a-z]'), ['a/a', 'a/b', 'a/c', 'a/x']); }); it('should support negation patterns', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c']; assert.deepEqual(mm(fixtures, '!*/*'), []); assert.deepEqual(mm(fixtures, '!*/b'), ['a/a', 'a/c', 'b/a', 'b/c']); assert.deepEqual(mm(fixtures, '!a/*'), ['b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!a/b'), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!a/(b)'), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!a/(*)'), ['b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!(*/b)'), ['a/a', 'a/c', 'b/a', 'b/c']); assert.deepEqual(mm(fixtures, '!(a/b)'), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); }); }); describe('posix paths (array of patterns)', () => { it('should return an array of matches for a literal string', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c']; assert.deepEqual(mm(fixtures, ['(a/b)']), ['a/b']); assert.deepEqual(mm(fixtures, ['a/b']), ['a/b']); }); it('should support regex logical or', () => { let fixtures = ['a/a', 'a/b', 'a/c']; assert.deepEqual(mm(fixtures, ['a/(a|c)']), ['a/a', 'a/c']); assert.deepEqual(mm(fixtures, ['a/(a|b|c)']), ['a/a', 'a/b', 'a/c']); }); it('should support regex ranges', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'a/x/y', 'a/x']; assert.deepEqual(mm(fixtures, ['a/[b-c]']), ['a/b', 'a/c']); assert.deepEqual(mm(fixtures, ['a/[a-z]']), ['a/a', 'a/b', 'a/c', 'a/x']); }); it('should support negation patterns', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c']; assert.deepEqual(mm(fixtures, ['!*/*']), []); assert.deepEqual(mm(fixtures, ['!*/*']), []); assert.deepEqual(mm(fixtures, ['!*/b']), ['a/a', 'a/c', 'b/a', 'b/c']); assert.deepEqual(mm(fixtures, ['!a/*']), ['b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, ['!a/b']), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, ['!a/(b)']), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, ['!a/(*)']), ['b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, ['!(*/b)']), ['a/a', 'a/c', 'b/a', 'b/c']); assert.deepEqual(mm(fixtures, ['!(a/b)']), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); }); }); describe('backlashes for path separators, on posix', () => { if (process.platform === 'win32') return; let format = str => str; it('should return an array of matches for a literal string', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']; assert.deepEqual(mm(fixtures, '(a/b)', { format }), []); assert.deepEqual(mm(fixtures, 'a/b', { format }), []); }); it('should support regex logical or', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c']; assert.deepEqual(mm(fixtures, 'a/(a|c)', { format }), []); assert.deepEqual(mm(fixtures, 'a/(a|b|c)', { format }), []); }); it('should support regex ranges', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c', 'a\\x\\y', 'a\\x']; assert.deepEqual(mm(fixtures, 'a/[b-c]', { format }), []); assert.deepEqual(mm(fixtures, 'a/[a-z]', { format }), []); }); it('should support negation patterns', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']; assert.deepEqual(mm(fixtures, '!*/*', { format }), fixtures); assert.deepEqual(mm(fixtures, '!*/b', { format }), fixtures); assert.deepEqual(mm(fixtures, '!a/*', { format }), fixtures); assert.deepEqual(mm(fixtures, '!a/b', { format }), fixtures); assert.deepEqual(mm(fixtures, '!a/(b)', { format }), fixtures); assert.deepEqual(mm(fixtures, '!a/(*)', { format }), fixtures); assert.deepEqual(mm(fixtures, '!(*/b)', { format }), fixtures); assert.deepEqual(mm(fixtures, '!(a/b)', { format }), fixtures); assert.deepEqual(mm(fixtures, '!*/*', { windows: true }), []); assert.deepEqual(mm(fixtures, ['!*/b'], { windows: true }), ['a/a', 'a/c', 'b/a', 'b/c']); assert.deepEqual(mm(fixtures, ['!a/*'], { windows: true }), ['b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, ['!a/b'], { windows: true }), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, ['!a/(b)'], { windows: true }), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, ['!a/(*)'], { windows: true }), ['b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, ['!(*/b)'], { windows: true }), ['a/a', 'a/c', 'b/a', 'b/c']); assert.deepEqual(mm(fixtures, ['!(a/b)'], { windows: true }), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); }); }); describe('windows paths', () => { beforeEach(() => { path.sep = '\\'; }); afterEach(() => { path.sep = sep; }); it('should return an array of matches for a literal string', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']; assert.deepEqual(mm(fixtures, '(a/b)'), ['a/b']); assert.deepEqual(mm(fixtures, '(a/b)', { windows: false }), []); assert.deepEqual(mm(fixtures, 'a/b'), ['a/b']); assert.deepEqual(mm(fixtures, 'a/b', { windows: false }), []); }); it('should support regex logical or', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c']; assert.deepEqual(mm(fixtures, 'a/(a|c)'), ['a/a', 'a/c']); assert.deepEqual(mm(fixtures, 'a/(a|b|c)'), ['a/a', 'a/b', 'a/c']); }); it('should support regex ranges', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c', 'a\\x\\y', 'a\\x']; assert.deepEqual(mm(fixtures, 'a/[b-c]'), ['a/b', 'a/c']); assert.deepEqual(mm(fixtures, 'a/[a-z]'), ['a/a', 'a/b', 'a/c', 'a/x']); }); it('should support negation patterns', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']; assert.deepEqual(mm(fixtures, '!*/*'), []); assert.deepEqual(mm(fixtures, '!*/b'), ['a/a', 'a/c', 'b/a', 'b/c']); assert.deepEqual(mm(fixtures, '!a/*'), ['b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!a/b'), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!a/(b)'), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!a/(*)'), ['b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, '!(*/b)'), ['a/a', 'a/c', 'b/a', 'b/c']); assert.deepEqual(mm(fixtures, '!(a/b)'), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); }); }); }); micromatch-4.0.5/test/api.not.js000066400000000000000000000123611421714312500165360ustar00rootroot00000000000000'use strict'; const path = require('path'); const sep = path.sep; const assert = require('assert'); const { not } = require('..'); describe('.not()', () => { beforeEach(() => { path.sep = '\\'; }); afterEach(() => { path.sep = sep; }); describe('posix paths', () => { it('should return an array of matches for a literal string', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c']; assert.deepEqual(not(fixtures, '(a/b)'), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(not(fixtures, 'a/b'), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); }); it('should support regex logical or', () => { let fixtures = ['a/a', 'a/b', 'a/c']; assert.deepEqual(not(fixtures, 'a/(a|c)'), ['a/b']); assert.deepEqual(not(fixtures, 'a/(a|b|c)'), []); }); it('should support regex ranges', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'a/x/y', 'a/x']; assert.deepEqual(not(fixtures, 'a/[b-c]'), ['a/a', 'a/x/y', 'a/x']); assert.deepEqual(not(fixtures, 'a/[a-z]'), ['a/x/y']); }); it('should support globs (*)', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'a/x', 'a/a/a', 'a/a/b', 'a/a/a/a', 'a/a/a/a/a']; assert.deepEqual(not(fixtures, 'a/*'), ['a/a/a', 'a/a/b', 'a/a/a/a', 'a/a/a/a/a']); assert.deepEqual(not(fixtures, 'a/*/a'), ['a/a', 'a/b', 'a/c', 'a/x', 'a/a/b', 'a/a/a/a', 'a/a/a/a/a']); assert.deepEqual(not(fixtures, 'a/*/*'), ['a/a', 'a/b', 'a/c', 'a/x', 'a/a/a/a', 'a/a/a/a/a']); assert.deepEqual(not(fixtures, 'a/*/*/*'), ['a/a', 'a/b', 'a/c', 'a/x', 'a/a/a', 'a/a/b', 'a/a/a/a/a']); assert.deepEqual(not(fixtures, 'a/*/*/*/*'), ['a/a', 'a/b', 'a/c', 'a/x', 'a/a/a', 'a/a/b', 'a/a/a/a']); }); it('should support globstars (**)', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'a/x', 'a/x/y', 'a/x/y/z']; assert.deepEqual(not(fixtures, 'a/**'), []); assert.deepEqual(not(fixtures, 'a/**/*'), []); assert.deepEqual(not(fixtures, 'a/**/**/*'), []); }); it('should support negation patterns', () => { let fixtures = ['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c']; assert.deepEqual(not(fixtures, '!a/b'), ['a/b']); assert.deepEqual(not(fixtures, '!a/(b)'), ['a/b']); assert.deepEqual(not(fixtures, '!(a/b)'), ['a/b']); }); }); describe('windows paths', () => { it('should return an array of matches for a literal string', () => { let fixtures = ['a', 'a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']; assert.deepEqual(not(fixtures, '(a/b)'), ['a', 'a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(not(fixtures, 'a/b'), ['a', 'a/a', 'a/c', 'b/a', 'b/b', 'b/c']); }); it('should support regex logical or', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c']; assert.deepEqual(not(fixtures, 'a/(a|c)'), ['a/b']); assert.deepEqual(not(fixtures, 'a/(a|b|c)'), []); }); it('should support regex ranges', () => { let format = str => str.replace(/\\/g, '/').replace(/^\.\//, ''); let fixtures = ['.\\a\\a', 'a\\a', 'a\\b', 'a\\c', 'a\\x', 'a\\x\\y']; assert.deepEqual(not(fixtures, '[a-c]/[a-c]', { format }), ['a/x', 'a/x/y']); assert.deepEqual(not(fixtures, 'a/[b-c]', { format }), ['a/a', 'a/x', 'a/x/y']); assert.deepEqual(not(fixtures, 'a/[a-z]', { format }), ['a/x/y']); }); it('should support globs (*)', () => { let format = str => str.replace(/\\/g, '/').replace(/^\.\//, ''); let fixtures = ['a\\a', 'a/a', 'a\\b', '.\\a\\b', 'a\\c', 'a\\x', 'a\\a\\a', 'a\\a\\b', 'a\\a\\a\\a', 'a\\a\\a\\a\\a']; assert.deepEqual(not(fixtures, 'a/*', { format }), ['a/a/a', 'a/a/b', 'a/a/a/a', 'a/a/a/a/a']); assert.deepEqual(not(fixtures, 'a/*/a', { format }), ['a/a', 'a/b', 'a/c', 'a/x', 'a/a/b', 'a/a/a/a', 'a/a/a/a/a']); assert.deepEqual(not(fixtures, 'a/*/*', { format }), ['a/a', 'a/b', 'a/c', 'a/x', 'a/a/a/a', 'a/a/a/a/a']); assert.deepEqual(not(fixtures, 'a/*/*/*', { format }), ['a/a', 'a/b', 'a/c', 'a/x', 'a/a/a', 'a/a/b', 'a/a/a/a/a']); assert.deepEqual(not(fixtures, 'a/*/*/*/*', { format }), ['a/a', 'a/b', 'a/c', 'a/x', 'a/a/a', 'a/a/b', 'a/a/a/a']); }); it('should support globstars (**)', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c', 'a\\x', 'a\\x\\y', 'a\\x\\y\\z']; let expected = ['a/a', 'a/b', 'a/c', 'a/x', 'a/x/y', 'a/x/y/z']; assert.deepEqual(not(fixtures, '*'), expected); assert.deepEqual(not(fixtures, '**'), []); assert.deepEqual(not(fixtures, '*/*'), ['a/x/y', 'a/x/y/z']); assert.deepEqual(not(fixtures, 'a/**'), []); assert.deepEqual(not(fixtures, 'a/x/**'), ['a/a', 'a/b', 'a/c']); assert.deepEqual(not(fixtures, 'a/**/*'), []); assert.deepEqual(not(fixtures, 'a/**/**/*'), []); }); it('should support negation patterns', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']; let expected = ['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c']; assert.deepEqual(not(fixtures, '!**'), expected); assert.deepEqual(not(fixtures, '!*/*'), expected); assert.deepEqual(not(fixtures, '!*'), []); assert.deepEqual(not(fixtures, '!a/b'), ['a/b']); assert.deepEqual(not(fixtures, '!a/(b)'), ['a/b']); assert.deepEqual(not(fixtures, '!(a/b)'), ['a/b']); }); }); }); micromatch-4.0.5/test/api.parse.js000066400000000000000000000012041421714312500170420ustar00rootroot00000000000000'use strict'; const assert = require('assert'); const mm = require('..'); describe('.parse()', () => { it('should parse a glob', function() { if (process.platform === 'win32') return this.skip(); let results = mm.parse('a/*'); let { tokens } = results[0]; tokens.forEach(token => { delete token.prev; }); assert.deepEqual(tokens, [ { type: 'bos', value: '', output: '' }, { type: 'text', value: 'a' }, { type: 'slash', value: '/', output: '\\/(?!\\.)(?=.)' }, { type: 'star', value: '*', output: '[^/]*?' }, { type: 'maybe_slash', value: '', output: '\\/?' } ]); }); }); micromatch-4.0.5/test/api.some.js000066400000000000000000000010411421714312500166720ustar00rootroot00000000000000'use strict'; const assert = require('assert'); const mm = require('..'); describe('.some()', () => { it('should return true if any matches are found', () => { var fixtures = ['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c']; assert(mm.some(fixtures, ['z', 'b/*'])); }); it('should return false if no matches are found', () => { var fixtures = ['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c']; assert(!mm.some(fixtures, ['z', 'x/*'])); }); it('should arrayify a string value', () => { assert(mm.some('a', ['*'])); }); }); micromatch-4.0.5/test/bash.js000066400000000000000000000255641421714312500161140ustar00rootroot00000000000000'use strict'; require('mocha'); const path = require('path'); const assert = require('assert'); const mm = require('..'); const isWindows = () => process.platform === 'win32' || path.sep === '\\'; const format = str => str.replace(/\\/g, '/').replace(/^\.\//, ''); // from the Bash 4.3 specification/unit tests const fixtures = ['\\\\', '*', '**', '\\*', 'a', 'a/*', 'abc', 'abd', 'abe', 'b', 'bb', 'bcd', 'bdir/', 'Beware', 'c', 'ca', 'cb', 'd', 'dd', 'de']; describe('bash options and features:', () => { // $echo a/{1..3}/b describe('bash', () => { it('should handle "regular globbing":', () => { assert.deepEqual(mm(fixtures, 'a*'), ['a', 'abc', 'abd', 'abe']); assert.deepEqual(mm(fixtures, '\\a*'), ['a', 'abc', 'abd', 'abe']); }); it('should match directories:', () => { assert.deepEqual(mm(fixtures, 'b*/'), ['bdir/']); }); it('should use quoted characters as literals:', () => { assert.deepEqual(mm(fixtures, '\\*', { windows: false }), ['*', '\\*']); assert.deepEqual(mm(fixtures, '\\^', { windows: false }), []); assert.deepEqual(mm(fixtures, 'a\\*', { windows: false }), []); assert.deepEqual(mm(fixtures, ['a\\*', '\\*'], { windows: false }), ['*', '\\*']); assert.deepEqual(mm(fixtures, ['a\\*'], { windows: false }), []); assert.deepEqual(mm(fixtures, ['c*', 'a\\*', '*q*'], { windows: false }), ['c', 'ca', 'cb']); }); it('should support quoted characters', () => { assert.deepEqual(mm(['***'], '"***"'), ['***']); assert.deepEqual(mm(['"***"'], '"***"'), ['"***"']); assert.deepEqual(mm(['*', '**', '*foo', 'bar'], '"*"*'), ['*', '**', '*foo']); }); it('should respect escaped characters', () => { assert.deepEqual(mm(fixtures, '\\**', { windows: false }), ['*', '**']); }); it('should respect escaped paths/dots:', () => { let format = str => str.replace(/\\/g, ''); assert.deepEqual(mm(['"\\.\\./*/"'], '"\\.\\./*/"', { windows: false }), ['"\\.\\./*/"']); assert.deepEqual(mm(['"\\.\\./*/"'], '"\\.\\./*/"', { format, windows: false }), ['"../*/"']); assert.deepEqual(mm(['s/\\..*//'], 's/\\..*//', { windows: false }), ['s/\\..*//']); }); it("Pattern from Larry Wall's Configure that caused bash to blow up:", () => { assert.deepEqual(mm(['"/^root:/{s/^[^:]*:[^:]*:\\([^:]*\\).*"\'$\'"/\\1/"'], '"/^root:/{s/^[^:]*:[^:]*:\\([^:]*\\).*"\'$\'"/\\1/"', { windows: false }), ['"/^root:/{s/^[^:]*:[^:]*:\\([^:]*\\).*"\'$\'"/\\1/"']); assert.deepEqual(mm(fixtures, '[a-c]b*'), ['abc', 'abd', 'abe', 'bb', 'cb']); }); it('should support character classes', () => { let f = fixtures.slice(); f.push('baz', 'bzz', 'BZZ', 'beware', 'BewAre'); f.sort(); assert.deepEqual(mm(f, 'a*[^c]'), ['abd', 'abe']); assert.deepEqual(mm(['a-b', 'aXb'], 'a[X-]b'), ['a-b', 'aXb']); assert.deepEqual(mm(f, '[a-y]*[^c]'), ['abd', 'abe', 'baz', 'bb', 'bcd', 'bdir/', 'beware', 'bzz', 'ca', 'cb', 'dd', 'de']); assert.deepEqual(mm(['a*b/ooo'], 'a\\*b/*'), ['a*b/ooo']); assert.deepEqual(mm(['a*b/ooo'], 'a\\*?/*'), ['a*b/ooo']); assert.deepEqual(mm(f, 'a[b]c'), ['abc']); assert.deepEqual(mm(f, 'a["b"]c'), ['abc']); assert.deepEqual(mm(f, 'a[\\\\b]c'), ['abc']); //<= backslash and a "b" assert.deepEqual(mm(f, 'a[\\b]c'), []); //<= word boundary in a character class assert.deepEqual(mm(f, 'a[b-d]c'), ['abc']); assert.deepEqual(mm(f, 'a?c'), ['abc']); assert.deepEqual(mm(['a-b'], 'a[]-]b'), ['a-b']); assert.deepEqual(mm(['man/man1/bash.1'], '*/man*/bash.*'), ['man/man1/bash.1']); if (isWindows()) { // should not match backslashes on windows, since backslashes are path // separators and negation character classes should not match path separators // unless it's explicitly defined in the character class assert.deepEqual(mm(f, '[^a-c]*'), ['d', 'dd', 'de', 'Beware', 'BewAre', 'BZZ', '*', '**', '\\*'].sort()); assert.deepEqual(mm(f, '[^a-c]*', { bash: false }), ['d', 'dd', 'de', 'BewAre', 'Beware', 'BZZ', '*', '**', '\\*'].sort()); assert.deepEqual(mm(f, '[^a-c]*', { nocase: true }), ['d', 'dd', 'de', '*', '**', '\\*'].sort()); } else { assert.deepEqual(mm(f, '[^a-c]*'), ['*', '**', 'BZZ', 'BewAre', 'Beware', '\\*', 'd', 'dd', 'de', '\\\\'].sort()); assert.deepEqual(mm(f, '[^a-c]*', { bash: false }), ['*', '**', 'BZZ', 'BewAre', 'Beware', '\\*', 'd', 'dd', 'de', '\\\\'].sort()); assert.deepEqual(mm(f, '[^a-c]*', { nocase: true }), ['*', '**', '\\*', 'd', 'dd', 'de', '\\\\'].sort()); } }); it('should support basic wildmatch (brackets) features', () => { assert(!mm.isMatch('aab', 'a[]-]b')); assert(!mm.isMatch('ten', '[ten]')); assert(!mm.isMatch('ten', 't[!a-g]n', { posix: true })); assert(mm.isMatch(']', ']')); assert(mm.isMatch('a-b', 'a[]-]b')); assert(mm.isMatch('a]b', 'a[]-]b')); assert(mm.isMatch('a]b', 'a[]]b')); assert(mm.isMatch('aab', 'a[\\]a\\-]b')); assert(mm.isMatch('ten', 't[a-g]n')); assert(mm.isMatch('ton', 't[!a-g]n', { posix: true })); assert(mm.isMatch('ton', 't[^a-g]n')); }); it('should support extended slash-matching features', () => { assert(!mm.isMatch('foo/bar', 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r')); assert(mm.isMatch('foo/bar', 'foo[/]bar')); assert(mm.isMatch('foo-bar', 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r')); }); it('should match literal parens', () => { assert(mm.isMatch('foo(bar)baz', 'foo[bar()]+baz')); }); it('should match escaped characters', () => { assert(!mm.isMatch('', '\\')); if (isWindows()) { assert(!mm.isMatch('XXX/\\', '[A-Z]+/\\')); assert(!mm.isMatch('XXX/\\', '[A-Z]+/\\\\')); } else { assert(mm.isMatch('XXX/\\', '[A-Z]+/\\')); assert(mm.isMatch('XXX/\\', '[A-Z]+/\\\\')); } assert(mm.isMatch('\\', '\\')); assert(mm.isMatch('[ab]', '\\[ab]')); assert(mm.isMatch('[ab]', '[\\[:]ab]')); }); it('should match brackets', () => { assert(!mm.isMatch(']', '[^]-]')); assert(!mm.isMatch(']', '[!]-]')); assert(mm.isMatch('a', '[^]-]')); assert(mm.isMatch('a', '[!]-]', { posix: true })); assert(mm.isMatch('[ab]', '[[]ab]')); }); it('should regard multiple consecutive stars as a single star', () => { assert.deepEqual(mm(['bbc', 'abc', 'bbd'], 'a**c'), ['abc']); assert.deepEqual(mm(['bbc', 'abc', 'bbd'], 'a***c'), ['abc']); assert.deepEqual(mm(['bbc', 'abc', 'bbc'], 'a*****?c'), ['abc']); assert.deepEqual(mm(['bbc', 'abc'], '?*****??'), ['bbc', 'abc']); assert.deepEqual(mm(['bbc', 'abc'], '*****??'), ['bbc', 'abc']); assert.deepEqual(mm(['bbc', 'abc'], '?*****?c'), ['bbc', 'abc']); assert.deepEqual(mm(['bbc', 'abc', 'bbd'], '?***?****c'), ['bbc', 'abc']); assert.deepEqual(mm(['bbc', 'abc'], '?***?****?'), ['bbc', 'abc']); assert.deepEqual(mm(['bbc', 'abc'], '?***?****'), ['bbc', 'abc']); assert.deepEqual(mm(['bbc', 'abc'], '*******c'), ['bbc', 'abc']); assert.deepEqual(mm(['bbc', 'abc'], '*******?'), ['bbc', 'abc']); assert.deepEqual(mm(['abcdecdhjk'], 'a*cd**?**??k'), ['abcdecdhjk']); assert.deepEqual(mm(['abcdecdhjk'], 'a**?**cd**?**??k'), ['abcdecdhjk']); assert.deepEqual(mm(['abcdecdhjk'], 'a**?**cd**?**??k***'), ['abcdecdhjk']); assert.deepEqual(mm(['abcdecdhjk'], 'a**?**cd**?**??***k'), ['abcdecdhjk']); assert.deepEqual(mm(['abcdecdhjk'], 'a**?**cd**?**??***k**'), ['abcdecdhjk']); assert.deepEqual(mm(['abcdecdhjk'], 'a****c**?**??*****'), ['abcdecdhjk']); }); it('none of these should output anything:', () => { assert.deepEqual(mm(['abc'], '??**********?****?'), []); assert.deepEqual(mm(['abc'], '??**********?****c'), []); assert.deepEqual(mm(['abc'], '?************c****?****'), []); assert.deepEqual(mm(['abc'], '*c*?**'), []); assert.deepEqual(mm(['abc'], 'a*****c*?**'), []); assert.deepEqual(mm(['abc'], 'a********???*******'), []); assert.deepEqual(mm(['a'], '[]'), []); assert.deepEqual(mm(['['], '[abc'), []); }); }); describe('wildmat', () => { it('Basic wildmat features', () => { assert(!mm.isMatch('foo', '*f')); assert(!mm.isMatch('foo', '??')); assert(!mm.isMatch('foo', 'bar')); assert(!mm.isMatch('foobar', 'foo\\*bar')); assert(mm.isMatch('?a?b', '\\??\\?b')); assert(mm.isMatch('aaaaaaabababab', '*ab')); assert(mm.isMatch('f\\oo', 'f\\oo')); assert(mm.isMatch('foo', '*')); assert(mm.isMatch('foo', '*foo*')); assert(mm.isMatch('foo', '???')); assert(mm.isMatch('foo', 'f*')); assert(mm.isMatch('foo', 'foo')); assert(mm.isMatch('foo*', 'foo\\*', { toPosixSlashes: false })); assert(mm.isMatch('foobar', '*ob*a*r*')); }); it('should support recursion', () => { assert(!mm.isMatch('-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*')); assert(!mm.isMatch('-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*')); assert(!mm.isMatch('ab/cXd/efXg/hi', '*X*i')); assert(!mm.isMatch('ab/cXd/efXg/hi', '*Xg*i')); assert(!mm.isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz', '**/*a*b*g*n*t')); assert(!mm.isMatch('foo', '*/*/*')); assert(!mm.isMatch('foo', 'fo')); assert(!mm.isMatch('foo/bar', '*/*/*')); assert(!mm.isMatch('foo/bar', 'foo?bar')); assert(!mm.isMatch('foo/bb/aa/rr', '*/*/*')); assert(!mm.isMatch('foo/bba/arr', 'foo*')); assert(!mm.isMatch('foo/bba/arr', 'foo**')); assert(!mm.isMatch('foo/bba/arr', 'foo/*')); assert(!mm.isMatch('foo/bba/arr', 'foo/**arr')); assert(!mm.isMatch('foo/bba/arr', 'foo/**z')); assert(!mm.isMatch('foo/bba/arr', 'foo/*arr')); assert(!mm.isMatch('foo/bba/arr', 'foo/*z')); assert(!mm.isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*')); assert(mm.isMatch('-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*')); assert(mm.isMatch('ab/cXd/efXg/hi', '**/*X*/**/*i')); assert(mm.isMatch('ab/cXd/efXg/hi', '*/*X*/*/*i')); assert(mm.isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt', '**/*a*b*g*n*t')); assert(mm.isMatch('abcXdefXghi', '*X*i')); assert(mm.isMatch('foo', 'foo')); assert(mm.isMatch('foo/bar', 'foo/*')); assert(mm.isMatch('foo/bar', 'foo/bar')); assert(mm.isMatch('foo/bar', 'foo[/]bar')); assert(mm.isMatch('foo/bb/aa/rr', '**/**/**')); assert(mm.isMatch('foo/bba/arr', '*/*/*')); assert(mm.isMatch('foo/bba/arr', 'foo/**')); assert(mm.isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', { toPosixSlashes: false })); }); }); }); micromatch-4.0.5/test/bash.spec.js000066400000000000000000000327301421714312500170360ustar00rootroot00000000000000'use strict'; require('mocha'); const path = require('path'); const util = require('util'); const assert = require('assert'); const { isMatch } = require('..'); let units = []; describe('bash.spec', () => { describe('dotglob', () => { it('"a/b/.x" should match "**/.x/**"', () => { assert(isMatch('a/b/.x', '**/.x/**', { bash: true })); }); it('".x" should match "**/.x/**"', () => { assert(isMatch('.x', '**/.x/**', { bash: true })); }); it('".x/" should match "**/.x/**"', () => { assert(isMatch('.x/', '**/.x/**', { bash: true })); }); it('".x/a" should match "**/.x/**"', () => { assert(isMatch('.x/a', '**/.x/**', { bash: true })); }); it('".x/a/b" should match "**/.x/**"', () => { assert(isMatch('.x/a/b', '**/.x/**', { bash: true })); }); it('".x/.x" should match "**/.x/**"', () => { assert(isMatch('.x/.x', '**/.x/**', { bash: true })); }); it('"a/.x" should match "**/.x/**"', () => { assert(isMatch('a/.x', '**/.x/**', { bash: true })); }); it('"a/b/.x/c" should match "**/.x/**"', () => { assert(isMatch('a/b/.x/c', '**/.x/**', { bash: true })); }); it('"a/b/.x/c/d" should match "**/.x/**"', () => { assert(isMatch('a/b/.x/c/d', '**/.x/**', { bash: true })); }); it('"a/b/.x/c/d/e" should match "**/.x/**"', () => { assert(isMatch('a/b/.x/c/d/e', '**/.x/**', { bash: true })); }); it('"a/b/.x/" should match "**/.x/**"', () => { assert(isMatch('a/b/.x/', '**/.x/**', { bash: true })); }); it('"a/.x/b" should match "**/.x/**"', () => { assert(isMatch('a/.x/b', '**/.x/**', { bash: true })); }); it('"a/.x/b/.x/c" should not match "**/.x/**"', () => { assert(!isMatch('a/.x/b/.x/c', '**/.x/**', { bash: true })); }); it('".bashrc" should not match "?bashrc"', () => { assert(!isMatch('.bashrc', '?bashrc', { bash: true })); }); it('should match trailing slashes with stars', () => { assert(isMatch('.bar.baz/', '.*.*', { bash: true })); }); it('".bar.baz/" should match ".*.*/"', () => { assert(isMatch('.bar.baz/', '.*.*/', { bash: true })); }); it('".bar.baz" should match ".*.*"', () => { assert(isMatch('.bar.baz', '.*.*', { bash: true })); }); }); describe('glob', () => { it('"a/b/.x" should match "**/.x/**"', () => { assert(isMatch('a/b/.x', '**/.x/**', { bash: true })); }); it('".x" should match "**/.x/**"', () => { assert(isMatch('.x', '**/.x/**', { bash: true })); }); it('".x/" should match "**/.x/**"', () => { assert(isMatch('.x/', '**/.x/**', { bash: true })); }); it('".x/a" should match "**/.x/**"', () => { assert(isMatch('.x/a', '**/.x/**', { bash: true })); }); it('".x/a/b" should match "**/.x/**"', () => { assert(isMatch('.x/a/b', '**/.x/**', { bash: true })); }); it('".x/.x" should match "**/.x/**"', () => { assert(isMatch('.x/.x', '**/.x/**', { bash: true })); }); it('"a/.x" should match "**/.x/**"', () => { assert(isMatch('a/.x', '**/.x/**', { bash: true })); }); it('"a/b/.x/c" should match "**/.x/**"', () => { assert(isMatch('a/b/.x/c', '**/.x/**', { bash: true })); }); it('"a/b/.x/c/d" should match "**/.x/**"', () => { assert(isMatch('a/b/.x/c/d', '**/.x/**', { bash: true })); }); it('"a/b/.x/c/d/e" should match "**/.x/**"', () => { assert(isMatch('a/b/.x/c/d/e', '**/.x/**', { bash: true })); }); it('"a/b/.x/" should match "**/.x/**"', () => { assert(isMatch('a/b/.x/', '**/.x/**', { bash: true })); }); it('"a/.x/b" should match "**/.x/**"', () => { assert(isMatch('a/.x/b', '**/.x/**', { bash: true })); }); it('"a/.x/b/.x/c" should not match "**/.x/**"', () => { assert(!isMatch('a/.x/b/.x/c', '**/.x/**', { bash: true })); }); it('"a/c/b" should match "a/*/b"', () => { assert(isMatch('a/c/b', 'a/*/b', { bash: true })); }); it('"a/.d/b" should not match "a/*/b"', () => { assert(!isMatch('a/.d/b', 'a/*/b', { bash: true })); }); it('"a/./b" should not match "a/*/b"', () => { assert(!isMatch('a/./b', 'a/*/b', { bash: true })); }); it('"a/../b" should not match "a/*/b"', () => { assert(!isMatch('a/../b', 'a/*/b', { bash: true })); }); it('"ab" should match "ab**"', () => { assert(isMatch('ab', 'ab**', { bash: true })); }); it('"abcdef" should match "ab**"', () => { assert(isMatch('abcdef', 'ab**', { bash: true })); }); it('"abef" should match "ab**"', () => { assert(isMatch('abef', 'ab**', { bash: true })); }); it('"abcfef" should match "ab**"', () => { assert(isMatch('abcfef', 'ab**', { bash: true })); }); it('"ab" should not match "ab***ef"', () => { assert(!isMatch('ab', 'ab***ef', { bash: true })); }); it('"abcdef" should match "ab***ef"', () => { assert(isMatch('abcdef', 'ab***ef', { bash: true })); }); it('"abef" should match "ab***ef"', () => { assert(isMatch('abef', 'ab***ef', { bash: true })); }); it('"abcfef" should match "ab***ef"', () => { assert(isMatch('abcfef', 'ab***ef', { bash: true })); }); it('".bashrc" should not match "?bashrc"', () => { assert(!isMatch('.bashrc', '?bashrc', { bash: true })); }); it('"abbc" should not match "ab?bc"', () => { assert(!isMatch('abbc', 'ab?bc', { bash: true })); }); it('"abc" should not match "ab?bc"', () => { assert(!isMatch('abc', 'ab?bc', { bash: true })); }); it('"a.a" should match "[a-d]*.[a-b]"', () => { assert(isMatch('a.a', '[a-d]*.[a-b]', { bash: true })); }); it('"a.b" should match "[a-d]*.[a-b]"', () => { assert(isMatch('a.b', '[a-d]*.[a-b]', { bash: true })); }); it('"c.a" should match "[a-d]*.[a-b]"', () => { assert(isMatch('c.a', '[a-d]*.[a-b]', { bash: true })); }); it('"a.a.a" should match "[a-d]*.[a-b]"', () => { assert(isMatch('a.a.a', '[a-d]*.[a-b]', { bash: true })); }); it('"a.a.a" should match "[a-d]*.[a-b]*.[a-b]"', () => { assert(isMatch('a.a.a', '[a-d]*.[a-b]*.[a-b]', { bash: true })); }); it('"a.a" should match "*.[a-b]"', () => { assert(isMatch('a.a', '*.[a-b]', { bash: true })); }); it('"a.b" should match "*.[a-b]"', () => { assert(isMatch('a.b', '*.[a-b]', { bash: true })); }); it('"a.a.a" should match "*.[a-b]"', () => { assert(isMatch('a.a.a', '*.[a-b]', { bash: true })); }); it('"c.a" should match "*.[a-b]"', () => { assert(isMatch('c.a', '*.[a-b]', { bash: true })); }); it('"d.a.d" should not match "*.[a-b]"', () => { assert(!isMatch('d.a.d', '*.[a-b]', { bash: true })); }); it('"a.bb" should not match "*.[a-b]"', () => { assert(!isMatch('a.bb', '*.[a-b]', { bash: true })); }); it('"a.ccc" should not match "*.[a-b]"', () => { assert(!isMatch('a.ccc', '*.[a-b]', { bash: true })); }); it('"c.ccc" should not match "*.[a-b]"', () => { assert(!isMatch('c.ccc', '*.[a-b]', { bash: true })); }); it('"a.a" should match "*.[a-b]*"', () => { assert(isMatch('a.a', '*.[a-b]*', { bash: true })); }); it('"a.b" should match "*.[a-b]*"', () => { assert(isMatch('a.b', '*.[a-b]*', { bash: true })); }); it('"a.a.a" should match "*.[a-b]*"', () => { assert(isMatch('a.a.a', '*.[a-b]*', { bash: true })); }); it('"c.a" should match "*.[a-b]*"', () => { assert(isMatch('c.a', '*.[a-b]*', { bash: true })); }); it('"d.a.d" should match "*.[a-b]*"', () => { assert(isMatch('d.a.d', '*.[a-b]*', { bash: true })); }); it('"d.a.d" should not match "*.[a-b]*.[a-b]*"', () => { assert(!isMatch('d.a.d', '*.[a-b]*.[a-b]*', { bash: true })); }); it('"d.a.d" should match "*.[a-d]*.[a-d]*"', () => { assert(isMatch('d.a.d', '*.[a-d]*.[a-d]*', { bash: true })); }); it('"a.bb" should match "*.[a-b]*"', () => { assert(isMatch('a.bb', '*.[a-b]*', { bash: true })); }); it('"a.ccc" should not match "*.[a-b]*"', () => { assert(!isMatch('a.ccc', '*.[a-b]*', { bash: true })); }); it('"c.ccc" should not match "*.[a-b]*"', () => { assert(!isMatch('c.ccc', '*.[a-b]*', { bash: true })); }); it('"a.a" should match "*[a-b].[a-b]*"', () => { assert(isMatch('a.a', '*[a-b].[a-b]*', { bash: true })); }); it('"a.b" should match "*[a-b].[a-b]*"', () => { assert(isMatch('a.b', '*[a-b].[a-b]*', { bash: true })); }); it('"a.a.a" should match "*[a-b].[a-b]*"', () => { assert(isMatch('a.a.a', '*[a-b].[a-b]*', { bash: true })); }); it('"c.a" should not match "*[a-b].[a-b]*"', () => { assert(!isMatch('c.a', '*[a-b].[a-b]*', { bash: true })); }); it('"d.a.d" should not match "*[a-b].[a-b]*"', () => { assert(!isMatch('d.a.d', '*[a-b].[a-b]*', { bash: true })); }); it('"a.bb" should match "*[a-b].[a-b]*"', () => { assert(isMatch('a.bb', '*[a-b].[a-b]*', { bash: true })); }); it('"a.ccc" should not match "*[a-b].[a-b]*"', () => { assert(!isMatch('a.ccc', '*[a-b].[a-b]*', { bash: true })); }); it('"c.ccc" should not match "*[a-b].[a-b]*"', () => { assert(!isMatch('c.ccc', '*[a-b].[a-b]*', { bash: true })); }); it('"abd" should match "[a-y]*[^c]"', () => { assert(isMatch('abd', '[a-y]*[^c]', { bash: true })); }); it('"abe" should match "[a-y]*[^c]"', () => { assert(isMatch('abe', '[a-y]*[^c]', { bash: true })); }); it('"bb" should match "[a-y]*[^c]"', () => { assert(isMatch('bb', '[a-y]*[^c]', { bash: true })); }); it('"bcd" should match "[a-y]*[^c]"', () => { assert(isMatch('bcd', '[a-y]*[^c]', { bash: true })); }); it('"ca" should match "[a-y]*[^c]"', () => { assert(isMatch('ca', '[a-y]*[^c]', { bash: true })); }); it('"cb" should match "[a-y]*[^c]"', () => { assert(isMatch('cb', '[a-y]*[^c]', { bash: true })); }); it('"dd" should match "[a-y]*[^c]"', () => { assert(isMatch('dd', '[a-y]*[^c]', { bash: true })); }); it('"de" should match "[a-y]*[^c]"', () => { assert(isMatch('de', '[a-y]*[^c]', { bash: true })); }); it('"bdir/" should match "[a-y]*[^c]"', () => { assert(isMatch('bdir/', '[a-y]*[^c]', { bash: true })); }); it('"abd" should match "**/*"', () => { assert(isMatch('abd', '**/*', { bash: true })); }); }); describe('globstar', () => { it('"a.js" should match "**/*.js"', () => { assert(isMatch('a.js', '**/*.js', { bash: true })); }); it('"a/a.js" should match "**/*.js"', () => { assert(isMatch('a/a.js', '**/*.js', { bash: true })); }); it('"a/a/b.js" should match "**/*.js"', () => { assert(isMatch('a/a/b.js', '**/*.js', { bash: true })); }); it('"a/b/z.js" should match "a/b/**/*.js"', () => { assert(isMatch('a/b/z.js', 'a/b/**/*.js', { bash: true })); }); it('"a/b/c/z.js" should match "a/b/**/*.js"', () => { assert(isMatch('a/b/c/z.js', 'a/b/**/*.js', { bash: true })); }); it('"foo.md" should match "**/*.md"', () => { assert(isMatch('foo.md', '**/*.md', { bash: true })); }); it('"foo/bar.md" should match "**/*.md"', () => { assert(isMatch('foo/bar.md', '**/*.md', { bash: true })); }); it('"foo/bar" should match "foo/**/bar"', () => { assert(isMatch('foo/bar', 'foo/**/bar', { bash: true })); }); it('"foo/bar" should match "foo/**bar"', () => { assert(isMatch('foo/bar', 'foo/**bar', { bash: true })); }); it('"ab/a/d" should match "**/*"', () => { assert(isMatch('ab/a/d', '**/*', { bash: true })); }); it('"ab/b" should match "**/*"', () => { assert(isMatch('ab/b', '**/*', { bash: true })); }); it('"a/b/c/d/a.js" should match "**/*"', () => { assert(isMatch('a/b/c/d/a.js', '**/*', { bash: true })); }); it('"a/b/c.js" should match "**/*"', () => { assert(isMatch('a/b/c.js', '**/*', { bash: true })); }); it('"a/b/c.txt" should match "**/*"', () => { assert(isMatch('a/b/c.txt', '**/*', { bash: true })); }); it('"a/b/.js/c.txt" should match "**/*"', () => { assert(isMatch('a/b/.js/c.txt', '**/*', { bash: true })); }); it('"a.js" should match "**/*"', () => { assert(isMatch('a.js', '**/*', { bash: true })); }); it('"za.js" should match "**/*"', () => { assert(isMatch('za.js', '**/*', { bash: true })); }); it('"ab" should match "**/*"', () => { assert(isMatch('ab', '**/*', { bash: true })); }); it('"a.b" should match "**/*"', () => { assert(isMatch('a.b', '**/*', { bash: true })); }); it('"foo/" should match "foo/**/"', () => { assert(isMatch('foo/', 'foo/**/', { bash: true })); }); it('"foo/bar" should not match "foo/**/"', () => { assert(!isMatch('foo/bar', 'foo/**/', { bash: true })); }); it('"foo/bazbar" should not match "foo/**/"', () => { assert(!isMatch('foo/bazbar', 'foo/**/', { bash: true })); }); it('"foo/barbar" should not match "foo/**/"', () => { assert(!isMatch('foo/barbar', 'foo/**/', { bash: true })); }); it('"foo/bar/baz/qux" should not match "foo/**/"', () => { assert(!isMatch('foo/bar/baz/qux', 'foo/**/', { bash: true })); }); it('"foo/bar/baz/qux/" should match "foo/**/"', () => { assert(isMatch('foo/bar/baz/qux/', 'foo/**/', { bash: true })); }); }); }); micromatch-4.0.5/test/bash/000077500000000000000000000000001421714312500155425ustar00rootroot00000000000000micromatch-4.0.5/test/bash/dotglob.txt000066400000000000000000000010551421714312500177360ustar00rootroot00000000000000f a/b/.x **/.x/** f .x **/.x/** f .x/ **/.x/** f .x/a **/.x/** f .x/a/b **/.x/** f .x/.x **/.x/** f a/.x **/.x/** t a/b/.x/c **/.x/** t a/b/.x/c/d **/.x/** t a/b/.x/c/d/e **/.x/** t a/b/.x/ **/.x/** t a/.x/b **/.x/** t a/.x/b/.x/c **/.x/** t .bashrc ?bashrc t .b/ *.* t .bar.baz/ *.* t .bar *.* f .bar !.*.* t .bar.baz/ .*.*/ t .bar.baz/ .*.* micromatch-4.0.5/test/bash/glob.txt000066400000000000000000000036651421714312500172400ustar00rootroot00000000000000f a/b/.x **/.x/** f .x **/.x/** f .x/ **/.x/** f .x/a **/.x/** f .x/a/b **/.x/** f .x/.x **/.x/** f a/.x **/.x/** t a/b/.x/c **/.x/** t a/b/.x/c/d **/.x/** t a/b/.x/c/d/e **/.x/** t a/b/.x/ **/.x/** t a/.x/b **/.x/** t a/.x/b/.x/c **/.x/** t a/c/b a/*/b t a/.d/b a/*/b t a/./b a/*/b t a/../b a/*/b t ab ab** t abcdef ab** t abef ab** t abcfef ab** f ab ab***ef t abcdef ab***ef t abef ab***ef t abcfef ab***ef t .bashrc ?bashrc f abbc ab?bc f abc ab?bc t a.a [a-d]*.[a-b] t a.b [a-d]*.[a-b] t c.a [a-d]*.[a-b] t a.a.a [a-d]*.[a-b] f a.a !*.[a-b] f a.b !*.[a-b] f a.a.a !*.[a-b] f c.a !*.[a-b] f d.a.d !*.[a-b] f a.bb !*.[a-b] f a.ccc !*.[a-b] f c.ccc !*.[a-b] f a.a !*.[a-b]* f a.b !*.[a-b]* f a.a.a !*.[a-b]* f c.a !*.[a-b]* f d.a.d !*.[a-b]* f a.bb !*.[a-b]* f a.ccc !*.[a-b]* f c.ccc !*.[a-b]* f a.a !*[a-b].[a-b]* f a.b !*[a-b].[a-b]* f a.a.a !*[a-b].[a-b]* f c.a !*[a-b].[a-b]* f d.a.d !*[a-b].[a-b]* f a.bb !*[a-b].[a-b]* f a.ccc !*[a-b].[a-b]* f c.ccc !*[a-b].[a-b]* t abd [a-y]*[^c] t abe [a-y]*[^c] t bb [a-y]*[^c] t bcd [a-y]*[^c] t ca [a-y]*[^c] t cb [a-y]*[^c] t dd [a-y]*[^c] t de [a-y]*[^c] t bdir/ [a-y]*[^c] f abd **/* micromatch-4.0.5/test/bash/globstar.txt000066400000000000000000000011751421714312500201240ustar00rootroot00000000000000f a.js **/*.js t a/a.js **/*.js t a/a/b.js **/*.js f a/b/z.js a/b/**/*.js t a/b/c/z.js a/b/**/*.js f foo.md **/*.md t foo/bar.md **/*.md f foo/bar foo/**/bar t foo/bar foo/**bar t ab/a/d **/* t ab/b **/* t a/b/c/d/a.js **/* t a/b/c.js **/* t a/b/c.txt **/* t a/b/.js/c.txt **/* f a.js **/* f za.js **/* f ab **/* f a.b **/* f foo/ foo/**/ f foo/bar foo/**/ f foo/bazbar foo/**/ f foo/barbar foo/**/ f foo/bar/baz/qux foo/**/ t foo/bar/baz/qux/ foo/**/ micromatch-4.0.5/test/braces-compiled.js000066400000000000000000000337151421714312500202250ustar00rootroot00000000000000'use strict'; const assert = require('assert'); const mm = require('..'); const optimize = (pattern, options) => { return mm.braces(pattern, Object.assign({ optimize: true }, options)); }; describe('braces - compiled', () => { describe('extglob characters', () => { it('should expand braces (in extglobs) when preceded by an extglob character', () => { let actual = mm.braces('abc/*!(-v@{1,2}.0).js'); assert.deepEqual(actual, ['abc/*!(-v@(1|2).0).js']); }); it('should expand braces when preceded by an extglob character', () => { let actual = mm.braces('abc/*-v@{1,2}.0.js'); assert.deepEqual(actual, ['abc/*-v@(1|2).0.js']); }); }); describe('sets', () => { describe('invalid sets', () => { it('should handle invalid sets:', () => { optimize('{0..10,braces}', ['(0..10|braces)']); optimize('{1..10,braces}', ['(1..10|braces)']); }); }); describe('escaping', () => { it('should not expand escaped braces', () => { optimize('\\{a,b,c,d,e}', ['{a,b,c,d,e}']); optimize('a/b/c/{x,y\\}', ['a/b/c/{x,y}']); optimize('a/\\{x,y}/cde', ['a/{x,y}/cde']); optimize('abcd{efgh', ['abcd{efgh']); optimize('{abc}', ['{abc}']); optimize('{x,y,\\{a,b,c\\}}', ['(x|y|\\{a|b|c\\})']); optimize('{x,y,{a,b,c\\}}', ['\\{x,y,(a|b|c\\})']); optimize('{x,y,{abc},trie}', ['(x|y|\\{abc\\}|trie)']); optimize('{x\\,y,\\{abc\\},trie}', ['(x,y|\\{abc\\}|trie)']); }); it('should handle spaces', () => { // Bash 4.3 says the following should be equivalent to `foo|(1|2)|bar`, // That makes sense in Bash, since ' ' is a separator, but not here. optimize('foo {1,2} bar', ['foo (1|2) bar']); }); it('should handle empty braces', () => { optimize('{ }', ['\\{ \\}']); optimize('{', ['\\{']); optimize('{}', ['\\{\\}']); optimize('}', ['\\}']); }); it('should escape braces when only one value is defined', () => { optimize('a{b}c', ['a\\{b\\}c']); optimize('a/b/c{d}e', ['a/b/c\\{d\\}e']); }); it('should not expand braces in sets with es6/bash-like variables', () => { optimize('abc/${ddd}/xyz', ['abc/\\$\\{ddd\\}/xyz']); optimize('a${b}c', ['a\\$\\{b\\}c']); optimize('a/{${b},c}/d', ['a/(\\$\\{b\\}|c)/d']); optimize('a${b,d}/{foo,bar}c', ['a\\$\\{b,d\\}/(foo|bar)c']); }); it('should not expand escaped commas.', () => { optimize('a{b\\,c\\,d}e', ['a\\{b,c,d\\}e']); optimize('a{b\\,c}d', ['a\\{b,c\\}d']); optimize('{abc\\,def}', ['\\{abc,def\\}']); optimize('{abc\\,def,ghi}', ['(abc,def|ghi)']); optimize('a/{b,c}/{x\\,y}/d/e', ['a/(b|c)/\\{x,y\\}/d/e']); }); it('should return sets with escaped commas', () => { optimize('a/{b,c}/{x\\,y}/d/e', ['a/(b|c)/\\{x,y\\}/d/e']); }); it('should not expand escaped braces.', () => { optimize('{a,b\\}c,d}', ['(a|b\\}c|d)']); optimize('\\{a,b,c,d,e}', ['\\{a,b,c,d,e\\}']); optimize('a/{z,\\{a,b,c,d,e}/d', ['a/(z|\\{a|b|c|d|e)/d']); optimize('a/\\{b,c}/{d,e}/f', ['a/\\{b,c\\}/(d|e)/f']); optimize('./\\{x,y}/{a..z..3}/', ['./\\{x,y\\}/(a|d|g|j|m|p|s|v|y)/']); }); it('should not expand escaped braces or commas.', () => { optimize('{x\\,y,\\{abc\\},trie}', ['(x,y|\\{abc\\}|trie)']); }); }); describe('set expansion', () => { it('should support sequence brace operators', () => { optimize('/usr/{ucb/{ex,edit},lib/{ex,how_ex}}', ['/usr/(ucb/(ex|edit)|lib/(ex|how_ex))']); optimize('ff{c,b,a}', ['ff(c|b|a)']); optimize('f{d,e,f}g', ['f(d|e|f)g']); optimize('x{{0..10},braces}y', ['x(([0-9]|10)|braces)y']); optimize('{1..10}', ['([1-9]|10)']); optimize('{a,b,c}', ['(a|b|c)']); optimize('{braces,{0..10}}', ['(braces|([0-9]|10))']); optimize('{l,n,m}xyz', ['(l|n|m)xyz']); optimize('{{0..10},braces}', ['(([0-9]|10)|braces)']); optimize('{{1..10..2},braces}', ['((1|3|5|7|9)|braces)']); optimize('{{1..10},braces}', ['(([1-9]|10)|braces)']); }); it('should expand multiple sets', () => { optimize('a/{a,b}/{c,d}/e', ['a/(a|b)/(c|d)/e']); optimize('a{b,c}d{e,f}g', ['a(b|c)d(e|f)g']); optimize('a/{x,y}/c{d,e}f.{md,txt}', ['a/(x|y)/c(d|e)f.(md|txt)']); }); it('should expand nested sets', () => { optimize('{a,b}{{a,b},a,b}', ['(a|b)((a|b)|a|b)']); optimize('a{b,c{d,e}f}g', ['a(b|c(d|e)f)g']); optimize('a{{x,y},z}b', ['a((x|y)|z)b']); optimize('f{x,y{g,z}}h', ['f(x|y(g|z))h']); optimize('a{b,c}{d,e}/hx/z', ['a(b|c)(d|e)/hx/z']); optimize('a{b,c{d,e},h}x/z', ['a(b|c(d|e)|h)x/z']); optimize('a{b,c{d,e},h}x{y,z}', ['a(b|c(d|e)|h)x(y|z)']); optimize('a{b,c{d,e},{f,g}h}x{y,z}', ['a(b|c(d|e)|(f|g)h)x(y|z)']); optimize('a-{b{d,e}}-c', ['a-\\{b(d|e)\\}-c']); }); it('should expand not modify non-brace characters', () => { optimize('a/b/{d,e}/*.js', ['a/b/(d|e)/*.js']); optimize('a/**/c/{d,e}/f*.js', ['a/**/c/(d|e)/f*.js']); optimize('a/**/c/{d,e}/f*.{md,txt}', ['a/**/c/(d|e)/f*.(md|txt)']); }); }); describe('commas', () => { it('should work with leading and trailing commas.', () => { optimize('a{b,}c', ['a(b|)c']); optimize('a{,b}c', ['a(|b)c']); }); }); describe('spaces', () => { it('should handle spaces', () => { optimize('0{1..9} {10..20}', ['0([1-9]) (1[0-9]|20)']); optimize('a{ ,c{d, },h}x', ['a( |c(d| )|h)x']); optimize('a{ ,c{d, },h} ', ['a( |c(d| )|h) ']); // see https://github.com/jonschlinkert/micromatch/issues/66 optimize('/Users/tobiasreich/Sites/aaa/bbb/ccc 2016/src/**/[^_]*.{html,ejs}', ['/Users/tobiasreich/Sites/aaa/bbb/ccc 2016/src/**/[^_]*.(html|ejs)']); }); }); }); /** * Ranges */ describe('ranges', () => { describe('escaping / invalid ranges', () => { it('should not try to expand ranges with decimals', () => { optimize('{1.1..2.1}', ['\\{1.1..2.1\\}']); optimize('{1.1..~2.1}', ['\\{1.1..~2.1\\}']); }); it('should escape invalid ranges:', () => { optimize('{1..0f}', ['{1..0f}']); optimize('{1..10..ff}', ['{1..10..ff}']); optimize('{1..10.f}', ['{1..10.f}']); optimize('{1..10f}', ['{1..10f}']); optimize('{1..20..2f}', ['{1..20..2f}']); optimize('{1..20..f2}', ['{1..20..f2}']); optimize('{1..2f..2}', ['{1..2f..2}']); optimize('{1..ff..2}', ['{1..ff..2}']); optimize('{1..ff}', ['{1..ff}']); optimize('{1..f}', ['([1-f])']); optimize('{1.20..2}', ['{1.20..2}']); }); it('weirdly-formed brace expansions -- fixed in post-bash-3.1', () => { optimize('a-{b{d,e}}-c', ['a-\\{b(d|e)\\}-c']); optimize('a-{bdef-{g,i}-c', ['a-\\{bdef-(g|i)-c']); }); it('should not expand quoted strings.', () => { optimize('{"klklkl"}{1,2,3}', ['\\{klklkl\\}(1|2|3)']); optimize('{"x,x"}', ['\\{x,x\\}']); }); it('should escaped outer braces in nested non-sets', () => { optimize('{a-{b,c,d}}', ['{a-(b|c|d)}']); optimize('{a,{a-{b,c,d}}}', ['(a|{a-(b|c|d)})']); }); it('should escape imbalanced braces', () => { optimize('a-{bdef-{g,i}-c', ['a-\\{bdef-(g|i)-c']); optimize('abc{', ['abc\\{']); optimize('{abc{', ['\\{abc\\{']); optimize('{abc', ['\\{abc']); optimize('}abc', ['\\}abc']); optimize('ab{c', ['ab\\{c']); optimize('{{a,b}', ['\\{(a|b)']); optimize('{a,b}}', ['(a|b)\\}']); optimize('abcd{efgh', ['abcd\\{efgh']); optimize('a{b{c{d,e}f}g}h', ['a(b(c(d|e)f)g)h']); optimize('f{x,y{{g,z}}h}', ['f(x|y((g|z))h)']); optimize('z{a,b},c}d', ['z(a|b),c\\}d']); optimize('a{b{c{d,e}f{x,y{{g}h', ['a\\{b\\{c(d|e)f\\{x,y\\{\\{g\\}h']); optimize('f{x,y{{g}h', ['f\\{x,y\\{\\{g\\}h']); optimize('f{x,y{{g}}h', ['f{x,y{{g}}h']); optimize('a{b{c{d,e}f{x,y{}g}h', ['a{b{c(d|e)f(x|y{}g)h']); optimize('f{x,y{}g}h', ['f(x|y\\{\\}g)h']); optimize('z{a,b{,c}d', ['z\\{a,b(|c)d']); }); }); describe('positive numeric ranges', () => { it('should expand numeric ranges', () => { optimize('a{0..3}d', ['a([0-3])d']); optimize('x{10..1}y', ['x([1-9]|10)y']); optimize('x{3..3}y', ['x3y']); optimize('{1..10}', ['([1-9]|10)']); optimize('{1..3}', ['([1-3])']); optimize('{1..9}', ['([1-9])']); optimize('{10..1}', ['([1-9]|10)']); optimize('{10..1}y', ['([1-9]|10)y']); optimize('{3..3}', ['3']); optimize('{5..8}', ['([5-8])']); }); }); describe('negative ranges', () => { it('should expand ranges with negative numbers', () => { optimize('{-1..-10}', ['(-[1-9]|-10)']); optimize('{-10..-1}', ['(-[1-9]|-10)']); optimize('{-20..0}', ['(-[1-9]|-1[0-9]|-20|0)']); optimize('{0..-5}', ['(-[1-5]|0)']); optimize('{9..-4}', ['(-[1-4]|[0-9])']); }); }); describe('alphabetical ranges', () => { it('should expand alphabetical ranges', () => { optimize('0{1..9}/{10..20}', ['0([1-9])/(1[0-9]|20)']); optimize('0{a..d}0', ['0([a-d])0']); optimize('a/{b..d}/e', ['a/([b-d])/e']); optimize('{1..f}', ['([1-f])']); optimize('{a..A}', ['([A-a])']); optimize('{A..a}', ['([A-a])']); optimize('{a..e}', ['([a-e])']); optimize('{A..E}', ['([A-E])']); optimize('{a..f}', ['([a-f])']); optimize('{a..z}', ['([a-z])']); optimize('{E..A}', ['([A-E])']); optimize('{f..1}', ['([1-f])']); optimize('{f..a}', ['([a-f])']); optimize('{f..f}', ['f']); }); it('should expand multiple ranges:', () => { optimize('a/{b..d}/e/{f..h}', ['a/([b-d])/e/([f-h])']); }); }); describe('combo', () => { it('should expand numerical ranges - positive and negative', () => { optimize('{-10..10}', ['(-[1-9]|-?10|[0-9])']); }); }); // HEADS UP! If you're using the `--mm` flag minimatch freezes on these describe('large numbers', () => { it('should expand large numbers', () => { optimize('{2147483645..2147483649}', ['(214748364[5-9])']); optimize('{214748364..2147483649}', ['(21474836[4-9]|2147483[7-9][0-9]|214748[4-9][0-9]{2}|214749[0-9]{3}|2147[5-9][0-9]{4}|214[8-9][0-9]{5}|21[5-9][0-9]{6}|2[2-9][0-9]{7}|[3-9][0-9]{8}|1[0-9]{9}|20[0-9]{8}|21[0-3][0-9]{7}|214[0-6][0-9]{6}|2147[0-3][0-9]{5}|21474[0-7][0-9]{4}|214748[0-2][0-9]{3}|2147483[0-5][0-9]{2}|21474836[0-4][0-9])']); }); }); describe('steps > positive ranges', () => { it('should expand ranges using steps:', () => { optimize('{1..10..1}', ['([1-9]|10)']); optimize('{1..10..2}', ['(1|3|5|7|9)']); optimize('{1..20..20}', ['1']); optimize('{1..20..20}', ['1']); optimize('{1..20..20}', ['1']); optimize('{1..20..2}', ['(1|3|5|7|9|11|13|15|17|19)']); optimize('{10..0..2}', ['(10|8|6|4|2|0)']); optimize('{10..1..2}', ['(10|8|6|4|2)']); optimize('{100..0..5}', ['(100|95|90|85|80|75|70|65|60|55|50|45|40|35|30|25|20|15|10|5|0)']); optimize('{2..10..1}', ['([2-9]|10)']); optimize('{2..10..2}', ['(2|4|6|8|10)']); optimize('{2..10..3}', ['(2|5|8)']); optimize('{a..z..2}', ['(a|c|e|g|i|k|m|o|q|s|u|w|y)']); }); it('should expand positive ranges with negative steps:', () => { optimize('{10..0..-2}', ['(10|8|6|4|2|0)']); }); }); describe('steps > negative ranges', () => { it('should expand negative ranges using steps:', () => { optimize('{-1..-10..-2}', ['(-(1|3|5|7|9))']); optimize('{-1..-10..2}', ['(-(1|3|5|7|9))']); optimize('{-10..-2..2}', ['(-(10|8|6|4|2))']); optimize('{-2..-10..1}', ['(-[2-9]|-10)']); optimize('{-2..-10..2}', ['(-(2|4|6|8|10))']); optimize('{-2..-10..3}', ['(-(2|5|8))']); optimize('{-50..-0..5}', ['(0|-(50|45|40|35|30|25|20|15|10|5))']); optimize('{-9..9..3}', ['(0|3|6|9|-(9|6|3))']); optimize('{10..1..-2}', ['(10|8|6|4|2)']); optimize('{100..0..-5}', ['(100|95|90|85|80|75|70|65|60|55|50|45|40|35|30|25|20|15|10|5|0)']); }); }); describe('steps > alphabetical ranges', () => { it('should expand alpha ranges with steps', () => { optimize('{a..e..2}', ['(a|c|e)']); optimize('{E..A..2}', ['(E|C|A)']); optimize('{a..z}', ['([a-z])']); optimize('{a..z..2}', ['(a|c|e|g|i|k|m|o|q|s|u|w|y)']); optimize('{z..a..-2}', ['(z|x|v|t|r|p|n|l|j|h|f|d|b)']); }); it('should expand alpha ranges with negative steps', () => { optimize('{z..a..-2}', ['(z|x|v|t|r|p|n|l|j|h|f|d|b)']); }); }); describe('padding', () => { it('unwanted zero-padding -- fixed post-bash-4.0', () => { optimize('{10..0..2}', ['(10|8|6|4|2|0)']); optimize('{10..0..-2}', ['(10|8|6|4|2|0)']); optimize('{-50..-0..5}', ['(0|-(50|45|40|35|30|25|20|15|10|5))']); }); }); }); describe('integration', () => { it('should work with dots in file paths', () => { optimize('../{1..3}/../foo', '../([1-3])/../foo'); optimize('../{2..10..2}/../foo', '../(2|4|6|8|10)/../foo'); optimize('../{1..3}/../{a,b,c}/foo', '../([1-3])/../(a|b|c)/foo'); optimize('./{a..z..3}/', './(a|d|g|j|m|p|s|v|y)/'); optimize('./{"x,y"}/{a..z..3}/', './\\{x,y\\}/(a|d|g|j|m|p|s|v|y)/'); }); it('should expand a complex combination of ranges and sets:', () => { optimize('a/{x,y}/{1..5}c{d,e}f.{md,txt}', 'a/(x|y)/([1-5])c(d|e)f.(md|txt)'); }); it('should expand complex sets and ranges in `bash` mode:', () => { optimize('a/{x,{1..5},y}/c{d}e', 'a/(x|([1-5])|y)/c\\{d\\}e'); }); }); }); micromatch-4.0.5/test/braces.js000066400000000000000000000222171421714312500164260ustar00rootroot00000000000000'use strict'; const assert = require('assert'); const mm = require('..'); const { isMatch, makeRe } = mm; describe('braces', () => { it('should handle extglobs in braces', () => { let fixtures = ['a', 'b', 'c', 'd', 'ab', 'ac', 'ad', 'bc', 'cb', 'bc,d', 'c,db', 'c,d', 'd)', '(b|c', '*(b|c', 'b|c', 'b|cc', 'cb|c', 'x(a|b|c)', 'x(a|c)', '(a|b|c)', '(a|c)']; assert.deepEqual(mm(fixtures, ['a', '*(b|c,d)']), ['a', 'b', 'bc,d', 'c,db', 'c,d']); assert.deepEqual(mm(fixtures, '{a,*(b|c,d)}'), ['a', 'b', 'bc,d', 'c,db', 'c,d']); assert.deepEqual(mm(fixtures, ['a', '*(b|c,d)'], { expand: true }), ['a', 'b', 'bc,d', 'c,db', 'c,d']); assert.deepEqual(mm(fixtures, '{a,*(b|c,d)}', { expand: true }), ['a', 'b', 'bc,d', 'c,db', 'c,d']); let expected = ['a', 'b', 'c', 'ab', 'ac', 'bc', 'cb']; assert.deepEqual(mm(fixtures, '*(a|b|c)'), expected); assert.deepEqual(mm(fixtures, '*(a|{b|c,c})'), expected); assert.deepEqual(mm(fixtures, '*(a|{b|c,c})', { expand: true }), expected); }); it('should not match with brace sets when disabled', () => { assert(!isMatch('a/a', 'a/{a,b}', { nobrace: true })); assert(!isMatch('a/b', 'a/{a,b}', { nobrace: true })); assert(!isMatch('a/c', 'a/{a,b}', { nobrace: true })); assert(!isMatch('b/b', 'a/{a,b}', { nobrace: true })); assert(!isMatch('b/b', 'a/{a,b,c}', { nobrace: true })); assert(!isMatch('a/c', 'a/{a,b,c}', { nobrace: true })); }); it('should not match with brace ranges when disabled', () => { assert(!isMatch('a/a', 'a/{a..c}', { nobrace: true })); assert(!isMatch('a/b', 'a/{a..c}', { nobrace: true })); assert(!isMatch('a/c', 'a/{a..c}', { nobrace: true })); }); it('should match with brace sets', () => { assert(isMatch('a/a', 'a/{a,b}')); assert(isMatch('a/b', 'a/{a,b}')); assert(!isMatch('a/c', 'a/{a,b}')); assert(!isMatch('b/b', 'a/{a,b}')); assert(!isMatch('b/b', 'a/{a,b,c}')); assert(isMatch('a/c', 'a/{a,b,c}')); }); it('should match with brace ranges', () => { assert(isMatch('a/a', 'a/{a..c}')); assert(isMatch('a/b', 'a/{a..c}')); assert(isMatch('a/c', 'a/{a..c}')); }); it('should not convert braces inside brackets', () => { assert(isMatch('foo{}baz', 'foo[{a,b}]+baz')); assert(isMatch('{a}{b}{c}', '[abc{}]+')); }); it('should support braces with empty elements', () => { assert(!isMatch('abc.txt', 'a{,b}.txt')); assert(!isMatch('abc.txt', 'a{a,b,}.txt')); assert(!isMatch('abc.txt', 'a{b,}.txt')); assert(isMatch('a.txt', 'a{,b}.txt')); assert(isMatch('a.txt', 'a{b,}.txt')); assert(isMatch('aa.txt', 'a{a,b,}.txt')); assert(isMatch('aa.txt', 'a{a,b,}.txt')); assert(isMatch('ab.txt', 'a{,b}.txt')); assert(isMatch('ab.txt', 'a{b,}.txt')); }); it('should support braces containing slashes', () => { assert(isMatch('a', '{a/,}a/**')); assert(isMatch('aa.txt', 'a{a,b/}*.txt')); assert(isMatch('ab/.txt', 'a{a,b/}*.txt')); assert(isMatch('ab/a.txt', 'a{a,b/}*.txt')); assert(isMatch('a/', '{a/,}a/**')); assert(isMatch('a/a/', '{a/,}a/**')); assert(isMatch('a/a', '{a/,}a/**')); assert(isMatch('a/a/a', '{a/,}a/**')); assert(isMatch('a/a/', '{a/,}a/**')); assert(isMatch('a/a/a/', '{a/,}a/**')); assert(isMatch('a/b/a/', '{a/,}b/**')); assert(isMatch('b/a/', '{a/,}b/**')); }); it('should support braces with slashes and empty elements', () => { assert(isMatch('a.txt', 'a{,/}*.txt')); assert(isMatch('ab.txt', 'a{,/}*.txt')); assert(isMatch('a/b.txt', 'a{,/}*.txt')); assert(isMatch('a/ab.txt', 'a{,/}*.txt')); }); it('should support braces with escaped parens and stars', () => { assert(isMatch('a.txt', 'a{,.*{foo,db},\\(bar\\)}.txt')); assert(!isMatch('adb.txt', 'a{,.*{foo,db},\\(bar\\)}.txt')); assert(isMatch('a.db.txt', 'a{,.*{foo,db},\\(bar\\)}.txt')); assert(isMatch('a.txt', 'a{,*.{foo,db},\\(bar\\)}.txt')); assert(!isMatch('adb.txt', 'a{,*.{foo,db},\\(bar\\)}.txt')); assert(isMatch('a.db.txt', 'a{,*.{foo,db},\\(bar\\)}.txt')); assert(isMatch('a', 'a{,.*{foo,db},\\(bar\\)}')); assert(!isMatch('adb', 'a{,.*{foo,db},\\(bar\\)}')); assert(isMatch('a.db', 'a{,.*{foo,db},\\(bar\\)}')); assert(isMatch('a', 'a{,*.{foo,db},\\(bar\\)}')); assert(!isMatch('adb', 'a{,*.{foo,db},\\(bar\\)}')); assert(isMatch('a.db', 'a{,*.{foo,db},\\(bar\\)}')); assert(!isMatch('a', '{,.*{foo,db},\\(bar\\)}')); assert(!isMatch('adb', '{,.*{foo,db},\\(bar\\)}')); assert(!isMatch('a.db', '{,.*{foo,db},\\(bar\\)}')); assert(isMatch('.db', '{,.*{foo,db},\\(bar\\)}')); assert(!isMatch('a', '{,*.{foo,db},\\(bar\\)}')); assert(isMatch('a', '{*,*.{foo,db},\\(bar\\)}')); assert(!isMatch('adb', '{,*.{foo,db},\\(bar\\)}')); assert(isMatch('a.db', '{,*.{foo,db},\\(bar\\)}')); }); it('should support braces in patterns with globstars', () => { assert(!isMatch('a/b/c/xyz.md', 'a/b/**/c{d,e}/**/xyz.md')); assert(!isMatch('a/b/d/xyz.md', 'a/b/**/c{d,e}/**/xyz.md')); assert(isMatch('a/b/cd/xyz.md', 'a/b/**/c{d,e}/**/xyz.md')); assert(isMatch('a/b/c/xyz.md', 'a/b/**/{c,d,e}/**/xyz.md')); assert(isMatch('a/b/d/xyz.md', 'a/b/**/{c,d,e}/**/xyz.md')); }); it('should support globstars enclosed in braces, with slashes and empty elements', () => { assert(isMatch('a.txt', 'a{,/**/}*.txt')); assert(isMatch('a/b.txt', 'a{,/**/,/}*.txt')); assert(isMatch('a/x/y.txt', 'a{,/**/}*.txt')); assert(!isMatch('a/x/y/z', 'a{,/**/}*.txt')); }); it('should support braces with globstars and empty elements', () => { assert(isMatch('a/b/foo/bar/baz.qux', 'a/b{,/**}/bar{,/**}/*.*')); assert(isMatch('a/b/bar/baz.qux', 'a/b{,/**}/bar{,/**}/*.*')); }); it('should support Kleene stars', () => { assert(isMatch('ab', '{ab,c}*')); assert(isMatch('abab', '{ab,c}*')); assert(isMatch('ababab', '{ab,c}*')); assert(isMatch('ababc', '{ab,c}*')); assert(isMatch('abc', '{ab,c}*')); assert(isMatch('abcab', '{ab,c}*')); assert(isMatch('abcc', '{ab,c}*')); assert(isMatch('c', '{ab,c}*')); assert(isMatch('cab', '{ab,c}*')); assert(isMatch('cabab', '{ab,c}*')); assert(isMatch('cabc', '{ab,c}*')); assert(isMatch('cc', '{ab,c}*')); assert(isMatch('ccab', '{ab,c}*')); assert(isMatch('ccc', '{ab,c}*')); }); it('should support Kleene plus', () => { assert(isMatch('ab', '{ab,c}+')); assert(isMatch('abab', '{ab,c}+')); assert(isMatch('abc', '{ab,c}+')); assert(isMatch('c', '{ab,c}+')); assert(isMatch('cab', '{ab,c}+')); assert(isMatch('cc', '{ab,c}+')); assert(isMatch('ababab', '{ab,c}+')); assert(isMatch('ababc', '{ab,c}+')); assert(isMatch('abcab', '{ab,c}+')); assert(isMatch('abcc', '{ab,c}+')); assert(isMatch('cabab', '{ab,c}+')); assert(isMatch('cabc', '{ab,c}+')); assert(isMatch('ccab', '{ab,c}+')); assert(isMatch('ccc', '{ab,c}+')); assert(isMatch('ccc', '{a,b,c}+')); assert(isMatch('a', '{a,b,c}+')); assert(isMatch('b', '{a,b,c}+')); assert(isMatch('c', '{a,b,c}+')); assert(isMatch('aa', '{a,b,c}+')); assert(isMatch('ab', '{a,b,c}+')); assert(isMatch('ac', '{a,b,c}+')); assert(isMatch('ba', '{a,b,c}+')); assert(isMatch('bb', '{a,b,c}+')); assert(isMatch('bc', '{a,b,c}+')); assert(isMatch('ca', '{a,b,c}+')); assert(isMatch('cb', '{a,b,c}+')); assert(isMatch('cc', '{a,b,c}+')); assert(isMatch('aaa', '{a,b,c}+')); assert(isMatch('aab', '{a,b,c}+')); assert(isMatch('abc', '{a,b,c}+')); }); it('should support braces', () => { assert(isMatch('a', '{a,b,c}')); assert(isMatch('b', '{a,b,c}')); assert(isMatch('c', '{a,b,c}')); assert(!isMatch('aa', '{a,b,c}')); assert(!isMatch('bb', '{a,b,c}')); assert(!isMatch('cc', '{a,b,c}')); }); it('should support regex quantifiers by escaping braces', () => { assert(!isMatch('a ', '@(!(a) \\{1,2\\})*', { unescape: true })); assert(!isMatch('a ', '@(!(a) \\{1,2\\})*', { unescape: true })); assert(!isMatch('a', '@(!(a) \\{1,2\\})*', { unescape: true })); assert(!isMatch('aa', '@(!(a) \\{1,2\\})*', { unescape: true })); assert(!isMatch('aaa', '@(!(a) \\{1,2\\})*', { unescape: true })); assert(!isMatch('b', '@(!(a) \\{1,2\\})*', { unescape: true })); assert(!isMatch('bb', '@(!(a) \\{1,2\\})*', { unescape: true })); assert(!isMatch('bbb', '@(!(a) \\{1,2\\})*', { unescape: true })); assert(isMatch(' a ', '@(!(a) \\{1,2\\})*', { unescape: true })); assert(isMatch('b ', '@(!(a) \\{1,2\\})*', { unescape: true })); assert(isMatch('b ', '@(!(a) \\{1,2\\})*', { unescape: true })); assert(isMatch('a ', '@(!(a \\{1,2\\}))*')); assert(isMatch('a b', '@(!(a \\{1,2\\}))*')); assert(isMatch('a b', '@(!(a \\{1,2\\}))*')); assert(isMatch('a ', '@(!(a \\{1,2\\}))*')); assert(isMatch('a ', '@(!(a \\{1,2\\}))*')); assert(isMatch('a', '@(!(a \\{1,2\\}))*')); assert(isMatch('aa', '@(!(a \\{1,2\\}))*')); assert(isMatch('b', '@(!(a \\{1,2\\}))*')); assert(isMatch('bb', '@(!(a \\{1,2\\}))*')); assert(isMatch(' a ', '@(!(a \\{1,2\\}))*')); assert(isMatch('b ', '@(!(a \\{1,2\\}))*')); assert(isMatch('b ', '@(!(a \\{1,2\\}))*')); }); }); micromatch-4.0.5/test/dotfiles.js000066400000000000000000000366471421714312500170140ustar00rootroot00000000000000'use strict'; require('mocha'); const assert = require('assert'); const mi = require('minimatch'); const mm = require('..'); const { isMatch } = mm; describe('dotfiles', () => { describe('file name matching', () => { it('should not match a dot when the dot is not explicitly defined', () => { assert(!isMatch('.dot', '*dot')); assert(!isMatch('a/.dot', 'a/*dot')); }); it('should not match leading dots with question marks', () => { assert(!isMatch('.dot', '?dot')); assert(!isMatch('/.dot', '/?dot')); assert(!isMatch('a/.dot', 'a/?dot')); }); it('should match double dots with double dots', () => { let fixtures = ['a/../a', 'ab/../ac', '../a', 'a', '../../b', '../c', '../c/d']; assert.deepEqual(mm(fixtures, '../*'), ['../a', '../c']); assert.deepEqual(mm(fixtures, '*/../*'), ['a/../a', 'ab/../ac']); assert.deepEqual(mm(fixtures, '**/../*'), ['a/../a', 'ab/../ac', '../a', '../c']); }); it('should not match exclusive double or single dots', () => { let fixtures = ['a/./b', 'a/../b', 'a/c/b', 'a/.d/b']; let opts = { dot: true }; assert.deepEqual(mm(fixtures, 'a/.*/b'), ['a/.d/b']); assert.deepEqual(mm(fixtures, 'a/.*/b', opts), ['a/.d/b']); assert.deepEqual(mm(fixtures, 'a/*/b', opts), ['a/c/b', 'a/.d/b']); assert(!isMatch('../c', '**/**/**', opts)); assert(!isMatch('../c', '**/**/**')); }); it('should match dotfiles when there is a leading dot:', () => { let files = ['a/b', 'a/.b', '.a/b', '.a/.b']; let dotfiles = ['.dotfile', '.dotfile.md']; let opts = { dot: true }; assert.deepEqual(mm(dotfiles, '.*.md', opts), ['.dotfile.md']); assert.deepEqual(mm(dotfiles, '.dotfile', opts), ['.dotfile']); assert.deepEqual(mm(dotfiles, '.dotfile*', opts), dotfiles); assert.deepEqual(mm(files, 'a/{.*,**}', opts), ['a/b', 'a/.b']); assert.deepEqual(mm(files, '{.*,**}', opts), files); assert.deepEqual(mm(files, '*/.*', opts), ['a/.b', '.a/.b']); }); it('should match dotfiles when there is not a leading dot:', () => { let files = ['.a', 'a', 'a/b', 'a/.b', '.a/b', '.a/.b']; let opts = { dot: true }; assert.deepEqual(mm(files, '*', opts), ['.a', 'a']); assert.deepEqual(mm(files, '*/*', opts), ['a/b', 'a/.b', '.a/b', '.a/.b']); assert.deepEqual(mm(files, '**', opts), files); assert.deepEqual(mm(['.dotfile'], '*.*', opts), ['.dotfile']); assert.deepEqual(mm(['.a', '.b', 'c', 'c.md'], '*.*', opts), ['.a', '.b', 'c.md']); assert.deepEqual(mm(['.dotfile'], '*.md', opts), []); assert.deepEqual(mm(['.verb.txt'], '*.md', opts), []); assert.deepEqual(mm(['a/b/c/.dotfile'], '*.md', opts), []); assert.deepEqual(mm(['a/b/c/.dotfile.md'], '*.md', opts), []); assert.deepEqual(mm(['a/b/c/.verb.md'], '**/*.md', opts), ['a/b/c/.verb.md']); assert.deepEqual(mm(['foo.md'], '*.md', opts), ['foo.md']); assert(isMatch('b/.c', '**/**/**', opts)); assert(!isMatch('b/.c', '**/**/**')); }); it('should use negation patterns on dotfiles:', () => { assert.deepEqual(mm(['.a', '.b', 'c', 'c.md'], '!.*'), ['c', 'c.md']); assert.deepEqual(mm(['.a', '.b', 'c', 'c.md'], '!(.*)'), ['c', 'c.md']); assert.deepEqual(mm(['.a', '.b', 'c', 'c.md'], '!(.*)*'), ['c', 'c.md']); assert.deepEqual(mm(['.a', '.b', 'c', 'c.md'], '!*.*'), ['.a', '.b', 'c']); }); it('should match dotfiles when `options.dot` is true:', () => { assert.deepEqual(mm(['.dotfile'], '*.*', { dot: true }), ['.dotfile']); assert.deepEqual(mm(['.dotfile'], '*.md', { dot: true }), []); assert.deepEqual(mm(['.dotfile'], '.dotfile', { dot: true }), ['.dotfile']); assert.deepEqual(mm(['.dotfile.md'], '.*.md', { dot: true }), ['.dotfile.md']); assert.deepEqual(mm(['.verb.txt'], '*.md', { dot: true }), []); assert.deepEqual(mm(['.verb.txt'], '*.md', { dot: true }), []); assert.deepEqual(mm(['a/b/c/.dotfile'], '*.md', { dot: true }), []); assert.deepEqual(mm(['a/b/c/.dotfile.md'], '**/*.md', { dot: true }), ['a/b/c/.dotfile.md']); assert.deepEqual(mm(['a/b/c/.dotfile.md'], '**/.*', { dot: false }), ['a/b/c/.dotfile.md']); assert.deepEqual(mm(['a/b/c/.dotfile.md'], '**/.*.md', { dot: false }), ['a/b/c/.dotfile.md']); assert.deepEqual(mm(['a/b/c/.dotfile.md'], '*.md', { dot: false }), []); assert.deepEqual(mm(['a/b/c/.dotfile.md'], '*.md', { dot: true }), []); assert.deepEqual(mm(['a/b/c/.verb.md'], '**/*.md', { dot: true }), ['a/b/c/.verb.md']); assert.deepEqual(mm(['d.md'], '*.md', { dot: true }), ['d.md']); }); it('should not match a dot when the dot is not explicitly defined', () => { let fixtures = ['a/b/.x', '.x', '.x/', '.x/a', '.x/a/b', '.x/.x', 'a/.x', 'a/b/.x/c', 'a/b/.x/c/d', 'a/b/.x/c/d/e', 'a/b/.x/', 'a/.x/b', 'a/.x/b/.x/c']; assert.deepEqual(mm(fixtures, '**'), []); assert.deepEqual(mm(fixtures, 'a/**/c'), []); }); it('should match a dot when the dot is explicitly defined', () => { let fixtures = ['.x', '.x/', '.x/.x', '.x/a', '.x/a/b', 'a/.x/.x/c', 'a/.x/.x/.x/c', 'a/.x/b', 'a/.x/b/.x/c', 'a/b/.x', 'a/b/.x/', 'a/b/.x/c', 'a/b/.x/c/d', 'a/b/.x/c/d/e']; let expected = ['.x', '.x/', '.x/.x', '.x/a', '.x/a/b', 'a/.x/.x/c', 'a/.x/b', 'a/b/.x', 'a/b/.x/', 'a/b/.x/c', 'a/b/.x/c/d', 'a/b/.x/c/d/e']; assert.deepEqual(mm(fixtures, '**/.x/.x/**'), ['.x/.x', 'a/.x/.x/c']); assert.deepEqual(mm(fixtures, '**/.x/*/.x/**'), ['a/.x/b/.x/c']); assert.deepEqual(mm(fixtures, '**/.x/**'), expected.filter(ele => !ele.includes('.x/.x'))); assert(isMatch('.bar.baz', '.*.*')); assert(isMatch('.bar.baz', '.*.*')); assert(!isMatch('.bar.baz', '.*.*/')); assert(isMatch('.bar.baz', '.*.baz')); assert(!isMatch('.bar.baz/', '.*.*')); assert(isMatch('.bar.baz/', '.*.*{,/}')); assert(isMatch('.bar.baz/', '.*.*/')); assert(isMatch('.dot', '.*ot')); assert(isMatch('.dot', '.[d]ot')); assert(isMatch('.dot.foo.bar', '.*ot.*.*')); assert(isMatch('.dotfile.js', '.*.js')); assert(isMatch('/.dot', '**/.[d]ot')); assert(isMatch('/.dot', '**/.dot*')); assert(isMatch('/.dot', '/.[d]ot')); assert(isMatch('/.dot', '/.dot*')); assert(isMatch('a/.dot', '**/.[d]ot')); assert(isMatch('a/.dot', '*/.[d]ot')); assert(isMatch('a/.dot', '*/.dot*')); assert(isMatch('a/b/.dot', '**/.[d]ot')); assert(isMatch('a/b/.dot', '**/.dot*')); assert(isMatch('.dot', '.[d]ot')); assert(isMatch('.dot', '.d?t')); assert(isMatch('.dot', '.dot*')); assert.deepEqual(mm('.dot', '.[d]ot'), ['.dot']); assert.deepEqual(mm('.dot', '.dot*'), ['.dot']); assert.deepEqual(mm('.dot', '.d?t'), ['.dot']); assert(!isMatch('.bar.baz', '.*.*/')); assert(isMatch('.bar.baz/', '.*.*{,/}')); assert(isMatch('.bar.baz', '.*.*')); assert(isMatch('.bar.baz', '.*.baz')); assert(isMatch('.bar.baz/', '.*.*/')); assert(isMatch('.dot', '.*ot')); assert(isMatch('.dot', '.[d]ot')); assert(isMatch('.dot.foo.bar', '.*ot.*.*')); assert(isMatch('.dotfile.js', '.*.js')); assert(isMatch('/.dot', '**/.[d]ot')); assert(isMatch('/.dot', '**/.dot*')); assert(isMatch('/.dot', '**/[.]dot')); assert(isMatch('/.dot', '/[.]dot')); assert(isMatch('a/.dot', '**/.[d]ot')); assert(isMatch('a/.dot', '*/.[d]ot')); assert(isMatch('a/.dot', '*/.dot*')); assert(isMatch('a/.dot', '*/[.]dot')); assert(isMatch('a/b/.dot', '**/.[d]ot')); assert(isMatch('a/b/.dot', '**/.dot*')); assert(isMatch('a/b/.dot', '**/[.]dot')); }); it('should match dots in root path when glob is prefixed with **/', () => { assert(isMatch('.x', '**/.x/**')); assert(!isMatch('.x/.x', '**/.x/**')); assert(isMatch('.x/.x', '**/.x/.x/**')); assert(isMatch('a/b/.x', '**/.x/**')); assert(isMatch('.x/', '**/.x/**')); assert(isMatch('.x/a', '**/.x/**')); assert(isMatch('.x/a/b', '**/.x/**')); assert(isMatch('a/.x/b', '**/.x/**')); assert(isMatch('a/b/.x', '**/.x')); assert(isMatch('a/b/.x/', '**/.x/**')); assert(isMatch('a/b/.x/c', '**/.x/**')); assert(isMatch('a/b/.x/c/d', '**/.x/**')); assert(isMatch('a/b/.x/c/d/e', '**/.x/**')); }); it('should not match dotfiles with single stars by default', () => { assert(isMatch('foo', '*')); assert(isMatch('foo/bar', '*/*')); assert(!isMatch('.foo', '*')); assert(!isMatch('.foo/bar', '*/*')); assert(!isMatch('.foo/.bar', '*/*')); assert(!isMatch('foo/.bar', '*/*')); assert(!isMatch('foo/.bar/baz', '*/*/*')); }); it('should work with dots in the path', () => { assert(isMatch('../test.js', '../*.js')); assert(!isMatch('../.test.js', '../*.js')); }); it('should not match dotfiles with globstars by default', () => { assert(!isMatch('.foo', '**/**')); assert(!isMatch('.foo', '**')); assert(!isMatch('.foo', '**/*')); assert(!isMatch('bar/.foo', '**/*')); assert(!isMatch('.bar', '**/*')); assert(!isMatch('foo/.bar', '**/*')); assert(!isMatch('foo/.bar', '**/*a*')); }); it('should match dotfiles when a leading dot is in the pattern', () => { assert(!isMatch('foo', '**/.*a*')); assert(isMatch('.bar', '**/.*a*')); assert(isMatch('foo/.bar', '**/.*a*')); assert(isMatch('.foo', '**/.*')); assert(!isMatch('foo', '.*a*')); assert(isMatch('.bar', '.*a*')); assert(!isMatch('bar', '.*a*')); assert(!isMatch('foo', '.b*')); assert(isMatch('.bar', '.b*')); assert(!isMatch('bar', '.b*')); assert(!isMatch('foo', '.*r')); assert(isMatch('.bar', '.*r')); assert(!isMatch('bar', '.*r')); }); it('should not match a dot when the dot is not explicitly defined', () => { assert(!isMatch('.dot', '**/*dot')); assert(!isMatch('.dot', '**/?dot')); assert(!isMatch('.dot', '*/*dot')); assert(!isMatch('.dot', '*/?dot')); assert(!isMatch('.dot', '*dot')); assert(!isMatch('.dot', '/*dot')); assert(!isMatch('.dot', '/?dot')); assert(!isMatch('/.dot', '**/*dot')); assert(!isMatch('/.dot', '**/?dot')); assert(!isMatch('/.dot', '*/*dot')); assert(!isMatch('/.dot', '*/?dot')); assert(!isMatch('/.dot', '/*dot')); assert(!isMatch('/.dot', '/?dot')); assert(!isMatch('a/.dot', '*/*dot')); assert(!isMatch('a/.dot', '*/?dot')); assert(!isMatch('a/.dot', 'a/*dot')); assert(!isMatch('a/b/.dot', '**/*dot')); assert(!isMatch('a/b/.dot', '**/?dot')); }); it('should not match leading dots with question marks', () => { assert(!isMatch('.dot', '?dot')); assert(!isMatch('/.dot', '/?dot')); assert(!isMatch('a/.dot', 'a/?dot')); }); it('should match with double dots', () => { assert(!isMatch('../../b', '**/../*')); assert(!isMatch('../../b', '*/../*')); assert(!isMatch('../../b', '../*')); assert(!isMatch('../a', '*/../*')); assert(!isMatch('../c', '*/../*')); assert(!isMatch('../c/d', '**/../*')); assert(!isMatch('../c/d', '*/../*')); assert(!isMatch('../c/d', '../*')); assert(!isMatch('a', '**/../*')); assert(!isMatch('a', '*/../*')); assert(!isMatch('a', '../*')); assert(!isMatch('a/../a', '../*')); assert(!isMatch('ab/../ac', '../*')); assert(!isMatch('a/../', '**/../*')); assert(isMatch('../a', '**/../*')); assert(isMatch('../a', '../*')); assert(isMatch('a/../a', '**/../*')); assert(isMatch('a/../a', '*/../*')); assert(isMatch('ab/../ac', '**/../*')); assert(isMatch('ab/../ac', '*/../*')); }); }); describe('multiple directories', () => { it('should not match a dot when the dot is not explicitly defined', () => { assert(!isMatch('.dot', '*dot')); assert(!isMatch('/.dot', '*/*dot')); assert(!isMatch('.dot', '**/*dot')); assert(!isMatch('.dot', '**/?dot')); assert(!isMatch('.dot', '*/*dot')); assert(!isMatch('.dot', '*/?dot')); assert(!isMatch('.dot', '/*dot')); assert(!isMatch('.dot', '/?dot')); assert(!isMatch('/.dot', '**/*dot')); assert(!isMatch('/.dot', '**/?dot')); assert(!isMatch('/.dot', '*/?dot')); assert(!isMatch('/.dot', '/*dot')); assert(!isMatch('/.dot', '/?dot')); assert(!isMatch('a/.dot', '*/*dot')); assert(!isMatch('a/.dot', '*/?dot')); assert(!isMatch('a/b/.dot', '**/*dot')); assert(!isMatch('a/b/.dot', '**/?dot')); // related https://github.com/jonschlinkert/micromatch/issues/63 assert(!isMatch('/aaa/bbb/.git', '/aaa/bbb/**')); assert(!isMatch('aaa/bbb/.git', 'aaa/bbb/**')); assert(!isMatch('/aaa/bbb/ccc/.git', '/aaa/bbb/**')); assert(isMatch('/aaa/bbb/.git', '/aaa/bbb/**', { dot: true })); assert(isMatch('aaa/bbb/.git', 'aaa/bbb/**', { dot: true })); assert(isMatch('/aaa/bbb/ccc/.git', '/aaa/bbb/**', { dot: true })); }); }); describe('options.dot', () => { it('should match dotfiles when `options.dot` is true', () => { assert(isMatch('.dotfile.js', '.*.js', { dot: true })); assert(isMatch('.dot', '*dot', { dot: true })); assert(isMatch('.dot', '?dot', { dot: true })); assert(isMatch('.dot', '[.]dot', { dot: true })); assert(isMatch('/a/b/.dot', '**/*dot', { dot: true })); assert(isMatch('/a/b/.dot', '**/.[d]ot', { dot: true })); assert(isMatch('/a/b/.dot', '**/?dot', { dot: true })); assert(isMatch('/a/b/.dot', '**/[.]dot', { dot: false })); assert(isMatch('/a/b/.dot', '**/[.]dot', { dot: true })); assert(isMatch('a/b/.dot', '**/*dot', { dot: true })); assert(isMatch('a/b/.dot', '**/.[d]ot', { dot: true })); assert(isMatch('a/b/.dot', '**/?dot', { dot: true })); assert(isMatch('a/b/.dot', '**/[.]dot', { dot: false })); assert(isMatch('a/b/.dot', '**/[.]dot', { dot: true })); }); it('should match dotfiles when `.dot` and `.matchBase` both defined', () => { assert(isMatch('a/b/.dot', '*dot', { dot: true, matchBase: true })); assert(isMatch('a/b/.dot', '[.]dot', { dot: true, matchBase: true })); assert(isMatch('a/b/.dot', '[.]dot', { dot: false, matchBase: true })); assert(isMatch('a/b/.dot', '?dot', { dot: true, matchBase: true })); }); it('should work when the path has leading `./`', () => { let format = str => str.replace(/^\.\//, ''); assert(!isMatch('./b/.c', '**', { format })); assert(isMatch('./b/.c', '**', { format, dot: true })); assert(isMatch('./b/.c', '**', { format, dot: true, matchBase: true })); }); it('should not match dotfiles when `options.dot` is false', () => { assert(!isMatch('a/b/.dot', '**/*dot', { dot: false })); assert(!isMatch('a/b/.dot', '**/?dot', { dot: false })); }); it('should not match dotfiles when `.dot` is false and `.matchBase` is true', () => { assert(!isMatch('a/b/.dot', '*dot', { dot: false, matchBase: true })); assert(!isMatch('a/b/.dot', '?dot', { dot: false, matchBase: true })); }); it('should not match dotfiles when `.dot` is not defined and a dot is not in the glob pattern', () => { assert(!isMatch('a/b/.dot', '*dot', { matchBase: true })); assert(!isMatch('a/b/.dot', '?dot', { matchBase: true })); assert(!isMatch('a/b/.dot', '**/*dot')); assert(!isMatch('a/b/.dot', '**/?dot')); }); }); }); micromatch-4.0.5/test/extglobs-bash.js000066400000000000000000002274021421714312500177340ustar00rootroot00000000000000'use strict'; require('mocha'); const path = require('path'); const assert = require('assert'); const { isMatch, makeRe } = require('..'); if (!process.env.ORIGINAL_PATH_SEP) { process.env.ORIGINAL_PATH_SEP = path.sep } /** * Some of tests were converted from bash 4.3, 4.4, and minimatch unit tests. */ describe('extglobs (bash)', () => { beforeEach(() => (path.sep = '\\')); afterEach(() => (path.sep = process.env.ORIGINAL_PATH_SEP)); it('should not match empty string iwth "*(0|1|3|5|7|9)"', () => { assert(!isMatch('', '*(0|1|3|5|7|9)', { bash: true })); }); it('"*(a|b[)" should not match "*(a|b\\[)"', () => { assert(!isMatch('*(a|b[)', '*(a|b\\[)', { bash: true })); }); it('"*(a|b[)" should not match "\\*\\(a|b\\[\\)"', () => { assert(!isMatch('*(a|b[)', '\\*\\(a|b\\[\\)', { bash: true })); }); it('"***" should match "\\*\\*\\*"', () => { assert(isMatch('***', '\\*\\*\\*', { bash: true })); }); it('"-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1" should not match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', { bash: true })); }); it('"-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1" should match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { assert(isMatch('-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', { bash: true })); }); it('"-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1" should not match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', { bash: true })); }); it('"/dev/udp/129.22.8.102/45" should match "/dev\\/@(tcp|udp)\\/*\\/*"', () => { assert(isMatch('/dev/udp/129.22.8.102/45', '/dev\\/@(tcp|udp)\\/*\\/*', { bash: true })); }); it('"/x/y/z" should match "/x/y/z"', () => { assert(isMatch('/x/y/z', '/x/y/z', { bash: true })); }); it('"0377" should match "+([0-7])"', () => { assert(isMatch('0377', '+([0-7])', { bash: true })); }); it('"07" should match "+([0-7])"', () => { assert(isMatch('07', '+([0-7])', { bash: true })); }); it('"09" should not match "+([0-7])"', () => { assert(!isMatch('09', '+([0-7])', { bash: true })); }); it('"1" should match "0|[1-9]*([0-9])"', () => { assert(isMatch('1', '0|[1-9]*([0-9])', { bash: true })); }); it('"12" should match "0|[1-9]*([0-9])"', () => { assert(isMatch('12', '0|[1-9]*([0-9])', { bash: true })); }); it('"123abc" should not match "(a+|b)*"', () => { assert(!isMatch('123abc', '(a+|b)*', { bash: true })); }); it('"123abc" should not match "(a+|b)+"', () => { assert(!isMatch('123abc', '(a+|b)+', { bash: true })); }); it('"123abc" should match "*?(a)bc"', () => { assert(isMatch('123abc', '*?(a)bc', { bash: true })); }); it('"123abc" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('123abc', 'a(b*(foo|bar))d', { bash: true })); }); it('"123abc" should not match "ab*(e|f)"', () => { assert(!isMatch('123abc', 'ab*(e|f)', { bash: true })); }); it('"123abc" should not match "ab**"', () => { assert(!isMatch('123abc', 'ab**', { bash: true })); }); it('"123abc" should not match "ab**(e|f)"', () => { assert(!isMatch('123abc', 'ab**(e|f)', { bash: true })); }); it('"123abc" should not match "ab**(e|f)g"', () => { assert(!isMatch('123abc', 'ab**(e|f)g', { bash: true })); }); it('"123abc" should not match "ab***ef"', () => { assert(!isMatch('123abc', 'ab***ef', { bash: true })); }); it('"123abc" should not match "ab*+(e|f)"', () => { assert(!isMatch('123abc', 'ab*+(e|f)', { bash: true })); }); it('"123abc" should not match "ab*d+(e|f)"', () => { assert(!isMatch('123abc', 'ab*d+(e|f)', { bash: true })); }); it('"123abc" should not match "ab?*(e|f)"', () => { assert(!isMatch('123abc', 'ab?*(e|f)', { bash: true })); }); it('"12abc" should not match "0|[1-9]*([0-9])"', () => { assert(!isMatch('12abc', '0|[1-9]*([0-9])', { bash: true })); }); it('"137577991" should match "*(0|1|3|5|7|9)"', () => { assert(isMatch('137577991', '*(0|1|3|5|7|9)', { bash: true })); }); it('"2468" should not match "*(0|1|3|5|7|9)"', () => { assert(!isMatch('2468', '*(0|1|3|5|7|9)', { bash: true })); }); it('"?a?b" should match "\\??\\?b"', () => { assert(isMatch('?a?b', '\\??\\?b', { bash: true })); }); it('"\\a\\b\\c" should not match "abc"', () => { assert(!isMatch('\\a\\b\\c', 'abc', { bash: true })); }); it('"a" should match "!(*.a|*.b|*.c)"', () => { assert(isMatch('a', '!(*.a|*.b|*.c)', { bash: true })); }); it('"a" should not match "!(a)"', () => { assert(!isMatch('a', '!(a)', { bash: true })); }); it('"a" should not match "!(a)*"', () => { assert(!isMatch('a', '!(a)*', { bash: true })); }); it('"a" should match "(a)"', () => { assert(isMatch('a', '(a)', { bash: true })); }); it('"a" should not match "(b)"', () => { assert(!isMatch('a', '(b)', { bash: true })); }); it('"a" should match "*(a)"', () => { assert(isMatch('a', '*(a)', { bash: true })); }); it('"a" should match "+(a)"', () => { assert(isMatch('a', '+(a)', { bash: true })); }); it('"a" should match "?"', () => { assert(isMatch('a', '?', { bash: true })); }); it('"a" should match "?(a|b)"', () => { assert(isMatch('a', '?(a|b)', { bash: true })); }); it('"a" should not match "??"', () => { assert(!isMatch('a', '??', { bash: true })); }); it('"a" should match "a!(b)*"', () => { assert(isMatch('a', 'a!(b)*', { bash: true })); }); it('"a" should match "a?(a|b)"', () => { assert(isMatch('a', 'a?(a|b)', { bash: true })); }); it('"a" should match "a?(x)"', () => { assert(isMatch('a', 'a?(x)', { bash: true })); }); it('"a" should not match "a??b"', () => { assert(!isMatch('a', 'a??b', { bash: true })); }); it('"a" should not match "b?(a|b)"', () => { assert(!isMatch('a', 'b?(a|b)', { bash: true })); }); it('"a((((b" should match "a(*b"', () => { assert(isMatch('a((((b', 'a(*b', { bash: true })); }); it('"a((((b" should not match "a(b"', () => { assert(!isMatch('a((((b', 'a(b', { bash: true })); }); it('"a((((b" should not match "a\\(b"', () => { assert(!isMatch('a((((b', 'a\\(b', { bash: true })); }); it('"a((b" should match "a(*b"', () => { assert(isMatch('a((b', 'a(*b', { bash: true })); }); it('"a((b" should not match "a(b"', () => { assert(!isMatch('a((b', 'a(b', { bash: true })); }); it('"a((b" should not match "a\\(b"', () => { assert(!isMatch('a((b', 'a\\(b', { bash: true })); }); it('"a(b" should match "a(*b"', () => { assert(isMatch('a(b', 'a(*b', { bash: true })); }); it('"a(b" should match "a(b"', () => { assert(isMatch('a(b', 'a(b', { bash: true })); }); it('"a\\(b" should match "a\\(b"', () => { assert(isMatch('a\\(b', 'a\\(b', { bash: true })); }); it('"a(b" should match "a\\(b"', () => { assert(isMatch('a(b', 'a\\(b', { bash: true })); }); it('"a." should match "!(*.a|*.b|*.c)"', () => { assert(isMatch('a.', '!(*.a|*.b|*.c)', { bash: true })); }); it('"a." should match "*!(.a|.b|.c)"', () => { assert(isMatch('a.', '*!(.a|.b|.c)', { bash: true })); }); it('"a." should match "*.!(a)"', () => { assert(isMatch('a.', '*.!(a)', { bash: true })); }); it('"a." should match "*.!(a|b|c)"', () => { assert(isMatch('a.', '*.!(a|b|c)', { bash: true })); }); it('"a." should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(!isMatch('a.', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true })); }); it('"a." should not match "*.+(b|d)"', () => { assert(!isMatch('a.', '*.+(b|d)', { bash: true })); }); it('"a.a" should not match "!(*.[a-b]*)"', () => { assert(!isMatch('a.a', '!(*.[a-b]*)', { bash: true })); }); it('"a.a" should not match "!(*.a|*.b|*.c)"', () => { assert(!isMatch('a.a', '!(*.a|*.b|*.c)', { bash: true })); }); it('"a.a" should not match "!(*[a-b].[a-b]*)"', () => { assert(!isMatch('a.a', '!(*[a-b].[a-b]*)', { bash: true })); }); it('"a.a" should not match "!*.(a|b)"', () => { assert(!isMatch('a.a', '!*.(a|b)', { bash: true })); }); it('"a.a" should not match "!*.(a|b)*"', () => { assert(!isMatch('a.a', '!*.(a|b)*', { bash: true })); }); it('"a.a" should match "(a|d).(a|b)*"', () => { assert(isMatch('a.a', '(a|d).(a|b)*', { bash: true })); }); it('"a.a" should match "(b|a).(a)"', () => { assert(isMatch('a.a', '(b|a).(a)', { bash: true })); }); it('"a.a" should match "*!(.a|.b|.c)"', () => { assert(isMatch('a.a', '*!(.a|.b|.c)', { bash: true })); }); it('"a.a" should not match "*.!(a)"', () => { assert(!isMatch('a.a', '*.!(a)', { bash: true })); }); it('"a.a" should not match "*.!(a|b|c)"', () => { assert(!isMatch('a.a', '*.!(a|b|c)', { bash: true })); }); it('"a.a" should match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(isMatch('a.a', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true })); }); it('"a.a" should not match "*.+(b|d)"', () => { assert(!isMatch('a.a', '*.+(b|d)', { bash: true })); }); it('"a.a" should match "@(b|a).@(a)"', () => { assert(isMatch('a.a', '@(b|a).@(a)', { bash: true })); }); it('"a.a.a" should not match "!(*.[a-b]*)"', () => { assert(!isMatch('a.a.a', '!(*.[a-b]*)', { bash: true })); }); it('"a.a.a" should not match "!(*[a-b].[a-b]*)"', () => { assert(!isMatch('a.a.a', '!(*[a-b].[a-b]*)', { bash: true })); }); it('"a.a.a" should not match "!*.(a|b)"', () => { assert(!isMatch('a.a.a', '!*.(a|b)', { bash: true })); }); it('"a.a.a" should not match "!*.(a|b)*"', () => { assert(!isMatch('a.a.a', '!*.(a|b)*', { bash: true })); }); it('"a.a.a" should match "*.!(a)"', () => { assert(isMatch('a.a.a', '*.!(a)', { bash: true })); }); it('"a.a.a" should not match "*.+(b|d)"', () => { assert(!isMatch('a.a.a', '*.+(b|d)', { bash: true })); }); it('"a.aa.a" should not match "(b|a).(a)"', () => { assert(!isMatch('a.aa.a', '(b|a).(a)', { bash: true })); }); it('"a.aa.a" should not match "@(b|a).@(a)"', () => { assert(!isMatch('a.aa.a', '@(b|a).@(a)', { bash: true })); }); it('"a.abcd" should match "!(*.a|*.b|*.c)"', () => { assert(isMatch('a.abcd', '!(*.a|*.b|*.c)', { bash: true })); }); it('"a.abcd" should not match "!(*.a|*.b|*.c)*"', () => { assert(!isMatch('a.abcd', '!(*.a|*.b|*.c)*', { bash: true })); }); it('"a.abcd" should match "*!(*.a|*.b|*.c)*"', () => { assert(isMatch('a.abcd', '*!(*.a|*.b|*.c)*', { bash: true })); }); it('"a.abcd" should match "*!(.a|.b|.c)"', () => { assert(isMatch('a.abcd', '*!(.a|.b|.c)', { bash: true })); }); it('"a.abcd" should match "*.!(a|b|c)"', () => { assert(isMatch('a.abcd', '*.!(a|b|c)', { bash: true })); }); it('"a.abcd" should not match "*.!(a|b|c)*"', () => { assert(!isMatch('a.abcd', '*.!(a|b|c)*', { bash: true })); }); it('"a.abcd" should match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(isMatch('a.abcd', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true })); }); it('"a.b" should not match "!(*.*)"', () => { assert(!isMatch('a.b', '!(*.*)', { bash: true })); }); it('"a.b" should not match "!(*.[a-b]*)"', () => { assert(!isMatch('a.b', '!(*.[a-b]*)', { bash: true })); }); it('"a.b" should not match "!(*.a|*.b|*.c)"', () => { assert(!isMatch('a.b', '!(*.a|*.b|*.c)', { bash: true })); }); it('"a.b" should not match "!(*[a-b].[a-b]*)"', () => { assert(!isMatch('a.b', '!(*[a-b].[a-b]*)', { bash: true })); }); it('"a.b" should not match "!*.(a|b)"', () => { assert(!isMatch('a.b', '!*.(a|b)', { bash: true })); }); it('"a.b" should not match "!*.(a|b)*"', () => { assert(!isMatch('a.b', '!*.(a|b)*', { bash: true })); }); it('"a.b" should match "(a|d).(a|b)*"', () => { assert(isMatch('a.b', '(a|d).(a|b)*', { bash: true })); }); it('"a.b" should match "*!(.a|.b|.c)"', () => { assert(isMatch('a.b', '*!(.a|.b|.c)', { bash: true })); }); it('"a.b" should match "*.!(a)"', () => { assert(isMatch('a.b', '*.!(a)', { bash: true })); }); it('"a.b" should not match "*.!(a|b|c)"', () => { assert(!isMatch('a.b', '*.!(a|b|c)', { bash: true })); }); it('"a.b" should match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(isMatch('a.b', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true })); }); it('"a.b" should match "*.+(b|d)"', () => { assert(isMatch('a.b', '*.+(b|d)', { bash: true })); }); it('"a.bb" should not match "!(*.[a-b]*)"', () => { assert(!isMatch('a.bb', '!(*.[a-b]*)', { bash: true })); }); it('"a.bb" should not match "!(*[a-b].[a-b]*)"', () => { assert(!isMatch('a.bb', '!(*[a-b].[a-b]*)', { bash: true })); }); it('"a.bb" should match "!*.(a|b)"', () => { assert(isMatch('a.bb', '!*.(a|b)', { bash: true })); }); it('"a.bb" should not match "!*.(a|b)*"', () => { assert(!isMatch('a.bb', '!*.(a|b)*', { bash: true })); }); it('"a.bb" should not match "!*.*(a|b)"', () => { assert(!isMatch('a.bb', '!*.*(a|b)', { bash: true })); }); it('"a.bb" should match "(a|d).(a|b)*"', () => { assert(isMatch('a.bb', '(a|d).(a|b)*', { bash: true })); }); it('"a.bb" should not match "(b|a).(a)"', () => { assert(!isMatch('a.bb', '(b|a).(a)', { bash: true })); }); it('"a.bb" should match "*.+(b|d)"', () => { assert(isMatch('a.bb', '*.+(b|d)', { bash: true })); }); it('"a.bb" should not match "@(b|a).@(a)"', () => { assert(!isMatch('a.bb', '@(b|a).@(a)', { bash: true })); }); it('"a.c" should not match "!(*.a|*.b|*.c)"', () => { assert(!isMatch('a.c', '!(*.a|*.b|*.c)', { bash: true })); }); it('"a.c" should match "*!(.a|.b|.c)"', () => { assert(isMatch('a.c', '*!(.a|.b|.c)', { bash: true })); }); it('"a.c" should not match "*.!(a|b|c)"', () => { assert(!isMatch('a.c', '*.!(a|b|c)', { bash: true })); }); it('"a.c" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(!isMatch('a.c', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true })); }); it('"a.c.d" should match "!(*.a|*.b|*.c)"', () => { assert(isMatch('a.c.d', '!(*.a|*.b|*.c)', { bash: true })); }); it('"a.c.d" should match "*!(.a|.b|.c)"', () => { assert(isMatch('a.c.d', '*!(.a|.b|.c)', { bash: true })); }); it('"a.c.d" should match "*.!(a|b|c)"', () => { assert(isMatch('a.c.d', '*.!(a|b|c)', { bash: true })); }); it('"a.c.d" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(!isMatch('a.c.d', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true })); }); it('"a.ccc" should match "!(*.[a-b]*)"', () => { assert(isMatch('a.ccc', '!(*.[a-b]*)', { bash: true })); }); it('"a.ccc" should match "!(*[a-b].[a-b]*)"', () => { assert(isMatch('a.ccc', '!(*[a-b].[a-b]*)', { bash: true })); }); it('"a.ccc" should match "!*.(a|b)"', () => { assert(isMatch('a.ccc', '!*.(a|b)', { bash: true })); }); it('"a.ccc" should match "!*.(a|b)*"', () => { assert(isMatch('a.ccc', '!*.(a|b)*', { bash: true })); }); it('"a.ccc" should not match "*.+(b|d)"', () => { assert(!isMatch('a.ccc', '*.+(b|d)', { bash: true })); }); it('"a.js" should not match "!(*.js)"', () => { assert(!isMatch('a.js', '!(*.js)', { bash: true })); }); it('"a.js" should match "*!(.js)"', () => { assert(isMatch('a.js', '*!(.js)', { bash: true })); }); it('"a.js" should not match "*.!(js)"', () => { assert(!isMatch('a.js', '*.!(js)', { bash: true })); }); it('"a.js" should not match "a.!(js)"', () => { assert(!isMatch('a.js', 'a.!(js)', { bash: true })); }); it('"a.js" should not match "a.!(js)*"', () => { assert(!isMatch('a.js', 'a.!(js)*', { bash: true })); }); it('"a.js.js" should not match "!(*.js)"', () => { assert(!isMatch('a.js.js', '!(*.js)', { bash: true })); }); it('"a.js.js" should match "*!(.js)"', () => { assert(isMatch('a.js.js', '*!(.js)', { bash: true })); }); it('"a.js.js" should match "*.!(js)"', () => { assert(isMatch('a.js.js', '*.!(js)', { bash: true })); }); it('"a.js.js" should match "*.*(js).js"', () => { assert(isMatch('a.js.js', '*.*(js).js', { bash: true })); }); it('"a.md" should match "!(*.js)"', () => { assert(isMatch('a.md', '!(*.js)', { bash: true })); }); it('"a.md" should match "*!(.js)"', () => { assert(isMatch('a.md', '*!(.js)', { bash: true })); }); it('"a.md" should match "*.!(js)"', () => { assert(isMatch('a.md', '*.!(js)', { bash: true })); }); it('"a.md" should match "a.!(js)"', () => { assert(isMatch('a.md', 'a.!(js)', { bash: true })); }); it('"a.md" should match "a.!(js)*"', () => { assert(isMatch('a.md', 'a.!(js)*', { bash: true })); }); it('"a.md.js" should not match "*.*(js).js"', () => { assert(!isMatch('a.md.js', '*.*(js).js', { bash: true })); }); it('"a.txt" should match "a.!(js)"', () => { assert(isMatch('a.txt', 'a.!(js)', { bash: true })); }); it('"a.txt" should match "a.!(js)*"', () => { assert(isMatch('a.txt', 'a.!(js)*', { bash: true })); }); it('"a/!(z)" should match "a/!(z)"', () => { assert(isMatch('a/!(z)', 'a/!(z)', { bash: true })); }); it('"a/b" should match "a/!(z)"', () => { assert(isMatch('a/b', 'a/!(z)', { bash: true })); }); it('"a/b/c.txt" should not match "*/b/!(*).txt"', () => { assert(!isMatch('a/b/c.txt', '*/b/!(*).txt', { bash: true })); }); it('"a/b/c.txt" should not match "*/b/!(c).txt"', () => { assert(!isMatch('a/b/c.txt', '*/b/!(c).txt', { bash: true })); }); it('"a/b/c.txt" should match "*/b/!(cc).txt"', () => { assert(isMatch('a/b/c.txt', '*/b/!(cc).txt', { bash: true })); }); it('"a/b/cc.txt" should not match "*/b/!(*).txt"', () => { assert(!isMatch('a/b/cc.txt', '*/b/!(*).txt', { bash: true })); }); it('"a/b/cc.txt" should not match "*/b/!(c).txt"', () => { assert(!isMatch('a/b/cc.txt', '*/b/!(c).txt', { bash: true })); }); it('"a/b/cc.txt" should not match "*/b/!(cc).txt"', () => { assert(!isMatch('a/b/cc.txt', '*/b/!(cc).txt', { bash: true })); }); it('"a/dir/foo.txt" should match "*/dir/**/!(bar).txt"', () => { assert(isMatch('a/dir/foo.txt', '*/dir/**/!(bar).txt', { bash: true })); }); it('"a/z" should not match "a/!(z)"', () => { assert(!isMatch('a/z', 'a/!(z)', { bash: true })); }); it('"a\\(b" should not match "a(*b"', () => { assert(!isMatch('a\\(b', 'a(*b', { bash: true })); }); it('"a\\(b" should not match "a(b"', () => { assert(!isMatch('a\\(b', 'a(b', { bash: true })); }); it('"a\\z" should match "a\\z"', () => { assert(isMatch('a\\\\z', 'a\\\\z', { bash: true, windows: false })); }); it('"a\\z" should match "a\\z"', () => { assert(isMatch('a\\\\z', 'a\\\\z', { bash: true })); }); it('"a\\b" should match "a/b"', () => { assert(isMatch('a\\b', 'a/b', { windows: true })); }); it('"a\\z" should match "a\\z"', () => { assert(isMatch('a\\\\z', 'a\\\\z', { bash: true })); assert(isMatch('a\\z', 'a\\z', { bash: true })); }); it('"a\\z" should not match "a\\z"', () => { assert(isMatch('a\\z', 'a\\z', { bash: true })); }); it('"aa" should not match "!(a!(b))"', () => { assert(!isMatch('aa', '!(a!(b))', { bash: true })); }); it('"aa" should match "!(a)"', () => { assert(isMatch('aa', '!(a)', { bash: true })); }); it('"aa" should not match "!(a)*"', () => { assert(!isMatch('aa', '!(a)*', { bash: true })); }); it('"aa" should not match "?"', () => { assert(!isMatch('aa', '?', { bash: true })); }); it('"aa" should not match "@(a)b"', () => { assert(!isMatch('aa', '@(a)b', { bash: true })); }); it('"aa" should match "a!(b)*"', () => { assert(isMatch('aa', 'a!(b)*', { bash: true })); }); it('"aa" should not match "a??b"', () => { assert(!isMatch('aa', 'a??b', { bash: true })); }); it('"aa.aa" should not match "(b|a).(a)"', () => { assert(!isMatch('aa.aa', '(b|a).(a)', { bash: true })); }); it('"aa.aa" should not match "@(b|a).@(a)"', () => { assert(!isMatch('aa.aa', '@(b|a).@(a)', { bash: true })); }); it('"aaa" should not match "!(a)*"', () => { assert(!isMatch('aaa', '!(a)*', { bash: true })); }); it('"aaa" should match "a!(b)*"', () => { assert(isMatch('aaa', 'a!(b)*', { bash: true })); }); it('"aaaaaaabababab" should match "*ab"', () => { assert(isMatch('aaaaaaabababab', '*ab', { bash: true })); }); it('"aaac" should match "*(@(a))a@(c)"', () => { assert(isMatch('aaac', '*(@(a))a@(c)', { bash: true })); }); it('"aaaz" should match "[a*(]*z"', () => { assert(isMatch('aaaz', '[a*(]*z', { bash: true })); }); it('"aab" should not match "!(a)*"', () => { assert(!isMatch('aab', '!(a)*', { bash: true })); }); it('"aab" should not match "?"', () => { assert(!isMatch('aab', '?', { bash: true })); }); it('"aab" should not match "??"', () => { assert(!isMatch('aab', '??', { bash: true })); }); it('"aab" should not match "@(c)b"', () => { assert(!isMatch('aab', '@(c)b', { bash: true })); }); it('"aab" should match "a!(b)*"', () => { assert(isMatch('aab', 'a!(b)*', { bash: true })); }); it('"aab" should not match "a??b"', () => { assert(!isMatch('aab', 'a??b', { bash: true })); }); it('"aac" should match "*(@(a))a@(c)"', () => { assert(isMatch('aac', '*(@(a))a@(c)', { bash: true })); }); it('"aac" should not match "*(@(a))b@(c)"', () => { assert(!isMatch('aac', '*(@(a))b@(c)', { bash: true })); }); it('"aax" should not match "a!(a*|b)"', () => { assert(!isMatch('aax', 'a!(a*|b)', { bash: true })); }); it('"aax" should match "a!(x*|b)"', () => { assert(isMatch('aax', 'a!(x*|b)', { bash: true })); }); it('"aax" should match "a?(a*|b)"', () => { assert(isMatch('aax', 'a?(a*|b)', { bash: true })); }); it('"aaz" should match "[a*(]*z"', () => { assert(isMatch('aaz', '[a*(]*z', { bash: true })); }); it('"ab" should match "!(*.*)"', () => { assert(isMatch('ab', '!(*.*)', { bash: true })); }); it('"ab" should match "!(a!(b))"', () => { assert(isMatch('ab', '!(a!(b))', { bash: true })); }); it('"ab" should not match "!(a)*"', () => { assert(!isMatch('ab', '!(a)*', { bash: true })); }); it('"ab" should match "@(a+|b)*"', () => { assert(isMatch('ab', '@(a+|b)*', { bash: true })); }); it('"ab" should match "(a+|b)+"', () => { assert(isMatch('ab', '(a+|b)+', { bash: true })); }); it('"ab" should not match "*?(a)bc"', () => { assert(!isMatch('ab', '*?(a)bc', { bash: true })); }); it('"ab" should not match "a!(*(b|B))"', () => { assert(!isMatch('ab', 'a!(*(b|B))', { bash: true })); }); it('"ab" should not match "a!(@(b|B))"', () => { assert(!isMatch('ab', 'a!(@(b|B))', { bash: true })); }); it('"aB" should not match "a!(@(b|B))"', () => { assert(!isMatch('aB', 'a!(@(b|B))', { bash: true })); }); it('"ab" should not match "a!(b)*"', () => { assert(!isMatch('ab', 'a!(b)*', { bash: true })); }); it('"ab" should not match "a(*b"', () => { assert(!isMatch('ab', 'a(*b', { bash: true })); }); it('"ab" should not match "a(b"', () => { assert(!isMatch('ab', 'a(b', { bash: true })); }); it('"ab" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('ab', 'a(b*(foo|bar))d', { bash: true })); }); it('"ab" should not match "a/b"', () => { assert(!isMatch('ab', 'a/b', { windows: true })); }); it('"ab" should not match "a\\(b"', () => { assert(!isMatch('ab', 'a\\(b', { bash: true })); }); it('"ab" should match "ab*(e|f)"', () => { assert(isMatch('ab', 'ab*(e|f)', { bash: true })); }); it('"ab" should match "ab**"', () => { assert(isMatch('ab', 'ab**', { bash: true })); }); it('"ab" should match "ab**(e|f)"', () => { assert(isMatch('ab', 'ab**(e|f)', { bash: true })); }); it('"ab" should not match "ab**(e|f)g"', () => { assert(!isMatch('ab', 'ab**(e|f)g', { bash: true })); }); it('"ab" should not match "ab***ef"', () => { assert(!isMatch('ab', 'ab***ef', { bash: true })); }); it('"ab" should not match "ab*+(e|f)"', () => { assert(!isMatch('ab', 'ab*+(e|f)', { bash: true })); }); it('"ab" should not match "ab*d+(e|f)"', () => { assert(!isMatch('ab', 'ab*d+(e|f)', { bash: true })); }); it('"ab" should not match "ab?*(e|f)"', () => { assert(!isMatch('ab', 'ab?*(e|f)', { bash: true })); }); it('"ab/cXd/efXg/hi" should match "**/*X*/**/*i"', () => { assert(isMatch('ab/cXd/efXg/hi', '**/*X*/**/*i', { bash: true })); }); it('"ab/cXd/efXg/hi" should match "*/*X*/*/*i"', () => { assert(isMatch('ab/cXd/efXg/hi', '*/*X*/*/*i', { bash: true })); }); it('"ab/cXd/efXg/hi" should match "*X*i"', () => { assert(isMatch('ab/cXd/efXg/hi', '*X*i', { bash: true })); }); it('"ab/cXd/efXg/hi" should match "*Xg*i"', () => { assert(isMatch('ab/cXd/efXg/hi', '*Xg*i', { bash: true })); }); it('"ab]" should match "a!(@(b|B))"', () => { assert(isMatch('ab]', 'a!(@(b|B))', { bash: true })); }); it('"abab" should match "(a+|b)*"', () => { assert(isMatch('abab', '(a+|b)*', { bash: true })); }); it('"abab" should match "(a+|b)+"', () => { assert(isMatch('abab', '(a+|b)+', { bash: true })); }); it('"abab" should not match "*?(a)bc"', () => { assert(!isMatch('abab', '*?(a)bc', { bash: true })); }); it('"abab" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('abab', 'a(b*(foo|bar))d', { bash: true })); }); it('"abab" should not match "ab*(e|f)"', () => { assert(!isMatch('abab', 'ab*(e|f)', { bash: true })); }); it('"abab" should match "ab**"', () => { assert(isMatch('abab', 'ab**', { bash: true })); }); it('"abab" should match "ab**(e|f)"', () => { assert(isMatch('abab', 'ab**(e|f)', { bash: true })); }); it('"abab" should not match "ab**(e|f)g"', () => { assert(!isMatch('abab', 'ab**(e|f)g', { bash: true })); }); it('"abab" should not match "ab***ef"', () => { assert(!isMatch('abab', 'ab***ef', { bash: true })); }); it('"abab" should not match "ab*+(e|f)"', () => { assert(!isMatch('abab', 'ab*+(e|f)', { bash: true })); }); it('"abab" should not match "ab*d+(e|f)"', () => { assert(!isMatch('abab', 'ab*d+(e|f)', { bash: true })); }); it('"abab" should not match "ab?*(e|f)"', () => { assert(!isMatch('abab', 'ab?*(e|f)', { bash: true })); }); it('"abb" should match "!(*.*)"', () => { assert(isMatch('abb', '!(*.*)', { bash: true })); }); it('"abb" should not match "!(a)*"', () => { assert(!isMatch('abb', '!(a)*', { bash: true })); }); it('"abb" should not match "a!(b)*"', () => { assert(!isMatch('abb', 'a!(b)*', { bash: true })); }); it('"abbcd" should match "@(ab|a*(b))*(c)d"', () => { assert(isMatch('abbcd', '@(ab|a*(b))*(c)d', { bash: true })); }); it('"abc" should not match "\\a\\b\\c"', () => { assert(!isMatch('abc', '\\a\\b\\c', { bash: true })); }); it('"aBc" should match "a!(@(b|B))"', () => { assert(isMatch('aBc', 'a!(@(b|B))', { bash: true })); }); it('"abcd" should match "?@(a|b)*@(c)d"', () => { assert(isMatch('abcd', '?@(a|b)*@(c)d', { bash: true })); }); it('"abcd" should match "@(ab|a*@(b))*(c)d"', () => { assert(isMatch('abcd', '@(ab|a*@(b))*(c)d', { bash: true })); }); it('"abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt" should match "**/*a*b*g*n*t"', () => { assert(isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt', '**/*a*b*g*n*t', { bash: true })); }); it('"abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz" should not match "**/*a*b*g*n*t"', () => { assert(!isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz', '**/*a*b*g*n*t', { bash: true })); }); it('"abcdef" should match "(a+|b)*"', () => { assert(isMatch('abcdef', '(a+|b)*', { bash: true })); }); it('"abcdef" should not match "(a+|b)+"', () => { assert(!isMatch('abcdef', '(a+|b)+', { bash: true })); }); it('"abcdef" should not match "*?(a)bc"', () => { assert(!isMatch('abcdef', '*?(a)bc', { bash: true })); }); it('"abcdef" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('abcdef', 'a(b*(foo|bar))d', { bash: true })); }); it('"abcdef" should not match "ab*(e|f)"', () => { assert(!isMatch('abcdef', 'ab*(e|f)', { bash: true })); }); it('"abcdef" should match "ab**"', () => { assert(isMatch('abcdef', 'ab**', { bash: true })); }); it('"abcdef" should match "ab**(e|f)"', () => { assert(isMatch('abcdef', 'ab**(e|f)', { bash: true })); }); it('"abcdef" should not match "ab**(e|f)g"', () => { assert(!isMatch('abcdef', 'ab**(e|f)g', { bash: true })); }); it('"abcdef" should match "ab***ef"', () => { assert(isMatch('abcdef', 'ab***ef', { bash: true })); }); it('"abcdef" should match "ab*+(e|f)"', () => { assert(isMatch('abcdef', 'ab*+(e|f)', { bash: true })); }); it('"abcdef" should match "ab*d+(e|f)"', () => { assert(isMatch('abcdef', 'ab*d+(e|f)', { bash: true })); }); it('"abcdef" should not match "ab?*(e|f)"', () => { assert(!isMatch('abcdef', 'ab?*(e|f)', { bash: true })); }); it('"abcfef" should match "(a+|b)*"', () => { assert(isMatch('abcfef', '(a+|b)*', { bash: true })); }); it('"abcfef" should not match "(a+|b)+"', () => { assert(!isMatch('abcfef', '(a+|b)+', { bash: true })); }); it('"abcfef" should not match "*?(a)bc"', () => { assert(!isMatch('abcfef', '*?(a)bc', { bash: true })); }); it('"abcfef" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('abcfef', 'a(b*(foo|bar))d', { bash: true })); }); it('"abcfef" should not match "ab*(e|f)"', () => { assert(!isMatch('abcfef', 'ab*(e|f)', { bash: true })); }); it('"abcfef" should match "ab**"', () => { assert(isMatch('abcfef', 'ab**', { bash: true })); }); it('"abcfef" should match "ab**(e|f)"', () => { assert(isMatch('abcfef', 'ab**(e|f)', { bash: true })); }); it('"abcfef" should not match "ab**(e|f)g"', () => { assert(!isMatch('abcfef', 'ab**(e|f)g', { bash: true })); }); it('"abcfef" should match "ab***ef"', () => { assert(isMatch('abcfef', 'ab***ef', { bash: true })); }); it('"abcfef" should match "ab*+(e|f)"', () => { assert(isMatch('abcfef', 'ab*+(e|f)', { bash: true })); }); it('"abcfef" should not match "ab*d+(e|f)"', () => { assert(!isMatch('abcfef', 'ab*d+(e|f)', { bash: true })); }); it('"abcfef" should match "ab?*(e|f)"', () => { assert(isMatch('abcfef', 'ab?*(e|f)', { bash: true })); }); it('"abcfefg" should match "(a+|b)*"', () => { assert(isMatch('abcfefg', '(a+|b)*', { bash: true })); }); it('"abcfefg" should not match "(a+|b)+"', () => { assert(!isMatch('abcfefg', '(a+|b)+', { bash: true })); }); it('"abcfefg" should not match "*?(a)bc"', () => { assert(!isMatch('abcfefg', '*?(a)bc', { bash: true })); }); it('"abcfefg" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('abcfefg', 'a(b*(foo|bar))d', { bash: true })); }); it('"abcfefg" should not match "ab*(e|f)"', () => { assert(!isMatch('abcfefg', 'ab*(e|f)', { bash: true })); }); it('"abcfefg" should match "ab**"', () => { assert(isMatch('abcfefg', 'ab**', { bash: true })); }); it('"abcfefg" should match "ab**(e|f)"', () => { assert(isMatch('abcfefg', 'ab**(e|f)', { bash: true })); }); it('"abcfefg" should match "ab**(e|f)g"', () => { assert(isMatch('abcfefg', 'ab**(e|f)g', { bash: true })); }); it('"abcfefg" should not match "ab***ef"', () => { assert(!isMatch('abcfefg', 'ab***ef', { bash: true })); }); it('"abcfefg" should not match "ab*+(e|f)"', () => { assert(!isMatch('abcfefg', 'ab*+(e|f)', { bash: true })); }); it('"abcfefg" should not match "ab*d+(e|f)"', () => { assert(!isMatch('abcfefg', 'ab*d+(e|f)', { bash: true })); }); it('"abcfefg" should not match "ab?*(e|f)"', () => { assert(!isMatch('abcfefg', 'ab?*(e|f)', { bash: true })); }); it('"abcx" should match "!([[*])*"', () => { assert(isMatch('abcx', '!([[*])*', { bash: true })); }); it('"abcx" should match "+(a|b\\[)*"', () => { assert(isMatch('abcx', '+(a|b\\[)*', { bash: true })); }); it('"abcx" should not match "[a*(]*z"', () => { assert(!isMatch('abcx', '[a*(]*z', { bash: true })); }); it('"abcXdefXghi" should match "*X*i"', () => { assert(isMatch('abcXdefXghi', '*X*i', { bash: true })); }); it('"abcz" should match "!([[*])*"', () => { assert(isMatch('abcz', '!([[*])*', { bash: true })); }); it('"abcz" should match "+(a|b\\[)*"', () => { assert(isMatch('abcz', '+(a|b\\[)*', { bash: true })); }); it('"abcz" should match "[a*(]*z"', () => { assert(isMatch('abcz', '[a*(]*z', { bash: true })); }); it('"abd" should match "(a+|b)*"', () => { assert(isMatch('abd', '(a+|b)*', { bash: true })); }); it('"abd" should not match "(a+|b)+"', () => { assert(!isMatch('abd', '(a+|b)+', { bash: true })); }); it('"abd" should not match "*?(a)bc"', () => { assert(!isMatch('abd', '*?(a)bc', { bash: true })); }); it('"abd" should match "a!(*(b|B))"', () => { assert(isMatch('abd', 'a!(*(b|B))', { bash: true })); }); it('"abd" should match "a!(@(b|B))"', () => { assert(isMatch('abd', 'a!(@(b|B))', { bash: true })); }); it('"abd" should not match "a!(@(b|B))d"', () => { assert(!isMatch('abd', 'a!(@(b|B))d', { bash: true })); }); it('"abd" should match "a(b*(foo|bar))d"', () => { assert(isMatch('abd', 'a(b*(foo|bar))d', { bash: true })); }); it('"abd" should match "a+(b|c)d"', () => { assert(isMatch('abd', 'a+(b|c)d', { bash: true })); }); it('"abd" should match "a[b*(foo|bar)]d"', () => { assert(isMatch('abd', 'a[b*(foo|bar)]d', { bash: true })); }); it('"abd" should not match "ab*(e|f)"', () => { assert(!isMatch('abd', 'ab*(e|f)', { bash: true })); }); it('"abd" should match "ab**"', () => { assert(isMatch('abd', 'ab**', { bash: true })); }); it('"abd" should match "ab**(e|f)"', () => { assert(isMatch('abd', 'ab**(e|f)', { bash: true })); }); it('"abd" should not match "ab**(e|f)g"', () => { assert(!isMatch('abd', 'ab**(e|f)g', { bash: true })); }); it('"abd" should not match "ab***ef"', () => { assert(!isMatch('abd', 'ab***ef', { bash: true })); }); it('"abd" should not match "ab*+(e|f)"', () => { assert(!isMatch('abd', 'ab*+(e|f)', { bash: true })); }); it('"abd" should not match "ab*d+(e|f)"', () => { assert(!isMatch('abd', 'ab*d+(e|f)', { bash: true })); }); it('"abd" should match "ab?*(e|f)"', () => { assert(isMatch('abd', 'ab?*(e|f)', { bash: true })); }); it('"abef" should match "(a+|b)*"', () => { assert(isMatch('abef', '(a+|b)*', { bash: true })); }); it('"abef" should not match "(a+|b)+"', () => { assert(!isMatch('abef', '(a+|b)+', { bash: true })); }); it('"abef" should not match "*(a+|b)"', () => { assert(!isMatch('abef', '*(a+|b)', { bash: true })); }); it('"abef" should not match "*?(a)bc"', () => { assert(!isMatch('abef', '*?(a)bc', { bash: true })); }); it('"abef" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('abef', 'a(b*(foo|bar))d', { bash: true })); }); it('"abef" should match "ab*(e|f)"', () => { assert(isMatch('abef', 'ab*(e|f)', { bash: true })); }); it('"abef" should match "ab**"', () => { assert(isMatch('abef', 'ab**', { bash: true })); }); it('"abef" should match "ab**(e|f)"', () => { assert(isMatch('abef', 'ab**(e|f)', { bash: true })); }); it('"abef" should not match "ab**(e|f)g"', () => { assert(!isMatch('abef', 'ab**(e|f)g', { bash: true })); }); it('"abef" should match "ab***ef"', () => { assert(isMatch('abef', 'ab***ef', { bash: true })); }); it('"abef" should match "ab*+(e|f)"', () => { assert(isMatch('abef', 'ab*+(e|f)', { bash: true })); }); it('"abef" should not match "ab*d+(e|f)"', () => { assert(!isMatch('abef', 'ab*d+(e|f)', { bash: true })); }); it('"abef" should match "ab?*(e|f)"', () => { assert(isMatch('abef', 'ab?*(e|f)', { bash: true })); }); it('"abz" should not match "a!(*)"', () => { assert(!isMatch('abz', 'a!(*)', { bash: true })); }); it('"abz" should match "a!(z)"', () => { assert(isMatch('abz', 'a!(z)', { bash: true })); }); it('"abz" should match "a*!(z)"', () => { assert(isMatch('abz', 'a*!(z)', { bash: true })); }); it('"abz" should not match "a*(z)"', () => { assert(!isMatch('abz', 'a*(z)', { bash: true })); }); it('"abz" should match "a**(z)"', () => { assert(isMatch('abz', 'a**(z)', { bash: true })); }); it('"abz" should match "a*@(z)"', () => { assert(isMatch('abz', 'a*@(z)', { bash: true })); }); it('"abz" should not match "a+(z)"', () => { assert(!isMatch('abz', 'a+(z)', { bash: true })); }); it('"abz" should not match "a?(z)"', () => { assert(!isMatch('abz', 'a?(z)', { bash: true })); }); it('"abz" should not match "a@(z)"', () => { assert(!isMatch('abz', 'a@(z)', { bash: true })); }); it('"ac" should not match "!(a)*"', () => { assert(!isMatch('ac', '!(a)*', { bash: true })); }); it('"ac" should match "*(@(a))a@(c)"', () => { assert(isMatch('ac', '*(@(a))a@(c)', { bash: true })); }); it('"ac" should match "a!(*(b|B))"', () => { assert(isMatch('ac', 'a!(*(b|B))', { bash: true })); }); it('"ac" should match "a!(@(b|B))"', () => { assert(isMatch('ac', 'a!(@(b|B))', { bash: true })); }); it('"ac" should match "a!(b)*"', () => { assert(isMatch('ac', 'a!(b)*', { bash: true })); }); it('"accdef" should match "(a+|b)*"', () => { assert(isMatch('accdef', '(a+|b)*', { bash: true })); }); it('"accdef" should not match "(a+|b)+"', () => { assert(!isMatch('accdef', '(a+|b)+', { bash: true })); }); it('"accdef" should not match "*?(a)bc"', () => { assert(!isMatch('accdef', '*?(a)bc', { bash: true })); }); it('"accdef" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('accdef', 'a(b*(foo|bar))d', { bash: true })); }); it('"accdef" should not match "ab*(e|f)"', () => { assert(!isMatch('accdef', 'ab*(e|f)', { bash: true })); }); it('"accdef" should not match "ab**"', () => { assert(!isMatch('accdef', 'ab**', { bash: true })); }); it('"accdef" should not match "ab**(e|f)"', () => { assert(!isMatch('accdef', 'ab**(e|f)', { bash: true })); }); it('"accdef" should not match "ab**(e|f)g"', () => { assert(!isMatch('accdef', 'ab**(e|f)g', { bash: true })); }); it('"accdef" should not match "ab***ef"', () => { assert(!isMatch('accdef', 'ab***ef', { bash: true })); }); it('"accdef" should not match "ab*+(e|f)"', () => { assert(!isMatch('accdef', 'ab*+(e|f)', { bash: true })); }); it('"accdef" should not match "ab*d+(e|f)"', () => { assert(!isMatch('accdef', 'ab*d+(e|f)', { bash: true })); }); it('"accdef" should not match "ab?*(e|f)"', () => { assert(!isMatch('accdef', 'ab?*(e|f)', { bash: true })); }); it('"acd" should match "(a+|b)*"', () => { assert(isMatch('acd', '(a+|b)*', { bash: true })); }); it('"acd" should not match "(a+|b)+"', () => { assert(!isMatch('acd', '(a+|b)+', { bash: true })); }); it('"acd" should not match "*?(a)bc"', () => { assert(!isMatch('acd', '*?(a)bc', { bash: true })); }); it('"acd" should match "@(ab|a*(b))*(c)d"', () => { assert(isMatch('acd', '@(ab|a*(b))*(c)d', { bash: true })); }); it('"acd" should match "a!(*(b|B))"', () => { assert(isMatch('acd', 'a!(*(b|B))', { bash: true })); }); it('"acd" should match "a!(@(b|B))"', () => { assert(isMatch('acd', 'a!(@(b|B))', { bash: true })); }); it('"acd" should match "a!(@(b|B))d"', () => { assert(isMatch('acd', 'a!(@(b|B))d', { bash: true })); }); it('"acd" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('acd', 'a(b*(foo|bar))d', { bash: true })); }); it('"acd" should match "a+(b|c)d"', () => { assert(isMatch('acd', 'a+(b|c)d', { bash: true })); }); it('"acd" should not match "a[b*(foo|bar)]d"', () => { assert(!isMatch('acd', 'a[b*(foo|bar)]d', { bash: true })); }); it('"acd" should not match "ab*(e|f)"', () => { assert(!isMatch('acd', 'ab*(e|f)', { bash: true })); }); it('"acd" should not match "ab**"', () => { assert(!isMatch('acd', 'ab**', { bash: true })); }); it('"acd" should not match "ab**(e|f)"', () => { assert(!isMatch('acd', 'ab**(e|f)', { bash: true })); }); it('"acd" should not match "ab**(e|f)g"', () => { assert(!isMatch('acd', 'ab**(e|f)g', { bash: true })); }); it('"acd" should not match "ab***ef"', () => { assert(!isMatch('acd', 'ab***ef', { bash: true })); }); it('"acd" should not match "ab*+(e|f)"', () => { assert(!isMatch('acd', 'ab*+(e|f)', { bash: true })); }); it('"acd" should not match "ab*d+(e|f)"', () => { assert(!isMatch('acd', 'ab*d+(e|f)', { bash: true })); }); it('"acd" should not match "ab?*(e|f)"', () => { assert(!isMatch('acd', 'ab?*(e|f)', { bash: true })); }); it('"ax" should match "?(a*|b)"', () => { assert(isMatch('ax', '?(a*|b)', { bash: true })); }); it('"ax" should not match "a?(b*)"', () => { assert(!isMatch('ax', 'a?(b*)', { bash: true })); }); it('"axz" should not match "a+(z)"', () => { assert(!isMatch('axz', 'a+(z)', { bash: true })); }); it('"az" should not match "a!(*)"', () => { assert(!isMatch('az', 'a!(*)', { bash: true })); }); it('"az" should not match "a!(z)"', () => { assert(!isMatch('az', 'a!(z)', { bash: true })); }); it('"az" should match "a*!(z)"', () => { assert(isMatch('az', 'a*!(z)', { bash: true })); }); it('"az" should match "a*(z)"', () => { assert(isMatch('az', 'a*(z)', { bash: true })); }); it('"az" should match "a**(z)"', () => { assert(isMatch('az', 'a**(z)', { bash: true })); }); it('"az" should match "a*@(z)"', () => { assert(isMatch('az', 'a*@(z)', { bash: true })); }); it('"az" should match "a+(z)"', () => { assert(isMatch('az', 'a+(z)', { bash: true })); }); it('"az" should match "a?(z)"', () => { assert(isMatch('az', 'a?(z)', { bash: true })); }); it('"az" should match "a@(z)"', () => { assert(isMatch('az', 'a@(z)', { bash: true })); }); it('"az" should not match "a\\z"', () => { assert(!isMatch('az', 'a\\\\z', { bash: true, windows: false })); }); it('"az" should not match "a\\z"', () => { assert(!isMatch('az', 'a\\\\z', { bash: true })); }); it('"b" should match "!(a)*"', () => { assert(isMatch('b', '!(a)*', { bash: true })); }); it('"b" should match "(a+|b)*"', () => { assert(isMatch('b', '(a+|b)*', { bash: true })); }); it('"b" should not match "a!(b)*"', () => { assert(!isMatch('b', 'a!(b)*', { bash: true })); }); it('"b.a" should match "(b|a).(a)"', () => { assert(isMatch('b.a', '(b|a).(a)', { bash: true })); }); it('"b.a" should match "@(b|a).@(a)"', () => { assert(isMatch('b.a', '@(b|a).@(a)', { bash: true })); }); it('"b/a" should not match "!(b/a)"', () => { assert(!isMatch('b/a', '!(b/a)', { bash: true })); }); it('"b/b" should match "!(b/a)"', () => { assert(isMatch('b/b', '!(b/a)', { bash: true })); }); it('"b/c" should match "!(b/a)"', () => { assert(isMatch('b/c', '!(b/a)', { bash: true })); }); it('"b/c" should not match "b/!(c)"', () => { assert(!isMatch('b/c', 'b/!(c)', { bash: true })); }); it('"b/c" should match "b/!(cc)"', () => { assert(isMatch('b/c', 'b/!(cc)', { bash: true })); }); it('"b/c.txt" should not match "b/!(c).txt"', () => { assert(!isMatch('b/c.txt', 'b/!(c).txt', { bash: true })); }); it('"b/c.txt" should match "b/!(cc).txt"', () => { assert(isMatch('b/c.txt', 'b/!(cc).txt', { bash: true })); }); it('"b/cc" should match "b/!(c)"', () => { assert(isMatch('b/cc', 'b/!(c)', { bash: true })); }); it('"b/cc" should not match "b/!(cc)"', () => { assert(!isMatch('b/cc', 'b/!(cc)', { bash: true })); }); it('"b/cc.txt" should not match "b/!(c).txt"', () => { assert(!isMatch('b/cc.txt', 'b/!(c).txt', { bash: true })); }); it('"b/cc.txt" should not match "b/!(cc).txt"', () => { assert(!isMatch('b/cc.txt', 'b/!(cc).txt', { bash: true })); }); it('"b/ccc" should match "b/!(c)"', () => { assert(isMatch('b/ccc', 'b/!(c)', { bash: true })); }); it('"ba" should match "!(a!(b))"', () => { assert(isMatch('ba', '!(a!(b))', { bash: true })); }); it('"ba" should match "b?(a|b)"', () => { assert(isMatch('ba', 'b?(a|b)', { bash: true })); }); it('"baaac" should not match "*(@(a))a@(c)"', () => { assert(!isMatch('baaac', '*(@(a))a@(c)', { bash: true })); }); it('"bar" should match "!(foo)"', () => { assert(isMatch('bar', '!(foo)', { bash: true })); }); it('"bar" should match "!(foo)*"', () => { assert(isMatch('bar', '!(foo)*', { bash: true })); }); it('"bar" should match "!(foo)b*"', () => { assert(isMatch('bar', '!(foo)b*', { bash: true })); }); it('"bar" should match "*(!(foo))"', () => { assert(isMatch('bar', '*(!(foo))', { bash: true })); }); it('"baz" should match "!(foo)*"', () => { assert(isMatch('baz', '!(foo)*', { bash: true })); }); it('"baz" should match "!(foo)b*"', () => { assert(isMatch('baz', '!(foo)b*', { bash: true })); }); it('"baz" should match "*(!(foo))"', () => { assert(isMatch('baz', '*(!(foo))', { bash: true })); }); it('"bb" should match "!(a!(b))"', () => { assert(isMatch('bb', '!(a!(b))', { bash: true })); }); it('"bb" should match "!(a)*"', () => { assert(isMatch('bb', '!(a)*', { bash: true })); }); it('"bb" should not match "a!(b)*"', () => { assert(!isMatch('bb', 'a!(b)*', { bash: true })); }); it('"bb" should not match "a?(a|b)"', () => { assert(!isMatch('bb', 'a?(a|b)', { bash: true })); }); it('"bbc" should match "!([[*])*"', () => { assert(isMatch('bbc', '!([[*])*', { bash: true })); }); it('"bbc" should not match "+(a|b\\[)*"', () => { assert(!isMatch('bbc', '+(a|b\\[)*', { bash: true })); }); it('"bbc" should not match "[a*(]*z"', () => { assert(!isMatch('bbc', '[a*(]*z', { bash: true })); }); it('"bz" should not match "a+(z)"', () => { assert(!isMatch('bz', 'a+(z)', { bash: true })); }); it('"c" should not match "*(@(a))a@(c)"', () => { assert(!isMatch('c', '*(@(a))a@(c)', { bash: true })); }); it('"c.a" should not match "!(*.[a-b]*)"', () => { assert(!isMatch('c.a', '!(*.[a-b]*)', { bash: true })); }); it('"c.a" should match "!(*[a-b].[a-b]*)"', () => { assert(isMatch('c.a', '!(*[a-b].[a-b]*)', { bash: true })); }); it('"c.a" should not match "!*.(a|b)"', () => { assert(!isMatch('c.a', '!*.(a|b)', { bash: true })); }); it('"c.a" should not match "!*.(a|b)*"', () => { assert(!isMatch('c.a', '!*.(a|b)*', { bash: true })); }); it('"c.a" should not match "(b|a).(a)"', () => { assert(!isMatch('c.a', '(b|a).(a)', { bash: true })); }); it('"c.a" should not match "*.!(a)"', () => { assert(!isMatch('c.a', '*.!(a)', { bash: true })); }); it('"c.a" should not match "*.+(b|d)"', () => { assert(!isMatch('c.a', '*.+(b|d)', { bash: true })); }); it('"c.a" should not match "@(b|a).@(a)"', () => { assert(!isMatch('c.a', '@(b|a).@(a)', { bash: true })); }); it('"c.c" should not match "!(*.a|*.b|*.c)"', () => { assert(!isMatch('c.c', '!(*.a|*.b|*.c)', { bash: true })); }); it('"c.c" should match "*!(.a|.b|.c)"', () => { assert(isMatch('c.c', '*!(.a|.b|.c)', { bash: true })); }); it('"c.c" should not match "*.!(a|b|c)"', () => { assert(!isMatch('c.c', '*.!(a|b|c)', { bash: true })); }); it('"c.c" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(!isMatch('c.c', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true })); }); it('"c.ccc" should match "!(*.[a-b]*)"', () => { assert(isMatch('c.ccc', '!(*.[a-b]*)', { bash: true })); }); it('"c.ccc" should match "!(*[a-b].[a-b]*)"', () => { assert(isMatch('c.ccc', '!(*[a-b].[a-b]*)', { bash: true })); }); it('"c.js" should not match "!(*.js)"', () => { assert(!isMatch('c.js', '!(*.js)', { bash: true })); }); it('"c.js" should match "*!(.js)"', () => { assert(isMatch('c.js', '*!(.js)', { bash: true })); }); it('"c.js" should not match "*.!(js)"', () => { assert(!isMatch('c.js', '*.!(js)', { bash: true })); }); it('"c/a/v" should match "c/!(z)/v"', () => { assert(isMatch('c/a/v', 'c/!(z)/v', { bash: true })); }); it('"c/a/v" should not match "c/*(z)/v"', () => { assert(!isMatch('c/a/v', 'c/*(z)/v', { bash: true })); }); it('"c/a/v" should not match "c/+(z)/v"', () => { assert(!isMatch('c/a/v', 'c/+(z)/v', { bash: true })); }); it('"c/a/v" should not match "c/@(z)/v"', () => { assert(!isMatch('c/a/v', 'c/@(z)/v', { bash: true })); }); it('"c/z/v" should not match "*(z)"', () => { assert(!isMatch('c/z/v', '*(z)', { bash: true })); }); it('"c/z/v" should not match "+(z)"', () => { assert(!isMatch('c/z/v', '+(z)', { bash: true })); }); it('"c/z/v" should not match "?(z)"', () => { assert(!isMatch('c/z/v', '?(z)', { bash: true })); }); it('"c/z/v" should not match "c/!(z)/v"', () => { assert(!isMatch('c/z/v', 'c/!(z)/v', { bash: true })); }); it('"c/z/v" should match "c/*(z)/v"', () => { assert(isMatch('c/z/v', 'c/*(z)/v', { bash: true })); }); it('"c/z/v" should match "c/+(z)/v"', () => { assert(isMatch('c/z/v', 'c/+(z)/v', { bash: true })); }); it('"c/z/v" should match "c/@(z)/v"', () => { assert(isMatch('c/z/v', 'c/@(z)/v', { bash: true })); }); it('"c/z/v" should match "c/z/v"', () => { assert(isMatch('c/z/v', 'c/z/v', { bash: true })); }); it('"cc.a" should not match "(b|a).(a)"', () => { assert(!isMatch('cc.a', '(b|a).(a)', { bash: true })); }); it('"cc.a" should not match "@(b|a).@(a)"', () => { assert(!isMatch('cc.a', '@(b|a).@(a)', { bash: true })); }); it('"ccc" should match "!(a)*"', () => { assert(isMatch('ccc', '!(a)*', { bash: true })); }); it('"ccc" should not match "a!(b)*"', () => { assert(!isMatch('ccc', 'a!(b)*', { bash: true })); }); it('"cow" should match "!(*.*)"', () => { assert(isMatch('cow', '!(*.*)', { bash: true })); }); it('"cow" should not match "!(*.*)."', () => { assert(!isMatch('cow', '!(*.*).', { bash: true })); }); it('"cow" should not match ".!(*.*)"', () => { assert(!isMatch('cow', '.!(*.*)', { bash: true })); }); it('"cz" should not match "a!(*)"', () => { assert(!isMatch('cz', 'a!(*)', { bash: true })); }); it('"cz" should not match "a!(z)"', () => { assert(!isMatch('cz', 'a!(z)', { bash: true })); }); it('"cz" should not match "a*!(z)"', () => { assert(!isMatch('cz', 'a*!(z)', { bash: true })); }); it('"cz" should not match "a*(z)"', () => { assert(!isMatch('cz', 'a*(z)', { bash: true })); }); it('"cz" should not match "a**(z)"', () => { assert(!isMatch('cz', 'a**(z)', { bash: true })); }); it('"cz" should not match "a*@(z)"', () => { assert(!isMatch('cz', 'a*@(z)', { bash: true })); }); it('"cz" should not match "a+(z)"', () => { assert(!isMatch('cz', 'a+(z)', { bash: true })); }); it('"cz" should not match "a?(z)"', () => { assert(!isMatch('cz', 'a?(z)', { bash: true })); }); it('"cz" should not match "a@(z)"', () => { assert(!isMatch('cz', 'a@(z)', { bash: true })); }); it('"d.a.d" should not match "!(*.[a-b]*)"', () => { assert(!isMatch('d.a.d', '!(*.[a-b]*)', { bash: true })); }); it('"d.a.d" should match "!(*[a-b].[a-b]*)"', () => { assert(isMatch('d.a.d', '!(*[a-b].[a-b]*)', { bash: true })); }); it('"d.a.d" should not match "!*.(a|b)*"', () => { assert(!isMatch('d.a.d', '!*.(a|b)*', { bash: true })); }); it('"d.a.d" should match "!*.*(a|b)"', () => { assert(isMatch('d.a.d', '!*.*(a|b)', { bash: true })); }); it('"d.a.d" should not match "!*.{a,b}*"', () => { assert(!isMatch('d.a.d', '!*.{a,b}*', { bash: true })); }); it('"d.a.d" should match "*.!(a)"', () => { assert(isMatch('d.a.d', '*.!(a)', { bash: true })); }); it('"d.a.d" should match "*.+(b|d)"', () => { assert(isMatch('d.a.d', '*.+(b|d)', { bash: true })); }); it('"d.d" should match "!(*.a|*.b|*.c)"', () => { assert(isMatch('d.d', '!(*.a|*.b|*.c)', { bash: true })); }); it('"d.d" should match "*!(.a|.b|.c)"', () => { assert(isMatch('d.d', '*!(.a|.b|.c)', { bash: true })); }); it('"d.d" should match "*.!(a|b|c)"', () => { assert(isMatch('d.d', '*.!(a|b|c)', { bash: true })); }); it('"d.d" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(!isMatch('d.d', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true })); }); it('"d.js.d" should match "!(*.js)"', () => { assert(isMatch('d.js.d', '!(*.js)', { bash: true })); }); it('"d.js.d" should match "*!(.js)"', () => { assert(isMatch('d.js.d', '*!(.js)', { bash: true })); }); it('"d.js.d" should match "*.!(js)"', () => { assert(isMatch('d.js.d', '*.!(js)', { bash: true })); }); it('"dd.aa.d" should not match "(b|a).(a)"', () => { assert(!isMatch('dd.aa.d', '(b|a).(a)', { bash: true })); }); it('"dd.aa.d" should not match "@(b|a).@(a)"', () => { assert(!isMatch('dd.aa.d', '@(b|a).@(a)', { bash: true })); }); it('"def" should not match "()ef"', () => { assert(!isMatch('def', '()ef', { bash: true })); }); it('"e.e" should match "!(*.a|*.b|*.c)"', () => { assert(isMatch('e.e', '!(*.a|*.b|*.c)', { bash: true })); }); it('"e.e" should match "*!(.a|.b|.c)"', () => { assert(isMatch('e.e', '*!(.a|.b|.c)', { bash: true })); }); it('"e.e" should match "*.!(a|b|c)"', () => { assert(isMatch('e.e', '*.!(a|b|c)', { bash: true })); }); it('"e.e" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(!isMatch('e.e', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true })); }); it('"ef" should match "()ef"', () => { assert(isMatch('ef', '()ef', { bash: true })); }); it('"effgz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { assert(isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { bash: true })); }); it('"efgz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { assert(isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { bash: true })); }); it('"egz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { assert(isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { bash: true })); }); it('"egz" should not match "@(b+(c)d|e+(f)g?|?(h)i@(j|k))"', () => { assert(!isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))', { bash: true })); }); it('"egzefffgzbcdij" should match "*(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { assert(isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { bash: true })); }); it('"f" should not match "!(f!(o))"', () => { assert(!isMatch('f', '!(f!(o))', { bash: true })); }); it('"f" should match "!(f(o))"', () => { assert(isMatch('f', '!(f(o))', { bash: true })); }); it('"f" should not match "!(f)"', () => { assert(!isMatch('f', '!(f)', { bash: true })); }); it('"f" should not match "*(!(f))"', () => { assert(!isMatch('f', '*(!(f))', { bash: true })); }); it('"f" should not match "+(!(f))"', () => { assert(!isMatch('f', '+(!(f))', { bash: true })); }); it('"f.a" should not match "!(*.a|*.b|*.c)"', () => { assert(!isMatch('f.a', '!(*.a|*.b|*.c)', { bash: true })); }); it('"f.a" should match "*!(.a|.b|.c)"', () => { assert(isMatch('f.a', '*!(.a|.b|.c)', { bash: true })); }); it('"f.a" should not match "*.!(a|b|c)"', () => { assert(!isMatch('f.a', '*.!(a|b|c)', { bash: true })); }); it('"f.f" should match "!(*.a|*.b|*.c)"', () => { assert(isMatch('f.f', '!(*.a|*.b|*.c)', { bash: true })); }); it('"f.f" should match "*!(.a|.b|.c)"', () => { assert(isMatch('f.f', '*!(.a|.b|.c)', { bash: true })); }); it('"f.f" should match "*.!(a|b|c)"', () => { assert(isMatch('f.f', '*.!(a|b|c)', { bash: true })); }); it('"f.f" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(!isMatch('f.f', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true })); }); it('"fa" should not match "!(f!(o))"', () => { assert(!isMatch('fa', '!(f!(o))', { bash: true })); }); it('"fa" should match "!(f(o))"', () => { assert(isMatch('fa', '!(f(o))', { bash: true })); }); it('"fb" should not match "!(f!(o))"', () => { assert(!isMatch('fb', '!(f!(o))', { bash: true })); }); it('"fb" should match "!(f(o))"', () => { assert(isMatch('fb', '!(f(o))', { bash: true })); }); it('"fff" should match "!(f)"', () => { assert(isMatch('fff', '!(f)', { bash: true })); }); it('"fff" should match "*(!(f))"', () => { assert(isMatch('fff', '*(!(f))', { bash: true })); }); it('"fff" should match "+(!(f))"', () => { assert(isMatch('fff', '+(!(f))', { bash: true })); }); it('"fffooofoooooffoofffooofff" should match "*(*(f)*(o))"', () => { assert(isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { bash: true })); }); it('"ffo" should match "*(f*(o))"', () => { assert(isMatch('ffo', '*(f*(o))', { bash: true })); }); it('"file.C" should not match "*.c?(c)"', () => { assert(!isMatch('file.C', '*.c?(c)', { bash: true })); }); it('"file.c" should match "*.c?(c)"', () => { assert(isMatch('file.c', '*.c?(c)', { bash: true })); }); it('"file.cc" should match "*.c?(c)"', () => { assert(isMatch('file.cc', '*.c?(c)', { bash: true })); }); it('"file.ccc" should not match "*.c?(c)"', () => { assert(!isMatch('file.ccc', '*.c?(c)', { bash: true })); }); it('"fo" should match "!(f!(o))"', () => { assert(isMatch('fo', '!(f!(o))', { bash: true })); }); it('"fo" should not match "!(f(o))"', () => { assert(!isMatch('fo', '!(f(o))', { bash: true })); }); it('"fofo" should match "*(f*(o))"', () => { assert(isMatch('fofo', '*(f*(o))', { bash: true })); }); it('"fofoofoofofoo" should match "*(fo|foo)"', () => { assert(isMatch('fofoofoofofoo', '*(fo|foo)', { bash: true })); }); it('"fofoofoofofoo" should match "*(fo|foo)"', () => { assert(isMatch('fofoofoofofoo', '*(fo|foo)', { bash: true })); }); it('"foo" should match "!(!(foo))"', () => { assert(isMatch('foo', '!(!(foo))', { bash: true })); }); it('"foo" should match "!(f)"', () => { assert(isMatch('foo', '!(f)', { bash: true })); }); it('"foo" should not match "!(foo)"', () => { assert(!isMatch('foo', '!(foo)', { bash: true })); }); it('"foo" should not match "!(foo)*"', () => { assert(!isMatch('foo', '!(foo)*', { bash: true })); }); it('"foo" should not match "!(foo)*"', () => { assert(!isMatch('foo', '!(foo)*', { bash: true })); }); it('"foo" should not match "!(foo)+"', () => { assert(!isMatch('foo', '!(foo)+', { bash: true })); }); it('"foo" should not match "!(foo)b*"', () => { assert(!isMatch('foo', '!(foo)b*', { bash: true })); }); it('"foo" should match "!(x)"', () => { assert(isMatch('foo', '!(x)', { bash: true })); }); it('"foo" should match "!(x)*"', () => { assert(isMatch('foo', '!(x)*', { bash: true })); }); it('"foo" should match "*"', () => { assert(isMatch('foo', '*', { bash: true })); }); it('"foo" should match "*(!(f))"', () => { assert(isMatch('foo', '*(!(f))', { bash: true })); }); it('"foo" should not match "*(!(foo))"', () => { assert(!isMatch('foo', '*(!(foo))', { bash: true })); }); it('"foo" should not match "*(@(a))a@(c)"', () => { assert(!isMatch('foo', '*(@(a))a@(c)', { bash: true })); }); it('"foo" should match "*(@(foo))"', () => { assert(isMatch('foo', '*(@(foo))', { bash: true })); }); it('"foo" should not match "*(a|b\\[)"', () => { assert(!isMatch('foo', '*(a|b\\[)', { bash: true })); }); it('"foo" should match "*(a|b\\[)|f*"', () => { assert(isMatch('foo', '*(a|b\\[)|f*', { bash: true })); }); it('"foo" should match "@(*(a|b\\[)|f*)"', () => { assert(isMatch('foo', '@(*(a|b\\[)|f*)', { bash: true })); }); it('"foo" should not match "*/*/*"', () => { assert(!isMatch('foo', '*/*/*', { bash: true })); }); it('"foo" should not match "*f"', () => { assert(!isMatch('foo', '*f', { bash: true })); }); it('"foo" should match "*foo*"', () => { assert(isMatch('foo', '*foo*', { bash: true })); }); it('"foo" should match "+(!(f))"', () => { assert(isMatch('foo', '+(!(f))', { bash: true })); }); it('"foo" should not match "??"', () => { assert(!isMatch('foo', '??', { bash: true })); }); it('"foo" should match "???"', () => { assert(isMatch('foo', '???', { bash: true })); }); it('"foo" should not match "bar"', () => { assert(!isMatch('foo', 'bar', { bash: true })); }); it('"foo" should match "f*"', () => { assert(isMatch('foo', 'f*', { bash: true })); }); it('"foo" should not match "fo"', () => { assert(!isMatch('foo', 'fo', { bash: true })); }); it('"foo" should match "foo"', () => { assert(isMatch('foo', 'foo', { bash: true })); }); it('"foo" should match "{*(a|b\\[),f*}"', () => { assert(isMatch('foo', '{*(a|b\\[),f*}', { bash: true })); }); it('"foo*" should match "foo\\*"', () => { assert(isMatch('foo*', 'foo\\*', { bash: true, windows: false })); }); it('"foo*bar" should match "foo\\*bar"', () => { assert(isMatch('foo*bar', 'foo\\*bar', { bash: true })); }); it('"foo.js" should not match "!(foo).js"', () => { assert(!isMatch('foo.js', '!(foo).js', { bash: true })); }); it('"foo.js.js" should match "*.!(js)"', () => { assert(isMatch('foo.js.js', '*.!(js)', { bash: true })); }); it('"foo.js.js" should not match "*.!(js)*"', () => { assert(!isMatch('foo.js.js', '*.!(js)*', { bash: true })); }); it('"foo.js.js" should not match "*.!(js)*.!(js)"', () => { assert(!isMatch('foo.js.js', '*.!(js)*.!(js)', { bash: true })); }); it('"foo.js.js" should not match "*.!(js)+"', () => { assert(!isMatch('foo.js.js', '*.!(js)+', { bash: true })); }); it('"foo.txt" should match "**/!(bar).txt"', () => { assert(isMatch('foo.txt', '**/!(bar).txt', { bash: true })); }); it('"foo/bar" should not match "*/*/*"', () => { assert(!isMatch('foo/bar', '*/*/*', { bash: true })); }); it('"foo/bar" should match "foo/!(foo)"', () => { assert(isMatch('foo/bar', 'foo/!(foo)', { bash: true })); }); it('"foo/bar" should match "foo/*"', () => { assert(isMatch('foo/bar', 'foo/*', { bash: true })); }); it('"foo/bar" should match "foo/bar"', () => { assert(isMatch('foo/bar', 'foo/bar', { bash: true })); }); it('"foo/bar" should not match "foo?bar"', () => { assert(!isMatch('foo/bar', 'foo?bar', { bash: true })); }); it('"foo/bar" should match "foo[/]bar"', () => { assert(isMatch('foo/bar', 'foo[/]bar', { bash: true })); }); it('"foo/bar/baz.jsx" should match "foo/bar/**/*.+(js|jsx)"', () => { assert(isMatch('foo/bar/baz.jsx', 'foo/bar/**/*.+(js|jsx)', { bash: true })); }); it('"foo/bar/baz.jsx" should match "foo/bar/*.+(js|jsx)"', () => { assert(isMatch('foo/bar/baz.jsx', 'foo/bar/*.+(js|jsx)', { bash: true })); }); it('"foo/bb/aa/rr" should match "**/**/**"', () => { assert(isMatch('foo/bb/aa/rr', '**/**/**', { bash: true })); }); it('"foo/bb/aa/rr" should match "*/*/*"', () => { assert(isMatch('foo/bb/aa/rr', '*/*/*', { bash: true })); }); it('"foo/bba/arr" should match "*/*/*"', () => { assert(isMatch('foo/bba/arr', '*/*/*', { bash: true })); }); it('"foo/bba/arr" should match "foo*"', () => { assert(isMatch('foo/bba/arr', 'foo*', { bash: true })); }); it('"foo/bba/arr" should match "foo**"', () => { assert(isMatch('foo/bba/arr', 'foo**', { bash: true })); }); it('"foo/bba/arr" should match "foo/*"', () => { assert(isMatch('foo/bba/arr', 'foo/*', { bash: true })); }); it('"foo/bba/arr" should match "foo/**"', () => { assert(isMatch('foo/bba/arr', 'foo/**', { bash: true })); }); it('"foo/bba/arr" should match "foo/**arr"', () => { assert(isMatch('foo/bba/arr', 'foo/**arr', { bash: true })); }); it('"foo/bba/arr" should not match "foo/**z"', () => { assert(!isMatch('foo/bba/arr', 'foo/**z', { bash: true })); }); it('"foo/bba/arr" should match "foo/*arr"', () => { assert(isMatch('foo/bba/arr', 'foo/*arr', { bash: true })); }); it('"foo/bba/arr" should not match "foo/*z"', () => { assert(!isMatch('foo/bba/arr', 'foo/*z', { bash: true })); }); it('"foob" should not match "!(foo)b*"', () => { assert(!isMatch('foob', '!(foo)b*', { bash: true })); }); it('"foob" should not match "(foo)bb"', () => { assert(!isMatch('foob', '(foo)bb', { bash: true })); }); it('"foobar" should match "!(foo)"', () => { assert(isMatch('foobar', '!(foo)', { bash: true })); }); it('"foobar" should not match "!(foo)*"', () => { assert(!isMatch('foobar', '!(foo)*', { bash: true })); }); it('"foobar" should not match "!(foo)*"', () => { assert(!isMatch('foobar', '!(foo)*', { bash: true })); }); it('"foobar" should not match "!(foo)b*"', () => { assert(!isMatch('foobar', '!(foo)b*', { bash: true })); }); it('"foobar" should match "*(!(foo))"', () => { assert(isMatch('foobar', '*(!(foo))', { bash: true })); }); it('"foobar" should match "*ob*a*r*"', () => { assert(isMatch('foobar', '*ob*a*r*', { bash: true })); }); it('"foobar" should match "foo\\*bar"', () => { assert(isMatch('foobar', 'foo*bar', { bash: true })); }); it('"foobb" should not match "!(foo)b*"', () => { assert(!isMatch('foobb', '!(foo)b*', { bash: true })); }); it('"foobb" should match "(foo)bb"', () => { assert(isMatch('foobb', '(foo)bb', { bash: true })); }); it('"(foo)bb" should match "\\(foo\\)bb"', () => { assert(isMatch('(foo)bb', '\\(foo\\)bb', { bash: true })); }); it('"foofoofo" should match "@(foo|f|fo)*(f|of+(o))"', () => { assert(isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))', { bash: true })); }); it('"foofoofo" should match "@(foo|f|fo)*(f|of+(o))"', () => { assert(isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))', { bash: true })); }); it('"fooofoofofooo" should match "*(f*(o))"', () => { assert(isMatch('fooofoofofooo', '*(f*(o))', { bash: true })); }); it('"foooofo" should match "*(f*(o))"', () => { assert(isMatch('foooofo', '*(f*(o))', { bash: true })); }); it('"foooofof" should match "*(f*(o))"', () => { assert(isMatch('foooofof', '*(f*(o))', { bash: true })); }); it('"foooofof" should not match "*(f+(o))"', () => { assert(!isMatch('foooofof', '*(f+(o))', { bash: true })); }); it('"foooofofx" should not match "*(f*(o))"', () => { assert(!isMatch('foooofofx', '*(f*(o))', { bash: true })); }); it('"foooxfooxfoxfooox" should match "*(f*(o)x)"', () => { assert(isMatch('foooxfooxfoxfooox', '*(f*(o)x)', { bash: true })); }); it('"foooxfooxfxfooox" should match "*(f*(o)x)"', () => { assert(isMatch('foooxfooxfxfooox', '*(f*(o)x)', { bash: true })); }); it('"foooxfooxofoxfooox" should not match "*(f*(o)x)"', () => { assert(!isMatch('foooxfooxofoxfooox', '*(f*(o)x)', { bash: true })); }); it('"foot" should match "@(!(z*)|*x)"', () => { assert(isMatch('foot', '@(!(z*)|*x)', { bash: true })); }); it('"foox" should match "@(!(z*)|*x)"', () => { assert(isMatch('foox', '@(!(z*)|*x)', { bash: true })); }); it('"fz" should not match "*(z)"', () => { assert(!isMatch('fz', '*(z)', { bash: true })); }); it('"fz" should not match "+(z)"', () => { assert(!isMatch('fz', '+(z)', { bash: true })); }); it('"fz" should not match "?(z)"', () => { assert(!isMatch('fz', '?(z)', { bash: true })); }); it('"moo.cow" should not match "!(moo).!(cow)"', () => { assert(!isMatch('moo.cow', '!(moo).!(cow)', { bash: true })); }); it('"moo.cow" should not match "!(*).!(*)"', () => { assert(!isMatch('moo.cow', '!(*).!(*)', { bash: true })); }); it('"moo.cow" should not match "!(*.*).!(*.*)"', () => { assert(!isMatch('moo.cow', '!(*.*).!(*.*)', { bash: true })); }); it('"mad.moo.cow" should not match "!(*.*).!(*.*)"', () => { assert(!isMatch('mad.moo.cow', '!(*.*).!(*.*)', { bash: true })); }); it('"mad.moo.cow" should not match ".!(*.*)"', () => { assert(!isMatch('mad.moo.cow', '.!(*.*)', { bash: true })); }); it('"Makefile" should match "!(*.c|*.h|Makefile.in|config*|README)"', () => { assert(isMatch('Makefile', '!(*.c|*.h|Makefile.in|config*|README)', { bash: true })); }); it('"Makefile.in" should not match "!(*.c|*.h|Makefile.in|config*|README)"', () => { assert(!isMatch('Makefile.in', '!(*.c|*.h|Makefile.in|config*|README)', { bash: true })); }); it('"moo" should match "!(*.*)"', () => { assert(isMatch('moo', '!(*.*)', { bash: true })); }); it('"moo" should not match "!(*.*)."', () => { assert(!isMatch('moo', '!(*.*).', { bash: true })); }); it('"moo" should not match ".!(*.*)"', () => { assert(!isMatch('moo', '.!(*.*)', { bash: true })); }); it('"moo.cow" should not match "!(*.*)"', () => { assert(!isMatch('moo.cow', '!(*.*)', { bash: true })); }); it('"moo.cow" should not match "!(*.*)."', () => { assert(!isMatch('moo.cow', '!(*.*).', { bash: true })); }); it('"moo.cow" should not match ".!(*.*)"', () => { assert(!isMatch('moo.cow', '.!(*.*)', { bash: true })); }); it('"mucca.pazza" should not match "mu!(*(c))?.pa!(*(z))?"', () => { assert(!isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?', { bash: true })); }); it('"ofoofo" should match "*(of+(o))"', () => { assert(isMatch('ofoofo', '*(of+(o))', { bash: true })); }); it('"ofoofo" should match "*(of+(o)|f)"', () => { assert(isMatch('ofoofo', '*(of+(o)|f)', { bash: true })); }); it('"ofooofoofofooo" should not match "*(f*(o))"', () => { assert(!isMatch('ofooofoofofooo', '*(f*(o))', { bash: true })); }); it('"ofoooxoofxo" should match "*(*(of*(o)x)o)"', () => { assert(isMatch('ofoooxoofxo', '*(*(of*(o)x)o)', { bash: true })); }); it('"ofoooxoofxoofoooxoofxo" should match "*(*(of*(o)x)o)"', () => { assert(isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { bash: true })); }); it('"ofoooxoofxoofoooxoofxofo" should not match "*(*(of*(o)x)o)"', () => { assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { bash: true })); }); it('"ofoooxoofxoofoooxoofxoo" should match "*(*(of*(o)x)o)"', () => { assert(isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { bash: true })); }); it('"ofoooxoofxoofoooxoofxooofxofxo" should match "*(*(of*(o)x)o)"', () => { assert(isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { bash: true })); }); it('"ofxoofxo" should match "*(*(of*(o)x)o)"', () => { assert(isMatch('ofxoofxo', '*(*(of*(o)x)o)', { bash: true })); }); it('"oofooofo" should match "*(of|oof+(o))"', () => { assert(isMatch('oofooofo', '*(of|oof+(o))', { bash: true })); }); it('"ooo" should match "!(f)"', () => { assert(isMatch('ooo', '!(f)', { bash: true })); }); it('"ooo" should match "*(!(f))"', () => { assert(isMatch('ooo', '*(!(f))', { bash: true })); }); it('"ooo" should match "+(!(f))"', () => { assert(isMatch('ooo', '+(!(f))', { bash: true })); }); it('"oxfoxfox" should not match "*(oxf+(ox))"', () => { assert(!isMatch('oxfoxfox', '*(oxf+(ox))', { bash: true })); }); it('"oxfoxoxfox" should match "*(oxf+(ox))"', () => { assert(isMatch('oxfoxoxfox', '*(oxf+(ox))', { bash: true })); }); it('"para" should match "para*([0-9])"', () => { assert(isMatch('para', 'para*([0-9])', { bash: true })); }); it('"para" should not match "para+([0-9])"', () => { assert(!isMatch('para', 'para+([0-9])', { bash: true })); }); it('"para.38" should match "para!(*.[00-09])"', () => { assert(isMatch('para.38', 'para!(*.[00-09])', { bash: true })); }); it('"para.graph" should match "para!(*.[0-9])"', () => { assert(isMatch('para.graph', 'para!(*.[0-9])', { bash: true })); }); it('"para13829383746592" should match "para*([0-9])"', () => { assert(isMatch('para13829383746592', 'para*([0-9])', { bash: true })); }); it('"para381" should not match "para?([345]|99)1"', () => { assert(!isMatch('para381', 'para?([345]|99)1', { bash: true })); }); it('"para39" should match "para!(*.[0-9])"', () => { assert(isMatch('para39', 'para!(*.[0-9])', { bash: true })); }); it('"para987346523" should match "para+([0-9])"', () => { assert(isMatch('para987346523', 'para+([0-9])', { bash: true })); }); it('"para991" should match "para?([345]|99)1"', () => { assert(isMatch('para991', 'para?([345]|99)1', { bash: true })); }); it('"paragraph" should match "para!(*.[0-9])"', () => { assert(isMatch('paragraph', 'para!(*.[0-9])', { bash: true })); }); it('"paragraph" should not match "para*([0-9])"', () => { assert(!isMatch('paragraph', 'para*([0-9])', { bash: true })); }); it('"paragraph" should match "para@(chute|graph)"', () => { assert(isMatch('paragraph', 'para@(chute|graph)', { bash: true })); }); it('"paramour" should not match "para@(chute|graph)"', () => { assert(!isMatch('paramour', 'para@(chute|graph)', { bash: true })); }); it('"parse.y" should match "!(*.c|*.h|Makefile.in|config*|README)"', () => { assert(isMatch('parse.y', '!(*.c|*.h|Makefile.in|config*|README)', { bash: true })); }); it('"shell.c" should not match "!(*.c|*.h|Makefile.in|config*|README)"', () => { assert(!isMatch('shell.c', '!(*.c|*.h|Makefile.in|config*|README)', { bash: true })); }); it('"VMS.FILE;" should not match "*\\;[1-9]*([0-9])"', () => { assert(!isMatch('VMS.FILE;', '*\\;[1-9]*([0-9])', { bash: true })); }); it('"VMS.FILE;0" should not match "*\\;[1-9]*([0-9])"', () => { assert(!isMatch('VMS.FILE;0', '*\\;[1-9]*([0-9])', { bash: true })); }); it('"VMS.FILE;9" should match "*\\;[1-9]*([0-9])"', () => { assert(isMatch('VMS.FILE;9', '*\\;[1-9]*([0-9])', { bash: true })); }); it('"VMS.FILE;1" should match "*\\;[1-9]*([0-9])"', () => { assert(isMatch('VMS.FILE;1', '*\\;[1-9]*([0-9])', { bash: true })); }); it('"VMS.FILE;1" should match "*;[1-9]*([0-9])"', () => { assert(isMatch('VMS.FILE;1', '*;[1-9]*([0-9])', { bash: true })); }); it('"VMS.FILE;139" should match "*\\;[1-9]*([0-9])"', () => { assert(isMatch('VMS.FILE;139', '*\\;[1-9]*([0-9])', { bash: true })); }); it('"VMS.FILE;1N" should not match "*\\;[1-9]*([0-9])"', () => { assert(!isMatch('VMS.FILE;1N', '*\\;[1-9]*([0-9])', { bash: true })); }); it('"xfoooofof" should not match "*(f*(o))"', () => { assert(!isMatch('xfoooofof', '*(f*(o))', { bash: true })); }); it('"XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1" should match "XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*"', () => { assert(isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', { bash: true, windows: false })); }); it('"XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1" should not match "XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*"', () => { assert(!isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', { bash: true })); }); it('"z" should match "*(z)"', () => { assert(isMatch('z', '*(z)', { bash: true })); }); it('"z" should match "+(z)"', () => { assert(isMatch('z', '+(z)', { bash: true })); }); it('"z" should match "?(z)"', () => { assert(isMatch('z', '?(z)', { bash: true })); }); it('"zf" should not match "*(z)"', () => { assert(!isMatch('zf', '*(z)', { bash: true })); }); it('"zf" should not match "+(z)"', () => { assert(!isMatch('zf', '+(z)', { bash: true })); }); it('"zf" should not match "?(z)"', () => { assert(!isMatch('zf', '?(z)', { bash: true })); }); it('"zoot" should not match "@(!(z*)|*x)"', () => { assert(!isMatch('zoot', '@(!(z*)|*x)', { bash: true })); }); it('"zoox" should match "@(!(z*)|*x)"', () => { assert(isMatch('zoox', '@(!(z*)|*x)', { bash: true })); }); it('"zz" should not match "(a+|b)*"', () => { assert(!isMatch('zz', '(a+|b)*', { bash: true })); }); }); micromatch-4.0.5/test/extglobs-minimatch.js000066400000000000000000002033041421714312500207630ustar00rootroot00000000000000'use strict'; require('mocha'); const path = require('path'); const assert = require('assert'); const { isMatch, makeRe } = require('..'); if (!process.env.ORIGINAL_PATH_SEP) { process.env.ORIGINAL_PATH_SEP = path.sep } /** * Some of tests were converted from bash 4.3, 4.4, and minimatch unit tests. */ describe('extglobs (minimatch)', () => { let setup = { before: () => (path.sep = '\\'), after: () => (path.sep = process.env.ORIGINAL_PATH_SEP) }; afterEach(() => setup.after()); beforeEach(() => setup.before()); it('should not match empty string with "*(0|1|3|5|7|9)"', () => { assert(!isMatch('', '*(0|1|3|5|7|9)')); }); it('"*(a|b[)" should not match "*(a|b\\[)"', () => { assert(!isMatch('*(a|b[)', '*(a|b\\[)')); }); it('"*(a|b[)" should not match "\\*\\(a|b\\[\\)"', () => { assert(isMatch('*(a|b[)', '\\*\\(a\\|b\\[\\)')); }); it('"***" should match "\\*\\*\\*"', () => { assert(isMatch('***', '\\*\\*\\*')); }); it('"-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1" should not match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*')); }); it('"-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1" should match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { assert(isMatch('-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*')); }); it('"-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1" should not match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*')); }); it('"/dev/udp/129.22.8.102/45" should not match "/dev\\/@(tcp|udp)\\/*\\/*"', () => { assert(isMatch('/dev/udp/129.22.8.102/45', '/dev\\/@(tcp|udp)\\/*\\/*')); }); it('"/x/y/z" should match "/x/y/z"', () => { assert(isMatch('/x/y/z', '/x/y/z')); }); it('"0377" should match "+([0-7])"', () => { assert(isMatch('0377', '+([0-7])')); }); it('"07" should match "+([0-7])"', () => { assert(isMatch('07', '+([0-7])')); }); it('"09" should not match "+([0-7])"', () => { assert(!isMatch('09', '+([0-7])')); }); it('"1" should match "0|[1-9]*([0-9])"', () => { assert(isMatch('1', '0|[1-9]*([0-9])')); }); it('"12" should match "0|[1-9]*([0-9])"', () => { assert(isMatch('12', '0|[1-9]*([0-9])')); }); it('"123abc" should not match "(a+|b)*"', () => { assert(!isMatch('123abc', '(a+|b)*')); }); it('"123abc" should not match "(a+|b)+"', () => { assert(!isMatch('123abc', '(a+|b)+')); }); it('"123abc" should match "*?(a)bc"', () => { assert(isMatch('123abc', '*?(a)bc')); }); it('"123abc" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('123abc', 'a(b*(foo|bar))d')); }); it('"123abc" should not match "ab*(e|f)"', () => { assert(!isMatch('123abc', 'ab*(e|f)')); }); it('"123abc" should not match "ab**"', () => { assert(!isMatch('123abc', 'ab**')); }); it('"123abc" should not match "ab**(e|f)"', () => { assert(!isMatch('123abc', 'ab**(e|f)')); }); it('"123abc" should not match "ab**(e|f)g"', () => { assert(!isMatch('123abc', 'ab**(e|f)g')); }); it('"123abc" should not match "ab***ef"', () => { assert(!isMatch('123abc', 'ab***ef')); }); it('"123abc" should not match "ab*+(e|f)"', () => { assert(!isMatch('123abc', 'ab*+(e|f)')); }); it('"123abc" should not match "ab*d+(e|f)"', () => { assert(!isMatch('123abc', 'ab*d+(e|f)')); }); it('"123abc" should not match "ab?*(e|f)"', () => { assert(!isMatch('123abc', 'ab?*(e|f)')); }); it('"12abc" should not match "0|[1-9]*([0-9])"', () => { assert(!isMatch('12abc', '0|[1-9]*([0-9])')); }); it('"137577991" should match "*(0|1|3|5|7|9)"', () => { assert(isMatch('137577991', '*(0|1|3|5|7|9)')); }); it('"2468" should not match "*(0|1|3|5|7|9)"', () => { assert(!isMatch('2468', '*(0|1|3|5|7|9)')); }); it('"?a?b" should match "\\??\\?b"', () => { assert(isMatch('?a?b', '\\??\\?b')); }); it('"\\a\\b\\c" should not match "abc"', () => { assert(!isMatch('\\a\\b\\c', 'abc')); }); it('"a" should match "!(*.a|*.b|*.c)"', () => { assert(isMatch('a', '!(*.a|*.b|*.c)')); }); it('"a" should not match "!(a)"', () => { assert(!isMatch('a', '!(a)')); }); it('"a" should not match "!(a)*"', () => { assert(!isMatch('a', '!(a)*')); }); it('"a" should match "(a)"', () => { assert(isMatch('a', '(a)')); }); it('"a" should not match "(b)"', () => { assert(!isMatch('a', '(b)')); }); it('"a" should match "*(a)"', () => { assert(isMatch('a', '*(a)')); }); it('"a" should match "+(a)"', () => { assert(isMatch('a', '+(a)')); }); it('"a" should match "?"', () => { assert(isMatch('a', '?')); }); it('"a" should match "?(a|b)"', () => { assert(isMatch('a', '?(a|b)')); }); it('"a" should not match "??"', () => { assert(!isMatch('a', '??')); }); it('"a" should match "a!(b)*"', () => { assert(isMatch('a', 'a!(b)*')); }); it('"a" should match "a?(a|b)"', () => { assert(isMatch('a', 'a?(a|b)')); }); it('"a" should match "a?(x)"', () => { assert(isMatch('a', 'a?(x)')); }); it('"a" should not match "a??b"', () => { assert(!isMatch('a', 'a??b')); }); it('"a" should not match "b?(a|b)"', () => { assert(!isMatch('a', 'b?(a|b)')); }); it('"a((((b" should match "a(*b"', () => { assert(isMatch('a((((b', 'a(*b')); }); it('"a((((b" should not match "a(b"', () => { assert(!isMatch('a((((b', 'a(b')); }); it('"a((((b" should not match "a\\(b"', () => { assert(!isMatch('a((((b', 'a\\(b')); }); it('"a((b" should match "a(*b"', () => { assert(isMatch('a((b', 'a(*b')); }); it('"a((b" should not match "a(b"', () => { assert(!isMatch('a((b', 'a(b')); }); it('"a((b" should not match "a\\(b"', () => { assert(!isMatch('a((b', 'a\\(b')); }); it('"a(b" should match "a(*b"', () => { assert(isMatch('a(b', 'a(*b')); }); it('"a(b" should match "a(b"', () => { assert(isMatch('a(b', 'a(b')); }); it('"a(b" should match "a\\(b"', () => { assert(isMatch('a(b', 'a\\(b')); }); it('"a." should match "!(*.a|*.b|*.c)"', () => { assert(isMatch('a.', '!(*.a|*.b|*.c)')); }); it('"a." should match "*!(.a|.b|.c)"', () => { assert(isMatch('a.', '*!(.a|.b|.c)')); }); it('"a." should match "*.!(a)"', () => { assert(isMatch('a.', '*.!(a)')); }); it('"a." should match "*.!(a|b|c)"', () => { assert(isMatch('a.', '*.!(a|b|c)')); }); it('"a." should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(!isMatch('a.', '*.(a|b|@(ab|a*@(b))*(c)d)')); }); it('"a." should not match "*.+(b|d)"', () => { assert(!isMatch('a.', '*.+(b|d)')); }); it('"a.a" should not match "!(*.[a-b]*)"', () => { assert(!isMatch('a.a', '!(*.[a-b]*)')); }); it('"a.a" should not match "!(*.a|*.b|*.c)"', () => { assert(!isMatch('a.a', '!(*.a|*.b|*.c)')); }); it('"a.a" should not match "!(*[a-b].[a-b]*)"', () => { assert(!isMatch('a.a', '!(*[a-b].[a-b]*)')); }); it('"a.a" should not match "!*.(a|b)"', () => { assert(!isMatch('a.a', '!*.(a|b)')); }); it('"a.a" should not match "!*.(a|b)*"', () => { assert(!isMatch('a.a', '!*.(a|b)*')); }); it('"a.a" should match "(a|d).(a|b)*"', () => { assert(isMatch('a.a', '(a|d).(a|b)*')); }); it('"a.a" should match "(b|a).(a)"', () => { assert(isMatch('a.a', '(b|a).(a)')); }); it('"a.a" should match "*!(.a|.b|.c)"', () => { assert(isMatch('a.a', '*!(.a|.b|.c)')); }); it('"a.a" should not match "*.!(a)"', () => { assert(!isMatch('a.a', '*.!(a)')); }); it('"a.a" should not match "*.!(a|b|c)"', () => { assert(!isMatch('a.a', '*.!(a|b|c)')); }); it('"a.a" should match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(isMatch('a.a', '*.(a|b|@(ab|a*@(b))*(c)d)')); }); it('"a.a" should not match "*.+(b|d)"', () => { assert(!isMatch('a.a', '*.+(b|d)')); }); it('"a.a" should match "@(b|a).@(a)"', () => { assert(isMatch('a.a', '@(b|a).@(a)')); }); it('"a.a.a" should not match "!(*.[a-b]*)"', () => { assert(!isMatch('a.a.a', '!(*.[a-b]*)')); }); it('"a.a.a" should not match "!(*[a-b].[a-b]*)"', () => { assert(!isMatch('a.a.a', '!(*[a-b].[a-b]*)')); }); it('"a.a.a" should not match "!*.(a|b)"', () => { assert(!isMatch('a.a.a', '!*.(a|b)')); }); it('"a.a.a" should not match "!*.(a|b)*"', () => { assert(!isMatch('a.a.a', '!*.(a|b)*')); }); it('"a.a.a" should match "*.!(a)"', () => { assert(isMatch('a.a.a', '*.!(a)')); }); it('"a.a.a" should not match "*.+(b|d)"', () => { assert(!isMatch('a.a.a', '*.+(b|d)')); }); it('"a.aa.a" should not match "(b|a).(a)"', () => { assert(!isMatch('a.aa.a', '(b|a).(a)')); }); it('"a.aa.a" should not match "@(b|a).@(a)"', () => { assert(!isMatch('a.aa.a', '@(b|a).@(a)')); }); it('"a.abcd" should match "!(*.a|*.b|*.c)"', () => { assert(isMatch('a.abcd', '!(*.a|*.b|*.c)')); }); it('"a.abcd" should not match "!(*.a|*.b|*.c)*"', () => { assert(!isMatch('a.abcd', '!(*.a|*.b|*.c)*')); }); it('"a.abcd" should match "*!(*.a|*.b|*.c)*"', () => { assert(isMatch('a.abcd', '*!(*.a|*.b|*.c)*')); }); it('"a.abcd" should match "*!(.a|.b|.c)"', () => { assert(isMatch('a.abcd', '*!(.a|.b|.c)')); }); it('"a.abcd" should match "*.!(a|b|c)"', () => { assert(isMatch('a.abcd', '*.!(a|b|c)')); }); it('"a.abcd" should not match "*.!(a|b|c)*"', () => { assert(!isMatch('a.abcd', '*.!(a|b|c)*')); }); it('"a.abcd" should match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(isMatch('a.abcd', '*.(a|b|@(ab|a*@(b))*(c)d)')); }); it('"a.b" should not match "!(*.*)"', () => { assert(!isMatch('a.b', '!(*.*)')); }); it('"a.b" should not match "!(*.[a-b]*)"', () => { assert(!isMatch('a.b', '!(*.[a-b]*)')); }); it('"a.b" should not match "!(*.a|*.b|*.c)"', () => { assert(!isMatch('a.b', '!(*.a|*.b|*.c)')); }); it('"a.b" should not match "!(*[a-b].[a-b]*)"', () => { assert(!isMatch('a.b', '!(*[a-b].[a-b]*)')); }); it('"a.b" should not match "!*.(a|b)"', () => { assert(!isMatch('a.b', '!*.(a|b)')); }); it('"a.b" should not match "!*.(a|b)*"', () => { assert(!isMatch('a.b', '!*.(a|b)*')); }); it('"a.b" should match "(a|d).(a|b)*"', () => { assert(isMatch('a.b', '(a|d).(a|b)*')); }); it('"a.b" should match "*!(.a|.b|.c)"', () => { assert(isMatch('a.b', '*!(.a|.b|.c)')); }); it('"a.b" should match "*.!(a)"', () => { assert(isMatch('a.b', '*.!(a)')); }); it('"a.b" should not match "*.!(a|b|c)"', () => { assert(!isMatch('a.b', '*.!(a|b|c)')); }); it('"a.b" should match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(isMatch('a.b', '*.(a|b|@(ab|a*@(b))*(c)d)')); }); it('"a.b" should match "*.+(b|d)"', () => { assert(isMatch('a.b', '*.+(b|d)')); }); it('"a.bb" should not match "!(*.[a-b]*)"', () => { assert(!isMatch('a.bb', '!(*.[a-b]*)')); }); it('"a.bb" should not match "!(*[a-b].[a-b]*)"', () => { assert(!isMatch('a.bb', '!(*[a-b].[a-b]*)')); }); it('"a.bb" should match "!*.(a|b)"', () => { assert(isMatch('a.bb', '!*.(a|b)')); }); it('"a.bb" should not match "!*.(a|b)*"', () => { assert(!isMatch('a.bb', '!*.(a|b)*')); }); it('"a.bb" should not match "!*.*(a|b)"', () => { assert(!isMatch('a.bb', '!*.*(a|b)')); }); it('"a.bb" should match "(a|d).(a|b)*"', () => { assert(isMatch('a.bb', '(a|d).(a|b)*')); }); it('"a.bb" should not match "(b|a).(a)"', () => { assert(!isMatch('a.bb', '(b|a).(a)')); }); it('"a.bb" should match "*.+(b|d)"', () => { assert(isMatch('a.bb', '*.+(b|d)')); }); it('"a.bb" should not match "@(b|a).@(a)"', () => { assert(!isMatch('a.bb', '@(b|a).@(a)')); }); it('"a.c" should not match "!(*.a|*.b|*.c)"', () => { assert(!isMatch('a.c', '!(*.a|*.b|*.c)')); }); it('"a.c" should match "*!(.a|.b|.c)"', () => { assert(isMatch('a.c', '*!(.a|.b|.c)')); }); it('"a.c" should not match "*.!(a|b|c)"', () => { assert(!isMatch('a.c', '*.!(a|b|c)')); }); it('"a.c" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(!isMatch('a.c', '*.(a|b|@(ab|a*@(b))*(c)d)')); }); it('"a.c.d" should match "!(*.a|*.b|*.c)"', () => { assert(isMatch('a.c.d', '!(*.a|*.b|*.c)')); }); it('"a.c.d" should match "*!(.a|.b|.c)"', () => { assert(isMatch('a.c.d', '*!(.a|.b|.c)')); }); it('"a.c.d" should match "*.!(a|b|c)"', () => { assert(isMatch('a.c.d', '*.!(a|b|c)')); }); it('"a.c.d" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(!isMatch('a.c.d', '*.(a|b|@(ab|a*@(b))*(c)d)')); }); it('"a.ccc" should match "!(*.[a-b]*)"', () => { assert(isMatch('a.ccc', '!(*.[a-b]*)')); }); it('"a.ccc" should match "!(*[a-b].[a-b]*)"', () => { assert(isMatch('a.ccc', '!(*[a-b].[a-b]*)')); }); it('"a.ccc" should match "!*.(a|b)"', () => { assert(isMatch('a.ccc', '!*.(a|b)')); }); it('"a.ccc" should match "!*.(a|b)*"', () => { assert(isMatch('a.ccc', '!*.(a|b)*')); }); it('"a.ccc" should not match "*.+(b|d)"', () => { assert(!isMatch('a.ccc', '*.+(b|d)')); }); it('"a.js" should not match "!(*.js)"', () => { assert(!isMatch('a.js', '!(*.js)')); }); it('"a.js" should match "*!(.js)"', () => { assert(isMatch('a.js', '*!(.js)')); }); it('"a.js" should not match "*.!(js)"', () => { assert(!isMatch('a.js', '*.!(js)')); }); it('"a.js" should not match "a.!(js)"', () => { assert(!isMatch('a.js', 'a.!(js)')); }); it('"a.js" should not match "a.!(js)*"', () => { assert(!isMatch('a.js', 'a.!(js)*')); }); it('"a.js.js" should not match "!(*.js)"', () => { assert(!isMatch('a.js.js', '!(*.js)')); }); it('"a.js.js" should match "*!(.js)"', () => { assert(isMatch('a.js.js', '*!(.js)')); }); it('"a.js.js" should match "*.!(js)"', () => { assert(isMatch('a.js.js', '*.!(js)')); }); it('"a.js.js" should match "*.*(js).js"', () => { assert(isMatch('a.js.js', '*.*(js).js')); }); it('"a.md" should match "!(*.js)"', () => { assert(isMatch('a.md', '!(*.js)')); }); it('"a.md" should match "*!(.js)"', () => { assert(isMatch('a.md', '*!(.js)')); }); it('"a.md" should match "*.!(js)"', () => { assert(isMatch('a.md', '*.!(js)')); }); it('"a.md" should match "a.!(js)"', () => { assert(isMatch('a.md', 'a.!(js)')); }); it('"a.md" should match "a.!(js)*"', () => { assert(isMatch('a.md', 'a.!(js)*')); }); it('"a.md.js" should not match "*.*(js).js"', () => { assert(!isMatch('a.md.js', '*.*(js).js')); }); it('"a.txt" should match "a.!(js)"', () => { assert(isMatch('a.txt', 'a.!(js)')); }); it('"a.txt" should match "a.!(js)*"', () => { assert(isMatch('a.txt', 'a.!(js)*')); }); it('"a/!(z)" should match "a/!(z)"', () => { assert(isMatch('a/!(z)', 'a/!(z)')); }); it('"a/b" should match "a/!(z)"', () => { assert(isMatch('a/b', 'a/!(z)')); }); it('"a/b/c.txt" should not match "*/b/!(*).txt"', () => { assert(!isMatch('a/b/c.txt', '*/b/!(*).txt')); }); it('"a/b/c.txt" should not match "*/b/!(c).txt"', () => { assert(!isMatch('a/b/c.txt', '*/b/!(c).txt')); }); it('"a/b/c.txt" should match "*/b/!(cc).txt"', () => { assert(isMatch('a/b/c.txt', '*/b/!(cc).txt')); }); it('"a/b/cc.txt" should not match "*/b/!(*).txt"', () => { assert(!isMatch('a/b/cc.txt', '*/b/!(*).txt')); }); it('"a/b/cc.txt" should not match "*/b/!(c).txt"', () => { assert(!isMatch('a/b/cc.txt', '*/b/!(c).txt')); }); it('"a/b/cc.txt" should not match "*/b/!(cc).txt"', () => { assert(!isMatch('a/b/cc.txt', '*/b/!(cc).txt')); }); it('"a/dir/foo.txt" should match "*/dir/**/!(bar).txt"', () => { assert(isMatch('a/dir/foo.txt', '*/dir/**/!(bar).txt')); }); it('"a/z" should not match "a/!(z)"', () => { assert(!isMatch('a/z', 'a/!(z)')); }); it('"a\\(b" should not match "a(*b"', () => { assert(!isMatch('a\\(b', 'a(*b')); }); it('"a\\(b" should not match "a(b"', () => { assert(!isMatch('a\\(b', 'a(b')); }); it('"a\\z" should match "a\\z"', () => { assert(isMatch('a\\\\z', 'a\\\\z', { windows: false })); }); it('"a\\z" should match "a\\z"', () => { assert(isMatch('a\\\\z', 'a\\\\z')); }); it('"a\\b" should match "a/b"', () => { assert(isMatch('a\\b', 'a/b', { windows: true })); }); it('"a\\z" should match "a\\z"', () => { assert(isMatch('a\\z', 'a\\\\z', { windows: false })); }); it('"a\\z" should not match "a\\z"', () => { assert(!isMatch('a\\z', 'a\\\\z')); }); it('"aa" should not match "!(a!(b))"', () => { assert(!isMatch('aa', '!(a!(b))')); }); it('"aa" should match "!(a)"', () => { assert(isMatch('aa', '!(a)')); }); it('"aa" should not match "!(a)*"', () => { assert(!isMatch('aa', '!(a)*')); }); it('"aa" should not match "?"', () => { assert(!isMatch('aa', '?')); }); it('"aa" should not match "@(a)b"', () => { assert(!isMatch('aa', '@(a)b')); }); it('"aa" should match "a!(b)*"', () => { assert(isMatch('aa', 'a!(b)*')); }); it('"aa" should not match "a??b"', () => { assert(!isMatch('aa', 'a??b')); }); it('"aa.aa" should not match "(b|a).(a)"', () => { assert(!isMatch('aa.aa', '(b|a).(a)')); }); it('"aa.aa" should not match "@(b|a).@(a)"', () => { assert(!isMatch('aa.aa', '@(b|a).@(a)')); }); it('"aaa" should not match "!(a)*"', () => { assert(!isMatch('aaa', '!(a)*')); }); it('"aaa" should match "a!(b)*"', () => { assert(isMatch('aaa', 'a!(b)*')); }); it('"aaaaaaabababab" should match "*ab"', () => { assert(isMatch('aaaaaaabababab', '*ab')); }); it('"aaac" should match "*(@(a))a@(c)"', () => { assert(isMatch('aaac', '*(@(a))a@(c)')); }); it('"aaaz" should match "[a*(]*z"', () => { assert(isMatch('aaaz', '[a*(]*z')); }); it('"aab" should not match "!(a)*"', () => { assert(!isMatch('aab', '!(a)*')); }); it('"aab" should not match "?"', () => { assert(!isMatch('aab', '?')); }); it('"aab" should not match "??"', () => { assert(!isMatch('aab', '??')); }); it('"aab" should not match "@(c)b"', () => { assert(!isMatch('aab', '@(c)b')); }); it('"aab" should match "a!(b)*"', () => { assert(isMatch('aab', 'a!(b)*')); }); it('"aab" should not match "a??b"', () => { assert(!isMatch('aab', 'a??b')); }); it('"aac" should match "*(@(a))a@(c)"', () => { assert(isMatch('aac', '*(@(a))a@(c)')); }); it('"aac" should not match "*(@(a))b@(c)"', () => { assert(!isMatch('aac', '*(@(a))b@(c)')); }); it('"aax" should not match "a!(a*|b)"', () => { assert(!isMatch('aax', 'a!(a*|b)')); }); it('"aax" should match "a!(x*|b)"', () => { assert(isMatch('aax', 'a!(x*|b)')); }); it('"aax" should match "a?(a*|b)"', () => { assert(isMatch('aax', 'a?(a*|b)')); }); it('"aaz" should match "[a*(]*z"', () => { assert(isMatch('aaz', '[a*(]*z')); }); it('"ab" should match "!(*.*)"', () => { assert(isMatch('ab', '!(*.*)')); }); it('"ab" should match "!(a!(b))"', () => { assert(isMatch('ab', '!(a!(b))')); }); it('"ab" should not match "!(a)*"', () => { assert(!isMatch('ab', '!(a)*')); }); it('"ab" should match "(a+|b)*"', () => { assert(isMatch('ab', '(a+|b)*')); }); it('"ab" should match "(a+|b)+"', () => { assert(isMatch('ab', '(a+|b)+')); }); it('"ab" should not match "*?(a)bc"', () => { assert(!isMatch('ab', '*?(a)bc')); }); it('"ab" should not match "a!(*(b|B))"', () => { assert(!isMatch('ab', 'a!(*(b|B))')); }); it('"ab" should not match "a!(@(b|B))"', () => { assert(!isMatch('ab', 'a!(@(b|B))')); }); it('"aB" should not match "a!(@(b|B))"', () => { assert(!isMatch('aB', 'a!(@(b|B))')); }); it('"ab" should not match "a!(b)*"', () => { assert(!isMatch('ab', 'a!(b)*')); }); it('"ab" should not match "a(*b"', () => { assert(!isMatch('ab', 'a(*b')); }); it('"ab" should not match "a(b"', () => { assert(!isMatch('ab', 'a(b')); }); it('"ab" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('ab', 'a(b*(foo|bar))d')); }); it('"ab" should not match "a/b"', () => { assert(!isMatch('ab', 'a/b', { windows: true })); }); it('"ab" should not match "a\\(b"', () => { assert(!isMatch('ab', 'a\\(b')); }); it('"ab" should match "ab*(e|f)"', () => { assert(isMatch('ab', 'ab*(e|f)')); }); it('"ab" should match "ab**"', () => { assert(isMatch('ab', 'ab**')); }); it('"ab" should match "ab**(e|f)"', () => { assert(isMatch('ab', 'ab**(e|f)')); }); it('"ab" should not match "ab**(e|f)g"', () => { assert(!isMatch('ab', 'ab**(e|f)g')); }); it('"ab" should not match "ab***ef"', () => { assert(!isMatch('ab', 'ab***ef')); }); it('"ab" should not match "ab*+(e|f)"', () => { assert(!isMatch('ab', 'ab*+(e|f)')); }); it('"ab" should not match "ab*d+(e|f)"', () => { assert(!isMatch('ab', 'ab*d+(e|f)')); }); it('"ab" should not match "ab?*(e|f)"', () => { assert(!isMatch('ab', 'ab?*(e|f)')); }); it('"ab/cXd/efXg/hi" should match "**/*X*/**/*i"', () => { assert(isMatch('ab/cXd/efXg/hi', '**/*X*/**/*i')); }); it('"ab/cXd/efXg/hi" should match "*/*X*/*/*i"', () => { assert(isMatch('ab/cXd/efXg/hi', '*/*X*/*/*i')); }); it('"ab/cXd/efXg/hi" should not match "*X*i"', () => { assert(!isMatch('ab/cXd/efXg/hi', '*X*i')); }); it('"ab/cXd/efXg/hi" should not match "*Xg*i"', () => { assert(!isMatch('ab/cXd/efXg/hi', '*Xg*i')); }); it('"ab]" should match "a!(@(b|B))"', () => { assert(isMatch('ab]', 'a!(@(b|B))')); }); it('"abab" should match "(a+|b)*"', () => { assert(isMatch('abab', '(a+|b)*')); }); it('"abab" should match "(a+|b)+"', () => { assert(isMatch('abab', '(a+|b)+')); }); it('"abab" should not match "*?(a)bc"', () => { assert(!isMatch('abab', '*?(a)bc')); }); it('"abab" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('abab', 'a(b*(foo|bar))d')); }); it('"abab" should not match "ab*(e|f)"', () => { assert(!isMatch('abab', 'ab*(e|f)')); }); it('"abab" should match "ab**"', () => { assert(isMatch('abab', 'ab**')); }); it('"abab" should match "ab**(e|f)"', () => { assert(isMatch('abab', 'ab**(e|f)')); }); it('"abab" should not match "ab**(e|f)g"', () => { assert(!isMatch('abab', 'ab**(e|f)g')); }); it('"abab" should not match "ab***ef"', () => { assert(!isMatch('abab', 'ab***ef')); }); it('"abab" should not match "ab*+(e|f)"', () => { assert(!isMatch('abab', 'ab*+(e|f)')); }); it('"abab" should not match "ab*d+(e|f)"', () => { assert(!isMatch('abab', 'ab*d+(e|f)')); }); it('"abab" should not match "ab?*(e|f)"', () => { assert(!isMatch('abab', 'ab?*(e|f)')); }); it('"abb" should match "!(*.*)"', () => { assert(isMatch('abb', '!(*.*)')); }); it('"abb" should not match "!(a)*"', () => { assert(!isMatch('abb', '!(a)*')); }); it('"abb" should not match "a!(b)*"', () => { assert(!isMatch('abb', 'a!(b)*')); }); it('"abbcd" should match "@(ab|a*(b))*(c)d"', () => { assert(isMatch('abbcd', '@(ab|a*(b))*(c)d')); }); it('"abc" should not match "\\a\\b\\c"', () => { assert(!isMatch('abc', '\\a\\b\\c')); }); it('"aBc" should match "a!(@(b|B))"', () => { assert(isMatch('aBc', 'a!(@(b|B))')); }); it('"abcd" should match "?@(a|b)*@(c)d"', () => { assert(isMatch('abcd', '?@(a|b)*@(c)d')); }); it('"abcd" should match "@(ab|a*@(b))*(c)d"', () => { assert(isMatch('abcd', '@(ab|a*@(b))*(c)d')); }); it('"abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt" should match "**/*a*b*g*n*t"', () => { assert(isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt', '**/*a*b*g*n*t')); }); it('"abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz" should not match "**/*a*b*g*n*t"', () => { assert(!isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz', '**/*a*b*g*n*t')); }); it('"abcdef" should match "(a+|b)*"', () => { assert(isMatch('abcdef', '(a+|b)*')); }); it('"abcdef" should not match "(a+|b)+"', () => { assert(!isMatch('abcdef', '(a+|b)+')); }); it('"abcdef" should not match "*?(a)bc"', () => { assert(!isMatch('abcdef', '*?(a)bc')); }); it('"abcdef" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('abcdef', 'a(b*(foo|bar))d')); }); it('"abcdef" should not match "ab*(e|f)"', () => { assert(!isMatch('abcdef', 'ab*(e|f)')); }); it('"abcdef" should match "ab**"', () => { assert(isMatch('abcdef', 'ab**')); }); it('"abcdef" should match "ab**(e|f)"', () => { assert(isMatch('abcdef', 'ab**(e|f)')); }); it('"abcdef" should not match "ab**(e|f)g"', () => { assert(!isMatch('abcdef', 'ab**(e|f)g')); }); it('"abcdef" should match "ab***ef"', () => { assert(isMatch('abcdef', 'ab***ef')); }); it('"abcdef" should match "ab*+(e|f)"', () => { assert(isMatch('abcdef', 'ab*+(e|f)')); }); it('"abcdef" should match "ab*d+(e|f)"', () => { assert(isMatch('abcdef', 'ab*d+(e|f)')); }); it('"abcdef" should not match "ab?*(e|f)"', () => { assert(!isMatch('abcdef', 'ab?*(e|f)')); }); it('"abcfef" should match "(a+|b)*"', () => { assert(isMatch('abcfef', '(a+|b)*')); }); it('"abcfef" should not match "(a+|b)+"', () => { assert(!isMatch('abcfef', '(a+|b)+')); }); it('"abcfef" should not match "*?(a)bc"', () => { assert(!isMatch('abcfef', '*?(a)bc')); }); it('"abcfef" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('abcfef', 'a(b*(foo|bar))d')); }); it('"abcfef" should not match "ab*(e|f)"', () => { assert(!isMatch('abcfef', 'ab*(e|f)')); }); it('"abcfef" should match "ab**"', () => { assert(isMatch('abcfef', 'ab**')); }); it('"abcfef" should match "ab**(e|f)"', () => { assert(isMatch('abcfef', 'ab**(e|f)')); }); it('"abcfef" should not match "ab**(e|f)g"', () => { assert(!isMatch('abcfef', 'ab**(e|f)g')); }); it('"abcfef" should match "ab***ef"', () => { assert(isMatch('abcfef', 'ab***ef')); }); it('"abcfef" should match "ab*+(e|f)"', () => { assert(isMatch('abcfef', 'ab*+(e|f)')); }); it('"abcfef" should not match "ab*d+(e|f)"', () => { assert(!isMatch('abcfef', 'ab*d+(e|f)')); }); it('"abcfef" should match "ab?*(e|f)"', () => { assert(isMatch('abcfef', 'ab?*(e|f)')); }); it('"abcfefg" should match "(a+|b)*"', () => { assert(isMatch('abcfefg', '(a+|b)*')); }); it('"abcfefg" should not match "(a+|b)+"', () => { assert(!isMatch('abcfefg', '(a+|b)+')); }); it('"abcfefg" should not match "*?(a)bc"', () => { assert(!isMatch('abcfefg', '*?(a)bc')); }); it('"abcfefg" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('abcfefg', 'a(b*(foo|bar))d')); }); it('"abcfefg" should not match "ab*(e|f)"', () => { assert(!isMatch('abcfefg', 'ab*(e|f)')); }); it('"abcfefg" should match "ab**"', () => { assert(isMatch('abcfefg', 'ab**')); }); it('"abcfefg" should match "ab**(e|f)"', () => { assert(isMatch('abcfefg', 'ab**(e|f)')); }); it('"abcfefg" should match "ab**(e|f)g"', () => { assert(isMatch('abcfefg', 'ab**(e|f)g')); }); it('"abcfefg" should not match "ab***ef"', () => { assert(!isMatch('abcfefg', 'ab***ef')); }); it('"abcfefg" should not match "ab*+(e|f)"', () => { assert(!isMatch('abcfefg', 'ab*+(e|f)')); }); it('"abcfefg" should not match "ab*d+(e|f)"', () => { assert(!isMatch('abcfefg', 'ab*d+(e|f)')); }); it('"abcfefg" should not match "ab?*(e|f)"', () => { assert(!isMatch('abcfefg', 'ab?*(e|f)')); }); it('"abcx" should match "!([[*])*"', () => { assert(isMatch('abcx', '!([[*])*')); }); it('"abcx" should match "+(a|b\\[)*"', () => { assert(isMatch('abcx', '+(a|b\\[)*')); }); it('"abcx" should not match "[a*(]*z"', () => { assert(!isMatch('abcx', '[a*(]*z')); }); it('"abcXdefXghi" should match "*X*i"', () => { assert(isMatch('abcXdefXghi', '*X*i')); }); it('"abcz" should match "!([[*])*"', () => { assert(isMatch('abcz', '!([[*])*')); }); it('"abcz" should match "+(a|b\\[)*"', () => { assert(isMatch('abcz', '+(a|b\\[)*')); }); it('"abcz" should match "[a*(]*z"', () => { assert(isMatch('abcz', '[a*(]*z')); }); it('"abd" should match "(a+|b)*"', () => { assert(isMatch('abd', '(a+|b)*')); }); it('"abd" should not match "(a+|b)+"', () => { assert(!isMatch('abd', '(a+|b)+')); }); it('"abd" should not match "*?(a)bc"', () => { assert(!isMatch('abd', '*?(a)bc')); }); it('"abd" should match "a!(*(b|B))"', () => { assert(isMatch('abd', 'a!(*(b|B))')); }); it('"abd" should match "a!(@(b|B))"', () => { assert(isMatch('abd', 'a!(@(b|B))')); }); it('"abd" should not match "a!(@(b|B))d"', () => { assert(!isMatch('abd', 'a!(@(b|B))d')); }); it('"abd" should match "a(b*(foo|bar))d"', () => { assert(isMatch('abd', 'a(b*(foo|bar))d')); }); it('"abd" should match "a+(b|c)d"', () => { assert(isMatch('abd', 'a+(b|c)d')); }); it('"abd" should match "a[b*(foo|bar)]d"', () => { assert(isMatch('abd', 'a[b*(foo|bar)]d')); }); it('"abd" should not match "ab*(e|f)"', () => { assert(!isMatch('abd', 'ab*(e|f)')); }); it('"abd" should match "ab**"', () => { assert(isMatch('abd', 'ab**')); }); it('"abd" should match "ab**(e|f)"', () => { assert(isMatch('abd', 'ab**(e|f)')); }); it('"abd" should not match "ab**(e|f)g"', () => { assert(!isMatch('abd', 'ab**(e|f)g')); }); it('"abd" should not match "ab***ef"', () => { assert(!isMatch('abd', 'ab***ef')); }); it('"abd" should not match "ab*+(e|f)"', () => { assert(!isMatch('abd', 'ab*+(e|f)')); }); it('"abd" should not match "ab*d+(e|f)"', () => { assert(!isMatch('abd', 'ab*d+(e|f)')); }); it('"abd" should match "ab?*(e|f)"', () => { assert(isMatch('abd', 'ab?*(e|f)')); }); it('"abef" should match "(a+|b)*"', () => { assert(isMatch('abef', '(a+|b)*')); }); it('"abef" should not match "(a+|b)+"', () => { assert(!isMatch('abef', '(a+|b)+')); }); it('"abef" should not match "*(a+|b)"', () => { assert(!isMatch('abef', '*(a+|b)')); }); it('"abef" should not match "*?(a)bc"', () => { assert(!isMatch('abef', '*?(a)bc')); }); it('"abef" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('abef', 'a(b*(foo|bar))d')); }); it('"abef" should match "ab*(e|f)"', () => { assert(isMatch('abef', 'ab*(e|f)')); }); it('"abef" should match "ab**"', () => { assert(isMatch('abef', 'ab**')); }); it('"abef" should match "ab**(e|f)"', () => { assert(isMatch('abef', 'ab**(e|f)')); }); it('"abef" should not match "ab**(e|f)g"', () => { assert(!isMatch('abef', 'ab**(e|f)g')); }); it('"abef" should match "ab***ef"', () => { assert(isMatch('abef', 'ab***ef')); }); it('"abef" should match "ab*+(e|f)"', () => { assert(isMatch('abef', 'ab*+(e|f)')); }); it('"abef" should not match "ab*d+(e|f)"', () => { assert(!isMatch('abef', 'ab*d+(e|f)')); }); it('"abef" should match "ab?*(e|f)"', () => { assert(isMatch('abef', 'ab?*(e|f)')); }); it('"abz" should not match "a!(*)"', () => { assert(!isMatch('abz', 'a!(*)')); }); it('"abz" should match "a!(z)"', () => { assert(isMatch('abz', 'a!(z)')); }); it('"abz" should match "a*!(z)"', () => { assert(isMatch('abz', 'a*!(z)')); }); it('"abz" should not match "a*(z)"', () => { assert(!isMatch('abz', 'a*(z)')); }); it('"abz" should match "a**(z)"', () => { assert(isMatch('abz', 'a**(z)')); }); it('"abz" should match "a*@(z)"', () => { assert(isMatch('abz', 'a*@(z)')); }); it('"abz" should not match "a+(z)"', () => { assert(!isMatch('abz', 'a+(z)')); }); it('"abz" should not match "a?(z)"', () => { assert(!isMatch('abz', 'a?(z)')); }); it('"abz" should not match "a@(z)"', () => { assert(!isMatch('abz', 'a@(z)')); }); it('"ac" should not match "!(a)*"', () => { assert(!isMatch('ac', '!(a)*')); }); it('"ac" should match "*(@(a))a@(c)"', () => { assert(isMatch('ac', '*(@(a))a@(c)')); }); it('"ac" should match "a!(*(b|B))"', () => { assert(isMatch('ac', 'a!(*(b|B))')); }); it('"ac" should match "a!(@(b|B))"', () => { assert(isMatch('ac', 'a!(@(b|B))')); }); it('"ac" should match "a!(b)*"', () => { assert(isMatch('ac', 'a!(b)*')); }); it('"accdef" should match "(a+|b)*"', () => { assert(isMatch('accdef', '(a+|b)*')); }); it('"accdef" should not match "(a+|b)+"', () => { assert(!isMatch('accdef', '(a+|b)+')); }); it('"accdef" should not match "*?(a)bc"', () => { assert(!isMatch('accdef', '*?(a)bc')); }); it('"accdef" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('accdef', 'a(b*(foo|bar))d')); }); it('"accdef" should not match "ab*(e|f)"', () => { assert(!isMatch('accdef', 'ab*(e|f)')); }); it('"accdef" should not match "ab**"', () => { assert(!isMatch('accdef', 'ab**')); }); it('"accdef" should not match "ab**(e|f)"', () => { assert(!isMatch('accdef', 'ab**(e|f)')); }); it('"accdef" should not match "ab**(e|f)g"', () => { assert(!isMatch('accdef', 'ab**(e|f)g')); }); it('"accdef" should not match "ab***ef"', () => { assert(!isMatch('accdef', 'ab***ef')); }); it('"accdef" should not match "ab*+(e|f)"', () => { assert(!isMatch('accdef', 'ab*+(e|f)')); }); it('"accdef" should not match "ab*d+(e|f)"', () => { assert(!isMatch('accdef', 'ab*d+(e|f)')); }); it('"accdef" should not match "ab?*(e|f)"', () => { assert(!isMatch('accdef', 'ab?*(e|f)')); }); it('"acd" should match "(a+|b)*"', () => { assert(isMatch('acd', '(a+|b)*')); }); it('"acd" should not match "(a+|b)+"', () => { assert(!isMatch('acd', '(a+|b)+')); }); it('"acd" should not match "*?(a)bc"', () => { assert(!isMatch('acd', '*?(a)bc')); }); it('"acd" should match "@(ab|a*(b))*(c)d"', () => { assert(isMatch('acd', '@(ab|a*(b))*(c)d')); }); it('"acd" should match "a!(*(b|B))"', () => { assert(isMatch('acd', 'a!(*(b|B))')); }); it('"acd" should match "a!(@(b|B))"', () => { assert(isMatch('acd', 'a!(@(b|B))')); }); it('"acd" should match "a!(@(b|B))d"', () => { assert(isMatch('acd', 'a!(@(b|B))d')); }); it('"acd" should not match "a(b*(foo|bar))d"', () => { assert(!isMatch('acd', 'a(b*(foo|bar))d')); }); it('"acd" should match "a+(b|c)d"', () => { assert(isMatch('acd', 'a+(b|c)d')); }); it('"acd" should not match "a[b*(foo|bar)]d"', () => { assert(!isMatch('acd', 'a[b*(foo|bar)]d')); }); it('"acd" should not match "ab*(e|f)"', () => { assert(!isMatch('acd', 'ab*(e|f)')); }); it('"acd" should not match "ab**"', () => { assert(!isMatch('acd', 'ab**')); }); it('"acd" should not match "ab**(e|f)"', () => { assert(!isMatch('acd', 'ab**(e|f)')); }); it('"acd" should not match "ab**(e|f)g"', () => { assert(!isMatch('acd', 'ab**(e|f)g')); }); it('"acd" should not match "ab***ef"', () => { assert(!isMatch('acd', 'ab***ef')); }); it('"acd" should not match "ab*+(e|f)"', () => { assert(!isMatch('acd', 'ab*+(e|f)')); }); it('"acd" should not match "ab*d+(e|f)"', () => { assert(!isMatch('acd', 'ab*d+(e|f)')); }); it('"acd" should not match "ab?*(e|f)"', () => { assert(!isMatch('acd', 'ab?*(e|f)')); }); it('"ax" should match "?(a*|b)"', () => { assert(isMatch('ax', '?(a*|b)')); }); it('"ax" should not match "a?(b*)"', () => { assert(!isMatch('ax', 'a?(b*)')); }); it('"axz" should not match "a+(z)"', () => { assert(!isMatch('axz', 'a+(z)')); }); it('"az" should not match "a!(*)"', () => { assert(!isMatch('az', 'a!(*)')); }); it('"az" should not match "a!(z)"', () => { assert(!isMatch('az', 'a!(z)')); }); it('"az" should match "a*!(z)"', () => { assert(isMatch('az', 'a*!(z)')); }); it('"az" should match "a*(z)"', () => { assert(isMatch('az', 'a*(z)')); }); it('"az" should match "a**(z)"', () => { assert(isMatch('az', 'a**(z)')); }); it('"az" should match "a*@(z)"', () => { assert(isMatch('az', 'a*@(z)')); }); it('"az" should match "a+(z)"', () => { assert(isMatch('az', 'a+(z)')); }); it('"az" should match "a?(z)"', () => { assert(isMatch('az', 'a?(z)')); }); it('"az" should match "a@(z)"', () => { assert(isMatch('az', 'a@(z)')); }); it('"az" should not match "a\\z"', () => { assert(!isMatch('az', 'a\\\\z', { windows: false })); }); it('"az" should not match "a\\z"', () => { assert(!isMatch('az', 'a\\\\z')); }); it('"b" should match "!(a)*"', () => { assert(isMatch('b', '!(a)*')); }); it('"b" should match "(a+|b)*"', () => { assert(isMatch('b', '(a+|b)*')); }); it('"b" should not match "a!(b)*"', () => { assert(!isMatch('b', 'a!(b)*')); }); it('"b.a" should match "(b|a).(a)"', () => { assert(isMatch('b.a', '(b|a).(a)')); }); it('"b.a" should match "@(b|a).@(a)"', () => { assert(isMatch('b.a', '@(b|a).@(a)')); }); it('"b/a" should not match "!(b/a)"', () => { assert(!isMatch('b/a', '!(b/a)')); }); it('"b/b" should match "!(b/a)"', () => { assert(isMatch('b/b', '!(b/a)')); }); it('"b/c" should match "!(b/a)"', () => { assert(isMatch('b/c', '!(b/a)')); }); it('"b/c" should not match "b/!(c)"', () => { assert(!isMatch('b/c', 'b/!(c)')); }); it('"b/c" should match "b/!(cc)"', () => { assert(isMatch('b/c', 'b/!(cc)')); }); it('"b/c.txt" should not match "b/!(c).txt"', () => { assert(!isMatch('b/c.txt', 'b/!(c).txt')); }); it('"b/c.txt" should match "b/!(cc).txt"', () => { assert(isMatch('b/c.txt', 'b/!(cc).txt')); }); it('"b/cc" should match "b/!(c)"', () => { assert(isMatch('b/cc', 'b/!(c)')); }); it('"b/cc" should not match "b/!(cc)"', () => { assert(!isMatch('b/cc', 'b/!(cc)')); }); it('"b/cc.txt" should not match "b/!(c).txt"', () => { assert(!isMatch('b/cc.txt', 'b/!(c).txt')); }); it('"b/cc.txt" should not match "b/!(cc).txt"', () => { assert(!isMatch('b/cc.txt', 'b/!(cc).txt')); }); it('"b/ccc" should match "b/!(c)"', () => { assert(isMatch('b/ccc', 'b/!(c)')); }); it('"ba" should match "!(a!(b))"', () => { assert(isMatch('ba', '!(a!(b))')); }); it('"ba" should match "b?(a|b)"', () => { assert(isMatch('ba', 'b?(a|b)')); }); it('"baaac" should not match "*(@(a))a@(c)"', () => { assert(!isMatch('baaac', '*(@(a))a@(c)')); }); it('"bar" should match "!(foo)"', () => { assert(isMatch('bar', '!(foo)')); }); it('"bar" should match "!(foo)*"', () => { assert(isMatch('bar', '!(foo)*')); }); it('"bar" should match "!(foo)b*"', () => { assert(isMatch('bar', '!(foo)b*')); }); it('"bar" should match "*(!(foo))"', () => { assert(isMatch('bar', '*(!(foo))')); }); it('"baz" should match "!(foo)*"', () => { assert(isMatch('baz', '!(foo)*')); }); it('"baz" should match "!(foo)b*"', () => { assert(isMatch('baz', '!(foo)b*')); }); it('"baz" should match "*(!(foo))"', () => { assert(isMatch('baz', '*(!(foo))')); }); it('"bb" should match "!(a!(b))"', () => { assert(isMatch('bb', '!(a!(b))')); }); it('"bb" should match "!(a)*"', () => { assert(isMatch('bb', '!(a)*')); }); it('"bb" should not match "a!(b)*"', () => { assert(!isMatch('bb', 'a!(b)*')); }); it('"bb" should not match "a?(a|b)"', () => { assert(!isMatch('bb', 'a?(a|b)')); }); it('"bbc" should match "!([[*])*"', () => { assert(isMatch('bbc', '!([[*])*')); }); it('"bbc" should not match "+(a|b\\[)*"', () => { assert(!isMatch('bbc', '+(a|b\\[)*')); }); it('"bbc" should not match "[a*(]*z"', () => { assert(!isMatch('bbc', '[a*(]*z')); }); it('"bz" should not match "a+(z)"', () => { assert(!isMatch('bz', 'a+(z)')); }); it('"c" should not match "*(@(a))a@(c)"', () => { assert(!isMatch('c', '*(@(a))a@(c)')); }); it('"c.a" should not match "!(*.[a-b]*)"', () => { assert(!isMatch('c.a', '!(*.[a-b]*)')); }); it('"c.a" should match "!(*[a-b].[a-b]*)"', () => { assert(isMatch('c.a', '!(*[a-b].[a-b]*)')); }); it('"c.a" should not match "!*.(a|b)"', () => { assert(!isMatch('c.a', '!*.(a|b)')); }); it('"c.a" should not match "!*.(a|b)*"', () => { assert(!isMatch('c.a', '!*.(a|b)*')); }); it('"c.a" should not match "(b|a).(a)"', () => { assert(!isMatch('c.a', '(b|a).(a)')); }); it('"c.a" should not match "*.!(a)"', () => { assert(!isMatch('c.a', '*.!(a)')); }); it('"c.a" should not match "*.+(b|d)"', () => { assert(!isMatch('c.a', '*.+(b|d)')); }); it('"c.a" should not match "@(b|a).@(a)"', () => { assert(!isMatch('c.a', '@(b|a).@(a)')); }); it('"c.c" should not match "!(*.a|*.b|*.c)"', () => { assert(!isMatch('c.c', '!(*.a|*.b|*.c)')); }); it('"c.c" should match "*!(.a|.b|.c)"', () => { assert(isMatch('c.c', '*!(.a|.b|.c)')); }); it('"c.c" should not match "*.!(a|b|c)"', () => { assert(!isMatch('c.c', '*.!(a|b|c)')); }); it('"c.c" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(!isMatch('c.c', '*.(a|b|@(ab|a*@(b))*(c)d)')); }); it('"c.ccc" should match "!(*.[a-b]*)"', () => { assert(isMatch('c.ccc', '!(*.[a-b]*)')); }); it('"c.ccc" should match "!(*[a-b].[a-b]*)"', () => { assert(isMatch('c.ccc', '!(*[a-b].[a-b]*)')); }); it('"c.js" should not match "!(*.js)"', () => { assert(!isMatch('c.js', '!(*.js)')); }); it('"c.js" should match "*!(.js)"', () => { assert(isMatch('c.js', '*!(.js)')); }); it('"c.js" should not match "*.!(js)"', () => { assert(!isMatch('c.js', '*.!(js)')); }); it('"c/a/v" should match "c/!(z)/v"', () => { assert(isMatch('c/a/v', 'c/!(z)/v')); }); it('"c/a/v" should not match "c/*(z)/v"', () => { assert(!isMatch('c/a/v', 'c/*(z)/v')); }); it('"c/a/v" should not match "c/+(z)/v"', () => { assert(!isMatch('c/a/v', 'c/+(z)/v')); }); it('"c/a/v" should not match "c/@(z)/v"', () => { assert(!isMatch('c/a/v', 'c/@(z)/v')); }); it('"c/z/v" should not match "*(z)"', () => { assert(!isMatch('c/z/v', '*(z)')); }); it('"c/z/v" should not match "+(z)"', () => { assert(!isMatch('c/z/v', '+(z)')); }); it('"c/z/v" should not match "?(z)"', () => { assert(!isMatch('c/z/v', '?(z)')); }); it('"c/z/v" should not match "c/!(z)/v"', () => { assert(!isMatch('c/z/v', 'c/!(z)/v')); }); it('"c/z/v" should match "c/*(z)/v"', () => { assert(isMatch('c/z/v', 'c/*(z)/v')); }); it('"c/z/v" should match "c/+(z)/v"', () => { assert(isMatch('c/z/v', 'c/+(z)/v')); }); it('"c/z/v" should match "c/@(z)/v"', () => { assert(isMatch('c/z/v', 'c/@(z)/v')); }); it('"c/z/v" should match "c/z/v"', () => { assert(isMatch('c/z/v', 'c/z/v')); }); it('"cc.a" should not match "(b|a).(a)"', () => { assert(!isMatch('cc.a', '(b|a).(a)')); }); it('"cc.a" should not match "@(b|a).@(a)"', () => { assert(!isMatch('cc.a', '@(b|a).@(a)')); }); it('"ccc" should match "!(a)*"', () => { assert(isMatch('ccc', '!(a)*')); }); it('"ccc" should not match "a!(b)*"', () => { assert(!isMatch('ccc', 'a!(b)*')); }); it('"cow" should match "!(*.*)"', () => { assert(isMatch('cow', '!(*.*)')); }); it('"cow" should not match "!(*.*)."', () => { assert(!isMatch('cow', '!(*.*).')); }); it('"cow" should not match ".!(*.*)"', () => { assert(!isMatch('cow', '.!(*.*)')); }); it('"cz" should not match "a!(*)"', () => { assert(!isMatch('cz', 'a!(*)')); }); it('"cz" should not match "a!(z)"', () => { assert(!isMatch('cz', 'a!(z)')); }); it('"cz" should not match "a*!(z)"', () => { assert(!isMatch('cz', 'a*!(z)')); }); it('"cz" should not match "a*(z)"', () => { assert(!isMatch('cz', 'a*(z)')); }); it('"cz" should not match "a**(z)"', () => { assert(!isMatch('cz', 'a**(z)')); }); it('"cz" should not match "a*@(z)"', () => { assert(!isMatch('cz', 'a*@(z)')); }); it('"cz" should not match "a+(z)"', () => { assert(!isMatch('cz', 'a+(z)')); }); it('"cz" should not match "a?(z)"', () => { assert(!isMatch('cz', 'a?(z)')); }); it('"cz" should not match "a@(z)"', () => { assert(!isMatch('cz', 'a@(z)')); }); it('"d.a.d" should not match "!(*.[a-b]*)"', () => { assert(!isMatch('d.a.d', '!(*.[a-b]*)')); }); it('"d.a.d" should match "!(*[a-b].[a-b]*)"', () => { assert(isMatch('d.a.d', '!(*[a-b].[a-b]*)')); }); it('"d.a.d" should not match "!*.(a|b)*"', () => { assert(!isMatch('d.a.d', '!*.(a|b)*')); }); it('"d.a.d" should match "!*.*(a|b)"', () => { assert(isMatch('d.a.d', '!*.*(a|b)')); }); it('"d.a.d" should not match "!*.{a,b}*"', () => { assert(!isMatch('d.a.d', '!*.{a,b}*')); }); it('"d.a.d" should match "*.!(a)"', () => { assert(isMatch('d.a.d', '*.!(a)')); }); it('"d.a.d" should match "*.+(b|d)"', () => { assert(isMatch('d.a.d', '*.+(b|d)')); }); it('"d.d" should match "!(*.a|*.b|*.c)"', () => { assert(isMatch('d.d', '!(*.a|*.b|*.c)')); }); it('"d.d" should match "*!(.a|.b|.c)"', () => { assert(isMatch('d.d', '*!(.a|.b|.c)')); }); it('"d.d" should match "*.!(a|b|c)"', () => { assert(isMatch('d.d', '*.!(a|b|c)')); }); it('"d.d" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(!isMatch('d.d', '*.(a|b|@(ab|a*@(b))*(c)d)')); }); it('"d.js.d" should match "!(*.js)"', () => { assert(isMatch('d.js.d', '!(*.js)')); }); it('"d.js.d" should match "*!(.js)"', () => { assert(isMatch('d.js.d', '*!(.js)')); }); it('"d.js.d" should match "*.!(js)"', () => { assert(isMatch('d.js.d', '*.!(js)')); }); it('"dd.aa.d" should not match "(b|a).(a)"', () => { assert(!isMatch('dd.aa.d', '(b|a).(a)')); }); it('"dd.aa.d" should not match "@(b|a).@(a)"', () => { assert(!isMatch('dd.aa.d', '@(b|a).@(a)')); }); it('"def" should not match "()ef"', () => { assert(!isMatch('def', '()ef')); }); it('"e.e" should match "!(*.a|*.b|*.c)"', () => { assert(isMatch('e.e', '!(*.a|*.b|*.c)')); }); it('"e.e" should match "*!(.a|.b|.c)"', () => { assert(isMatch('e.e', '*!(.a|.b|.c)')); }); it('"e.e" should match "*.!(a|b|c)"', () => { assert(isMatch('e.e', '*.!(a|b|c)')); }); it('"e.e" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(!isMatch('e.e', '*.(a|b|@(ab|a*@(b))*(c)d)')); }); it('"ef" should match "()ef"', () => { assert(isMatch('ef', '()ef')); }); it('"effgz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { assert(isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))')); }); it('"efgz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { assert(isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))')); }); it('"egz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { assert(isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))')); }); it('"egz" should not match "@(b+(c)d|e+(f)g?|?(h)i@(j|k))"', () => { assert(!isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))')); }); it('"egzefffgzbcdij" should match "*(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { assert(isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))')); }); it('"f" should not match "!(f!(o))"', () => { assert(!isMatch('f', '!(f!(o))')); }); it('"f" should match "!(f(o))"', () => { assert(isMatch('f', '!(f(o))')); }); it('"f" should not match "!(f)"', () => { assert(!isMatch('f', '!(f)')); }); it('"f" should not match "*(!(f))"', () => { assert(!isMatch('f', '*(!(f))')); }); it('"f" should not match "+(!(f))"', () => { assert(!isMatch('f', '+(!(f))')); }); it('"f.a" should not match "!(*.a|*.b|*.c)"', () => { assert(!isMatch('f.a', '!(*.a|*.b|*.c)')); }); it('"f.a" should match "*!(.a|.b|.c)"', () => { assert(isMatch('f.a', '*!(.a|.b|.c)')); }); it('"f.a" should not match "*.!(a|b|c)"', () => { assert(!isMatch('f.a', '*.!(a|b|c)')); }); it('"f.f" should match "!(*.a|*.b|*.c)"', () => { assert(isMatch('f.f', '!(*.a|*.b|*.c)')); }); it('"f.f" should match "*!(.a|.b|.c)"', () => { assert(isMatch('f.f', '*!(.a|.b|.c)')); }); it('"f.f" should match "*.!(a|b|c)"', () => { assert(isMatch('f.f', '*.!(a|b|c)')); }); it('"f.f" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { assert(!isMatch('f.f', '*.(a|b|@(ab|a*@(b))*(c)d)')); }); it('"fa" should not match "!(f!(o))"', () => { assert(!isMatch('fa', '!(f!(o))')); }); it('"fa" should match "!(f(o))"', () => { assert(isMatch('fa', '!(f(o))')); }); it('"fb" should not match "!(f!(o))"', () => { assert(!isMatch('fb', '!(f!(o))')); }); it('"fb" should match "!(f(o))"', () => { assert(isMatch('fb', '!(f(o))')); }); it('"fff" should match "!(f)"', () => { assert(isMatch('fff', '!(f)')); }); it('"fff" should match "*(!(f))"', () => { assert(isMatch('fff', '*(!(f))')); }); it('"fff" should match "+(!(f))"', () => { assert(isMatch('fff', '+(!(f))')); }); it('"fffooofoooooffoofffooofff" should match "*(*(f)*(o))"', () => { assert(isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))')); }); it('"ffo" should match "*(f*(o))"', () => { assert(isMatch('ffo', '*(f*(o))')); }); it('"file.C" should not match "*.c?(c)"', () => { assert(!isMatch('file.C', '*.c?(c)')); }); it('"file.c" should match "*.c?(c)"', () => { assert(isMatch('file.c', '*.c?(c)')); }); it('"file.cc" should match "*.c?(c)"', () => { assert(isMatch('file.cc', '*.c?(c)')); }); it('"file.ccc" should not match "*.c?(c)"', () => { assert(!isMatch('file.ccc', '*.c?(c)')); }); it('"fo" should match "!(f!(o))"', () => { assert(isMatch('fo', '!(f!(o))')); }); it('"fo" should not match "!(f(o))"', () => { assert(!isMatch('fo', '!(f(o))')); }); it('"fofo" should match "*(f*(o))"', () => { assert(isMatch('fofo', '*(f*(o))')); }); it('"fofoofoofofoo" should match "*(fo|foo)"', () => { assert(isMatch('fofoofoofofoo', '*(fo|foo)')); }); it('"fofoofoofofoo" should match "*(fo|foo)"', () => { assert(isMatch('fofoofoofofoo', '*(fo|foo)')); }); it('"foo" should match "!(!(foo))"', () => { assert(isMatch('foo', '!(!(foo))')); }); it('"foo" should match "!(f)"', () => { assert(isMatch('foo', '!(f)')); }); it('"foo" should not match "!(foo)"', () => { assert(!isMatch('foo', '!(foo)')); }); it('"foo" should not match "!(foo)*"', () => { assert(!isMatch('foo', '!(foo)*')); }); it('"foo" should not match "!(foo)*"', () => { assert(!isMatch('foo', '!(foo)*')); }); it('"foo" should not match "!(foo)+"', () => { assert(!isMatch('foo', '!(foo)+')); }); it('"foo" should not match "!(foo)b*"', () => { assert(!isMatch('foo', '!(foo)b*')); }); it('"foo" should match "!(x)"', () => { assert(isMatch('foo', '!(x)')); }); it('"foo" should match "!(x)*"', () => { assert(isMatch('foo', '!(x)*')); }); it('"foo" should match "*"', () => { assert(isMatch('foo', '*')); }); it('"foo" should match "*(!(f))"', () => { assert(isMatch('foo', '*(!(f))')); }); it('"foo" should not match "*(!(foo))"', () => { assert(!isMatch('foo', '*(!(foo))')); }); it('"foo" should not match "*(@(a))a@(c)"', () => { assert(!isMatch('foo', '*(@(a))a@(c)')); }); it('"foo" should match "*(@(foo))"', () => { assert(isMatch('foo', '*(@(foo))')); }); it('"foo" should not match "*(a|b\\[)"', () => { assert(!isMatch('foo', '*(a|b\\[)')); }); it('"foo" should match "*(a|b\\[)|f*"', () => { assert(isMatch('foo', '*(a|b\\[)|f*')); }); it('"foo" should match "@(*(a|b\\[)|f*)"', () => { assert(isMatch('foo', '@(*(a|b\\[)|f*)')); }); it('"foo" should not match "*/*/*"', () => { assert(!isMatch('foo', '*/*/*')); }); it('"foo" should not match "*f"', () => { assert(!isMatch('foo', '*f')); }); it('"foo" should match "*foo*"', () => { assert(isMatch('foo', '*foo*')); }); it('"foo" should match "+(!(f))"', () => { assert(isMatch('foo', '+(!(f))')); }); it('"foo" should not match "??"', () => { assert(!isMatch('foo', '??')); }); it('"foo" should match "???"', () => { assert(isMatch('foo', '???')); }); it('"foo" should not match "bar"', () => { assert(!isMatch('foo', 'bar')); }); it('"foo" should match "f*"', () => { assert(isMatch('foo', 'f*')); }); it('"foo" should not match "fo"', () => { assert(!isMatch('foo', 'fo')); }); it('"foo" should match "foo"', () => { assert(isMatch('foo', 'foo')); }); it('"foo" should match "{*(a|b\\[),f*}"', () => { assert(isMatch('foo', '{*(a|b\\[),f*}')); }); it('"foo*" should match "foo\\*"', () => { assert(isMatch('foo*', 'foo\\*', { windows: false })); }); it('"foo*bar" should match "foo\\*bar"', () => { assert(isMatch('foo*bar', 'foo\\*bar')); }); it('"foo.js" should not match "!(foo).js"', () => { assert(!isMatch('foo.js', '!(foo).js')); }); it('"foo.js.js" should match "*.!(js)"', () => { assert(isMatch('foo.js.js', '*.!(js)')); }); it('"foo.js.js" should not match "*.!(js)*"', () => { assert(!isMatch('foo.js.js', '*.!(js)*')); }); it('"foo.js.js" should not match "*.!(js)*.!(js)"', () => { assert(!isMatch('foo.js.js', '*.!(js)*.!(js)')); }); it('"foo.js.js" should not match "*.!(js)+"', () => { assert(!isMatch('foo.js.js', '*.!(js)+')); }); it('"foo.txt" should match "**/!(bar).txt"', () => { assert(isMatch('foo.txt', '**/!(bar).txt')); }); it('"foo/bar" should not match "*/*/*"', () => { assert(!isMatch('foo/bar', '*/*/*')); }); it('"foo/bar" should match "foo/!(foo)"', () => { assert(isMatch('foo/bar', 'foo/!(foo)')); }); it('"foo/bar" should match "foo/*"', () => { assert(isMatch('foo/bar', 'foo/*')); }); it('"foo/bar" should match "foo/bar"', () => { assert(isMatch('foo/bar', 'foo/bar')); }); it('"foo/bar" should not match "foo?bar"', () => { assert(!isMatch('foo/bar', 'foo?bar')); }); it('"foo/bar" should match "foo[/]bar"', () => { assert(isMatch('foo/bar', 'foo[/]bar')); }); it('"foo/bar/baz.jsx" should match "foo/bar/**/*.+(js|jsx)"', () => { assert(isMatch('foo/bar/baz.jsx', 'foo/bar/**/*.+(js|jsx)')); }); it('"foo/bar/baz.jsx" should match "foo/bar/*.+(js|jsx)"', () => { assert(isMatch('foo/bar/baz.jsx', 'foo/bar/*.+(js|jsx)')); }); it('"foo/bb/aa/rr" should match "**/**/**"', () => { assert(isMatch('foo/bb/aa/rr', '**/**/**')); }); it('"foo/bb/aa/rr" should not match "*/*/*"', () => { assert(!isMatch('foo/bb/aa/rr', '*/*/*')); }); it('"foo/bba/arr" should match "*/*/*"', () => { assert(isMatch('foo/bba/arr', '*/*/*')); }); it('"foo/bba/arr" should not match "foo*"', () => { assert(!isMatch('foo/bba/arr', 'foo*')); }); it('"foo/bba/arr" should not match "foo**"', () => { assert(!isMatch('foo/bba/arr', 'foo**')); }); it('"foo/bba/arr" should not match "foo/*"', () => { assert(!isMatch('foo/bba/arr', 'foo/*')); }); it('"foo/bba/arr" should match "foo/**"', () => { assert(isMatch('foo/bba/arr', 'foo/**')); }); it('"foo/bba/arr" should not match "foo/**arr"', () => { assert(!isMatch('foo/bba/arr', 'foo/**arr')); }); it('"foo/bba/arr" should not match "foo/**z"', () => { assert(!isMatch('foo/bba/arr', 'foo/**z')); }); it('"foo/bba/arr" should not match "foo/*arr"', () => { assert(!isMatch('foo/bba/arr', 'foo/*arr')); }); it('"foo/bba/arr" should not match "foo/*z"', () => { assert(!isMatch('foo/bba/arr', 'foo/*z')); }); it('"foob" should not match "!(foo)b*"', () => { assert(!isMatch('foob', '!(foo)b*')); }); it('"foob" should not match "(foo)bb"', () => { assert(!isMatch('foob', '(foo)bb')); }); it('"foobar" should match "!(foo)"', () => { assert(isMatch('foobar', '!(foo)')); }); it('"foobar" should not match "!(foo)*"', () => { assert(!isMatch('foobar', '!(foo)*')); }); it('"foobar" should not match "!(foo)*"', () => { assert(!isMatch('foobar', '!(foo)*')); }); it('"foobar" should not match "!(foo)b*"', () => { assert(!isMatch('foobar', '!(foo)b*')); }); it('"foobar" should match "*(!(foo))"', () => { assert(isMatch('foobar', '*(!(foo))')); }); it('"foobar" should match "*ob*a*r*"', () => { assert(isMatch('foobar', '*ob*a*r*')); }); it('"foobar" should not match "foo\\*bar"', () => { assert(!isMatch('foobar', 'foo\\*bar')); }); it('"foobb" should not match "!(foo)b*"', () => { assert(!isMatch('foobb', '!(foo)b*')); }); it('"foobb" should match "(foo)bb"', () => { assert(isMatch('foobb', '(foo)bb')); }); it('"(foo)bb" should match "\\(foo\\)bb"', () => { assert(isMatch('(foo)bb', '\\(foo\\)bb')); }); it('"foofoofo" should match "@(foo|f|fo)*(f|of+(o))"', () => { assert(isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))')); }); it('"foofoofo" should match "@(foo|f|fo)*(f|of+(o))"', () => { assert(isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))')); }); it('"fooofoofofooo" should match "*(f*(o))"', () => { assert(isMatch('fooofoofofooo', '*(f*(o))')); }); it('"foooofo" should match "*(f*(o))"', () => { assert(isMatch('foooofo', '*(f*(o))')); }); it('"foooofof" should match "*(f*(o))"', () => { assert(isMatch('foooofof', '*(f*(o))')); }); it('"foooofof" should not match "*(f+(o))"', () => { assert(!isMatch('foooofof', '*(f+(o))')); }); it('"foooofofx" should not match "*(f*(o))"', () => { assert(!isMatch('foooofofx', '*(f*(o))')); }); it('"foooxfooxfoxfooox" should match "*(f*(o)x)"', () => { assert(isMatch('foooxfooxfoxfooox', '*(f*(o)x)')); }); it('"foooxfooxfxfooox" should match "*(f*(o)x)"', () => { assert(isMatch('foooxfooxfxfooox', '*(f*(o)x)')); }); it('"foooxfooxofoxfooox" should not match "*(f*(o)x)"', () => { assert(!isMatch('foooxfooxofoxfooox', '*(f*(o)x)')); }); it('"foot" should match "@(!(z*)|*x)"', () => { assert(isMatch('foot', '@(!(z*)|*x)')); }); it('"foox" should match "@(!(z*)|*x)"', () => { assert(isMatch('foox', '@(!(z*)|*x)')); }); it('"fz" should not match "*(z)"', () => { assert(!isMatch('fz', '*(z)')); }); it('"fz" should not match "+(z)"', () => { assert(!isMatch('fz', '+(z)')); }); it('"fz" should not match "?(z)"', () => { assert(!isMatch('fz', '?(z)')); }); it('"moo.cow" should not match "!(moo).!(cow)"', () => { assert(!isMatch('moo.cow', '!(moo).!(cow)')); }); it('"moo.cow" should not match "!(*).!(*)"', () => { assert(!isMatch('moo.cow', '!(*).!(*)')); }); it('"moo.cow" should not match "!(*.*).!(*.*)"', () => { assert(!isMatch('moo.cow', '!(*.*).!(*.*)')); }); it('"mad.moo.cow" should not match "!(*.*).!(*.*)"', () => { assert(!isMatch('mad.moo.cow', '!(*.*).!(*.*)')); }); it('"mad.moo.cow" should not match ".!(*.*)"', () => { assert(!isMatch('mad.moo.cow', '.!(*.*)')); }); it('"Makefile" should match "!(*.c|*.h|Makefile.in|config*|README)"', () => { assert(isMatch('Makefile', '!(*.c|*.h|Makefile.in|config*|README)')); }); it('"Makefile.in" should not match "!(*.c|*.h|Makefile.in|config*|README)"', () => { assert(!isMatch('Makefile.in', '!(*.c|*.h|Makefile.in|config*|README)')); }); it('"moo" should match "!(*.*)"', () => { assert(isMatch('moo', '!(*.*)')); }); it('"moo" should not match "!(*.*)."', () => { assert(!isMatch('moo', '!(*.*).')); }); it('"moo" should not match ".!(*.*)"', () => { assert(!isMatch('moo', '.!(*.*)')); }); it('"moo.cow" should not match "!(*.*)"', () => { assert(!isMatch('moo.cow', '!(*.*)')); }); it('"moo.cow" should not match "!(*.*)."', () => { assert(!isMatch('moo.cow', '!(*.*).')); }); it('"moo.cow" should not match ".!(*.*)"', () => { assert(!isMatch('moo.cow', '.!(*.*)')); }); it('"mucca.pazza" should not match "mu!(*(c))?.pa!(*(z))?"', () => { assert(!isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?')); }); it('"ofoofo" should match "*(of+(o))"', () => { assert(isMatch('ofoofo', '*(of+(o))')); }); it('"ofoofo" should match "*(of+(o)|f)"', () => { assert(isMatch('ofoofo', '*(of+(o)|f)')); }); it('"ofooofoofofooo" should not match "*(f*(o))"', () => { assert(!isMatch('ofooofoofofooo', '*(f*(o))')); }); it('"ofoooxoofxo" should match "*(*(of*(o)x)o)"', () => { assert(isMatch('ofoooxoofxo', '*(*(of*(o)x)o)')); }); it('"ofoooxoofxoofoooxoofxo" should match "*(*(of*(o)x)o)"', () => { assert(isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)')); }); it('"ofoooxoofxoofoooxoofxofo" should not match "*(*(of*(o)x)o)"', () => { assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)')); }); it('"ofoooxoofxoofoooxoofxoo" should match "*(*(of*(o)x)o)"', () => { assert(isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)')); }); it('"ofoooxoofxoofoooxoofxooofxofxo" should match "*(*(of*(o)x)o)"', () => { assert(isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)')); }); it('"ofxoofxo" should match "*(*(of*(o)x)o)"', () => { assert(isMatch('ofxoofxo', '*(*(of*(o)x)o)')); }); it('"oofooofo" should match "*(of|oof+(o))"', () => { assert(isMatch('oofooofo', '*(of|oof+(o))')); }); it('"ooo" should match "!(f)"', () => { assert(isMatch('ooo', '!(f)')); }); it('"ooo" should match "*(!(f))"', () => { assert(isMatch('ooo', '*(!(f))')); }); it('"ooo" should match "+(!(f))"', () => { assert(isMatch('ooo', '+(!(f))')); }); it('"oxfoxfox" should not match "*(oxf+(ox))"', () => { assert(!isMatch('oxfoxfox', '*(oxf+(ox))')); }); it('"oxfoxoxfox" should match "*(oxf+(ox))"', () => { assert(isMatch('oxfoxoxfox', '*(oxf+(ox))')); }); it('"para" should match "para*([0-9])"', () => { assert(isMatch('para', 'para*([0-9])')); }); it('"para" should not match "para+([0-9])"', () => { assert(!isMatch('para', 'para+([0-9])')); }); it('"para.38" should match "para!(*.[00-09])"', () => { assert(isMatch('para.38', 'para!(*.[00-09])')); }); it('"para.graph" should match "para!(*.[0-9])"', () => { assert(isMatch('para.graph', 'para!(*.[0-9])')); }); it('"para13829383746592" should match "para*([0-9])"', () => { assert(isMatch('para13829383746592', 'para*([0-9])')); }); it('"para381" should not match "para?([345]|99)1"', () => { assert(!isMatch('para381', 'para?([345]|99)1')); }); it('"para39" should match "para!(*.[0-9])"', () => { assert(isMatch('para39', 'para!(*.[0-9])')); }); it('"para987346523" should match "para+([0-9])"', () => { assert(isMatch('para987346523', 'para+([0-9])')); }); it('"para991" should match "para?([345]|99)1"', () => { assert(isMatch('para991', 'para?([345]|99)1')); }); it('"paragraph" should match "para!(*.[0-9])"', () => { assert(isMatch('paragraph', 'para!(*.[0-9])')); }); it('"paragraph" should not match "para*([0-9])"', () => { assert(!isMatch('paragraph', 'para*([0-9])')); }); it('"paragraph" should match "para@(chute|graph)"', () => { assert(isMatch('paragraph', 'para@(chute|graph)')); }); it('"paramour" should not match "para@(chute|graph)"', () => { assert(!isMatch('paramour', 'para@(chute|graph)')); }); it('"parse.y" should match "!(*.c|*.h|Makefile.in|config*|README)"', () => { assert(isMatch('parse.y', '!(*.c|*.h|Makefile.in|config*|README)')); }); it('"shell.c" should not match "!(*.c|*.h|Makefile.in|config*|README)"', () => { assert(!isMatch('shell.c', '!(*.c|*.h|Makefile.in|config*|README)')); }); it('"VMS.FILE;" should not match "*\\;[1-9]*([0-9])"', () => { assert(!isMatch('VMS.FILE;', '*\\;[1-9]*([0-9])')); }); it('"VMS.FILE;0" should not match "*\\;[1-9]*([0-9])"', () => { assert(!isMatch('VMS.FILE;0', '*\\;[1-9]*([0-9])')); }); it('"VMS.FILE;9" should match "*\\;[1-9]*([0-9])"', () => { assert(isMatch('VMS.FILE;9', '*\\;[1-9]*([0-9])')); }); it('"VMS.FILE;1" should match "*\\;[1-9]*([0-9])"', () => { assert(isMatch('VMS.FILE;1', '*\\;[1-9]*([0-9])')); }); it('"VMS.FILE;1" should match "*;[1-9]*([0-9])"', () => { assert(isMatch('VMS.FILE;1', '*;[1-9]*([0-9])')); }); it('"VMS.FILE;139" should match "*\\;[1-9]*([0-9])"', () => { assert(isMatch('VMS.FILE;139', '*\\;[1-9]*([0-9])')); }); it('"VMS.FILE;1N" should not match "*\\;[1-9]*([0-9])"', () => { assert(!isMatch('VMS.FILE;1N', '*\\;[1-9]*([0-9])')); }); it('"xfoooofof" should not match "*(f*(o))"', () => { assert(!isMatch('xfoooofof', '*(f*(o))')); }); it('"XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1" should match "XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*"', () => { assert(isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', { windows: false })); }); it('"XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1" should not match "XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*"', () => { assert(!isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*')); }); it('"z" should match "*(z)"', () => { assert(isMatch('z', '*(z)')); }); it('"z" should match "+(z)"', () => { assert(isMatch('z', '+(z)')); }); it('"z" should match "?(z)"', () => { assert(isMatch('z', '?(z)')); }); it('"zf" should not match "*(z)"', () => { assert(!isMatch('zf', '*(z)')); }); it('"zf" should not match "+(z)"', () => { assert(!isMatch('zf', '+(z)')); }); it('"zf" should not match "?(z)"', () => { assert(!isMatch('zf', '?(z)')); }); it('"zoot" should not match "@(!(z*)|*x)"', () => { assert(!isMatch('zoot', '@(!(z*)|*x)')); }); it('"zoox" should match "@(!(z*)|*x)"', () => { assert(isMatch('zoox', '@(!(z*)|*x)')); }); it('"zz" should not match "(a+|b)*"', () => { assert(!isMatch('zz', '(a+|b)*')); }); }); micromatch-4.0.5/test/extglobs.js000066400000000000000000002240131421714312500170140ustar00rootroot00000000000000'use strict'; const assert = require('assert'); const mm = require('..'); const { isMatch } = mm; /** * Most of these tests were converted directly from bash 4.3 and 4.4 unit tests. */ describe('extglobs', () => { it('should throw on imbalanced sets when `options.strictBrackets` is true', () => { assert.throws(() => mm.makeRe('a(b', { strictBrackets: true }), /missing closing: "\)"/i); assert.throws(() => mm.makeRe('a)b', { strictBrackets: true }), /missing opening: "\("/i); }); it('should match extglobs ending with statechar', () => { assert(!isMatch('ax', 'a?(b*)')); assert(isMatch('ax', '?(a*|b)')); }); it('should not choke on non-extglobs', () => { assert(isMatch('c/z/v', 'c/z/v')); }); it('should work with file extensions', () => { assert(!isMatch('.md', '@(a|b).md')); assert(!isMatch('a.js', '@(a|b).md')); assert(isMatch('a.md', '@(a|b).md')); assert(isMatch('b.md', '@(a|b).md')); assert(!isMatch('c.md', '@(a|b).md')); assert(!isMatch('.md', '+(a|b).md')); assert(!isMatch('a.js', '+(a|b).md')); assert(isMatch('a.md', '+(a|b).md')); assert(isMatch('aa.md', '+(a|b).md')); assert(isMatch('ab.md', '+(a|b).md')); assert(isMatch('b.md', '+(a|b).md')); assert(isMatch('bb.md', '+(a|b).md')); assert(!isMatch('c.md', '+(a|b).md')); assert(isMatch('.md', '*(a|b).md')); assert(!isMatch('a.js', '*(a|b).md')); assert(isMatch('a.md', '*(a|b).md')); assert(isMatch('aa.md', '*(a|b).md')); assert(isMatch('ab.md', '*(a|b).md')); assert(isMatch('b.md', '*(a|b).md')); assert(isMatch('bb.md', '*(a|b).md')); assert(!isMatch('c.md', '*(a|b).md')); }); it('should support !(...)', () => { // these are correct, since * is greedy and matches before ! can negate assert(isMatch('file.txt', '*!(.jpg|.gif)')); assert(isMatch('file.jpg', '*!(.jpg|.gif)')); assert(isMatch('file.gif', '*!(.jpg|.gif)')); // this is how you negate extensions assert(!isMatch('file.jpg', '!(*.jpg|*.gif)')); assert(!isMatch('file.gif', '!(*.jpg|*.gif)')); assert(!isMatch('moo.cow', '!(moo).!(cow)')); assert(!isMatch('foo.cow', '!(moo).!(cow)')); assert(!isMatch('moo.bar', '!(moo).!(cow)')); assert(isMatch('foo.bar', '!(moo).!(cow)')); assert(isMatch('moo.cow', '!(!(moo)).!(!(cow))')); assert(isMatch('moo.bar', '@(moo).!(cow)')); assert(isMatch('moomoo.bar', '+(moo).!(cow)')); assert(isMatch('moomoo.bar', '+(moo)*(foo).!(cow)')); assert(isMatch('moomoofoo.bar', '+(moo)*(foo).!(cow)')); assert(isMatch('moomoofoofoo.bar', '+(moo)*(foo).!(cow)')); assert(!isMatch('c/z/v', 'c/!(z)/v')); assert(isMatch('c/a/v', 'c/!(z)/v')); assert(!isMatch('c/z', 'a!(z)')); assert(isMatch('abz', 'a!(z)')); assert(!isMatch('az', 'a!(z)')); assert(!isMatch('a/z', 'a/!(z)')); assert(isMatch('a/b', 'a/!(z)')); assert(!isMatch('c/z', 'a*!(z)')); assert(isMatch('abz', 'a*!(z)')); assert(isMatch('az', 'a*!(z)')); assert(isMatch('a/a', '!(b/a)')); assert(isMatch('a/b', '!(b/a)')); assert(isMatch('a/c', '!(b/a)')); assert(!isMatch('b/a', '!(b/a)')); assert(isMatch('b/b', '!(b/a)')); assert(isMatch('b/c', '!(b/a)')); assert(isMatch('a/a', '!(b/a)')); assert(isMatch('a/b', '!(b/a)')); assert(isMatch('a/c', '!(b/a)')); assert(!isMatch('b/a', '!(b/a)')); assert(isMatch('b/b', '!(b/a)')); assert(isMatch('b/c', '!(b/a)')); assert(isMatch('a/a', '!((b/a))')); assert(isMatch('a/b', '!((b/a))')); assert(isMatch('a/c', '!((b/a))')); assert(!isMatch('b/a', '!((b/a))')); assert(isMatch('b/b', '!((b/a))')); assert(isMatch('b/c', '!((b/a))')); assert(isMatch('a/a', '!((?:b/a))')); assert(isMatch('a/b', '!((?:b/a))')); assert(isMatch('a/c', '!((?:b/a))')); assert(!isMatch('b/a', '!((?:b/a))')); assert(isMatch('b/b', '!((?:b/a))')); assert(isMatch('b/c', '!((?:b/a))')); assert(isMatch('a/a', '!(b/(a))')); assert(isMatch('a/b', '!(b/(a))')); assert(isMatch('a/c', '!(b/(a))')); assert(!isMatch('b/a', '!(b/(a))')); assert(isMatch('b/b', '!(b/(a))')); assert(isMatch('b/c', '!(b/(a))')); assert(isMatch('a/a', '!(b/a)')); assert(isMatch('a/b', '!(b/a)')); assert(isMatch('a/c', '!(b/a)')); assert(!isMatch('b/a', '!(b/a)')); assert(isMatch('b/b', '!(b/a)')); assert(isMatch('b/c', '!(b/a)')); assert(!isMatch('a ', '@(!(a) )*')); assert(!isMatch('a b', '@(!(a) )*')); assert(!isMatch('a b', '@(!(a) )*')); assert(!isMatch('a ', '@(!(a) )*')); assert(!isMatch('a ', '@(!(a) )*')); assert(!isMatch('a', '@(!(a) )*')); assert(!isMatch('aa', '@(!(a) )*')); assert(!isMatch('b', '@(!(a) )*')); assert(!isMatch('bb', '@(!(a) )*')); assert(isMatch(' a ', '@(!(a) )*')); assert(isMatch('b ', '@(!(a) )*')); assert(isMatch('b ', '@(!(a) )*')); assert(!isMatch('a', '!(a)')); assert(isMatch('aa', '!(a)')); assert(isMatch('b', '!(a)')); assert(!isMatch('a', '!(a*)')); assert(!isMatch('aa', '!(a*)')); assert(!isMatch('ab', '!(a*)')); assert(isMatch('b', '!(a*)')); assert(!isMatch('a', '!(*a*)')); assert(!isMatch('aa', '!(*a*)')); assert(!isMatch('ab', '!(*a*)')); assert(!isMatch('ac', '!(*a*)')); assert(isMatch('b', '!(*a*)')); assert(!isMatch('a', '!(*a)')); assert(!isMatch('aa', '!(*a)')); assert(!isMatch('bba', '!(*a)')); assert(isMatch('ab', '!(*a)')); assert(isMatch('ac', '!(*a)')); assert(isMatch('b', '!(*a)')); assert(!isMatch('a', '!(*a)*')); assert(!isMatch('aa', '!(*a)*')); assert(!isMatch('bba', '!(*a)*')); assert(!isMatch('ab', '!(*a)*')); assert(!isMatch('ac', '!(*a)*')); assert(isMatch('b', '!(*a)*')); assert(!isMatch('a', '!(a)*')); assert(!isMatch('abb', '!(a)*')); assert(isMatch('ba', '!(a)*')); assert(isMatch('aa', 'a!(b)*')); assert(!isMatch('ab', 'a!(b)*')); assert(!isMatch('aba', 'a!(b)*')); assert(isMatch('ac', 'a!(b)*')); assert(isMatch('aac', 'a!(b)c')); assert(!isMatch('abc', 'a!(b)c')); assert(isMatch('acc', 'a!(b)c')); assert(!isMatch('a.c', 'a!(.)c')); assert(isMatch('abc', 'a!(.)c')); }); it('should support logical-or inside negation !(...) extglobs', () => { assert(!isMatch('ac', '!(a|b)c')); assert(!isMatch('bc', '!(a|b)c')); assert(isMatch('cc', '!(a|b)c')); }); it('should support multiple negation !(...) extglobs in one expression', () => { assert(!isMatch('ac.d', '!(a|b)c.!(d|e)')); assert(!isMatch('bc.d', '!(a|b)c.!(d|e)')); assert(!isMatch('cc.d', '!(a|b)c.!(d|e)')); assert(!isMatch('ac.e', '!(a|b)c.!(d|e)')); assert(!isMatch('bc.e', '!(a|b)c.!(d|e)')); assert(!isMatch('cc.e', '!(a|b)c.!(d|e)')); assert(!isMatch('ac.f', '!(a|b)c.!(d|e)')); assert(!isMatch('bc.f', '!(a|b)c.!(d|e)')); assert(isMatch('cc.f', '!(a|b)c.!(d|e)')); assert(isMatch('dc.g', '!(a|b)c.!(d|e)')); }); it('should support nested negation !(...) extglobs', () => { assert(isMatch('ac.d', '!(!(a|b)c.!(d|e))')); assert(isMatch('bc.d', '!(!(a|b)c.!(d|e))')); assert(!isMatch('cc.d', '!(a|b)c.!(d|e)')); assert(isMatch('cc.d', '!(!(a|b)c.!(d|e))')); assert(isMatch('cc.d', '!(!(a|b)c.!(d|e))')); assert(isMatch('ac.e', '!(!(a|b)c.!(d|e))')); assert(isMatch('bc.e', '!(!(a|b)c.!(d|e))')); assert(isMatch('cc.e', '!(!(a|b)c.!(d|e))')); assert(isMatch('ac.f', '!(!(a|b)c.!(d|e))')); assert(isMatch('bc.f', '!(!(a|b)c.!(d|e))')); assert(!isMatch('cc.f', '!(!(a|b)c.!(d|e))')); assert(!isMatch('dc.g', '!(!(a|b)c.!(d|e))')); }); it('should support *(...)', () => { assert(isMatch('a', 'a*(z)')); assert(isMatch('az', 'a*(z)')); assert(isMatch('azz', 'a*(z)')); assert(isMatch('azzz', 'a*(z)')); assert(!isMatch('abz', 'a*(z)')); assert(!isMatch('cz', 'a*(z)')); assert(!isMatch('a/a', '*(b/a)')); assert(!isMatch('a/b', '*(b/a)')); assert(!isMatch('a/c', '*(b/a)')); assert(isMatch('b/a', '*(b/a)')); assert(!isMatch('b/b', '*(b/a)')); assert(!isMatch('b/c', '*(b/a)')); assert(!isMatch('cz', 'a**(z)')); assert(isMatch('abz', 'a**(z)')); assert(isMatch('az', 'a**(z)')); assert(!isMatch('c/z/v', '*(z)')); assert(isMatch('z', '*(z)')); assert(!isMatch('zf', '*(z)')); assert(!isMatch('fz', '*(z)')); assert(!isMatch('c/a/v', 'c/*(z)/v')); assert(isMatch('c/z/v', 'c/*(z)/v')); assert(!isMatch('a.md.js', '*.*(js).js')); assert(isMatch('a.js.js', '*.*(js).js')); }); it('should support +(...) extglobs', () => { assert(!isMatch('a', 'a+(z)')); assert(isMatch('az', 'a+(z)')); assert(!isMatch('cz', 'a+(z)')); assert(!isMatch('abz', 'a+(z)')); assert(!isMatch('a+z', 'a+(z)')); assert(isMatch('a+z', 'a++(z)')); assert(!isMatch('c+z', 'a+(z)')); assert(!isMatch('a+bz', 'a+(z)')); assert(!isMatch('az', '+(z)')); assert(!isMatch('cz', '+(z)')); assert(!isMatch('abz', '+(z)')); assert(!isMatch('fz', '+(z)')); assert(isMatch('z', '+(z)')); assert(isMatch('zz', '+(z)')); assert(isMatch('c/z/v', 'c/+(z)/v')); assert(isMatch('c/zz/v', 'c/+(z)/v')); assert(!isMatch('c/a/v', 'c/+(z)/v')); }); it('should support ?(...) extglobs', () => { assert(isMatch('a?z', 'a??(z)')); assert(!isMatch('a?z', 'a?(z)')); assert(!isMatch('abz', 'a?(z)')); assert(!isMatch('z', 'a?(z)')); assert(isMatch('a', 'a?(z)')); assert(isMatch('az', 'a?(z)')); assert(!isMatch('abz', '?(z)')); assert(!isMatch('az', '?(z)')); assert(!isMatch('cz', '?(z)')); assert(!isMatch('fz', '?(z)')); assert(!isMatch('zz', '?(z)')); assert(isMatch('z', '?(z)')); assert(!isMatch('c/a/v', 'c/?(z)/v')); assert(!isMatch('c/zz/v', 'c/?(z)/v')); assert(isMatch('c/z/v', 'c/?(z)/v')); }); it('should support @(...) extglobs', () => { assert(isMatch('c/z/v', 'c/@(z)/v')); assert(!isMatch('c/a/v', 'c/@(z)/v')); assert(isMatch('moo.cow', '@(*.*)')); assert(!isMatch('cz', 'a*@(z)')); assert(isMatch('abz', 'a*@(z)')); assert(isMatch('az', 'a*@(z)')); assert(!isMatch('cz', 'a@(z)')); assert(!isMatch('abz', 'a@(z)')); assert(isMatch('az', 'a@(z)')); }); it('should support qmark matching', () => { assert(isMatch('a', '?')); assert(!isMatch('aa', '?')); assert(!isMatch('ab', '?')); assert(!isMatch('aaa', '?')); assert(!isMatch('abcdefg', '?')); assert(!isMatch('a', '??')); assert(isMatch('aa', '??')); assert(isMatch('ab', '??')); assert(!isMatch('aaa', '??')); assert(!isMatch('abcdefg', '??')); assert(!isMatch('a', '???')); assert(!isMatch('aa', '???')); assert(!isMatch('ab', '???')); assert(isMatch('aaa', '???')); assert(!isMatch('abcdefg', '???')); }); it('should match exactly one of the given pattern:', () => { assert(!isMatch('aa.aa', '(b|a).(a)')); assert(!isMatch('a.bb', '(b|a).(a)')); assert(!isMatch('a.aa.a', '(b|a).(a)')); assert(!isMatch('cc.a', '(b|a).(a)')); assert(isMatch('a.a', '(b|a).(a)')); assert(!isMatch('c.a', '(b|a).(a)')); assert(!isMatch('dd.aa.d', '(b|a).(a)')); assert(isMatch('b.a', '(b|a).(a)')); assert(!isMatch('aa.aa', '@(b|a).@(a)')); assert(!isMatch('a.bb', '@(b|a).@(a)')); assert(!isMatch('a.aa.a', '@(b|a).@(a)')); assert(!isMatch('cc.a', '@(b|a).@(a)')); assert(isMatch('a.a', '@(b|a).@(a)')); assert(!isMatch('c.a', '@(b|a).@(a)')); assert(!isMatch('dd.aa.d', '@(b|a).@(a)')); assert(isMatch('b.a', '@(b|a).@(a)')); }); it('should pass tests from rosenblatt\'s korn shell book', () => { assert(!isMatch('', '*(0|1|3|5|7|9)')); // only one that disagrees, since we don't match empty strings assert(isMatch('137577991', '*(0|1|3|5|7|9)')); assert(!isMatch('2468', '*(0|1|3|5|7|9)')); assert(isMatch('file.c', '*.c?(c)')); assert(!isMatch('file.C', '*.c?(c)')); assert(isMatch('file.cc', '*.c?(c)')); assert(!isMatch('file.ccc', '*.c?(c)')); assert(isMatch('parse.y', '!(*.c|*.h|Makefile.in|config*|README)')); assert(!isMatch('shell.c', '!(*.c|*.h|Makefile.in|config*|README)')); assert(isMatch('Makefile', '!(*.c|*.h|Makefile.in|config*|README)')); assert(!isMatch('Makefile.in', '!(*.c|*.h|Makefile.in|config*|README)')); assert(!isMatch('VMS.FILE;', '*\\;[1-9]*([0-9])')); assert(!isMatch('VMS.FILE;0', '*\\;[1-9]*([0-9])')); assert(isMatch('VMS.FILE;1', '*\\;[1-9]*([0-9])')); assert(isMatch('VMS.FILE;139', '*\\;[1-9]*([0-9])')); assert(!isMatch('VMS.FILE;1N', '*\\;[1-9]*([0-9])')); }); it('tests derived from the pd-ksh test suite', () => { assert(isMatch('abcx', '!([*)*')); assert(isMatch('abcz', '!([*)*')); assert(isMatch('bbc', '!([*)*')); assert(isMatch('abcx', '!([[*])*')); assert(isMatch('abcz', '!([[*])*')); assert(isMatch('bbc', '!([[*])*')); assert(isMatch('abcx', '+(a|b\\[)*')); assert(isMatch('abcz', '+(a|b\\[)*')); assert(!isMatch('bbc', '+(a|b\\[)*')); assert(isMatch('abcx', '+(a|b[)*')); assert(isMatch('abcz', '+(a|b[)*')); assert(!isMatch('bbc', '+(a|b[)*')); assert(!isMatch('abcx', '[a*(]*z')); assert(isMatch('abcz', '[a*(]*z')); assert(!isMatch('bbc', '[a*(]*z')); assert(isMatch('aaz', '[a*(]*z')); assert(isMatch('aaaz', '[a*(]*z')); assert(!isMatch('abcx', '[a*(]*)z')); assert(!isMatch('abcz', '[a*(]*)z')); assert(!isMatch('bbc', '[a*(]*)z')); assert(!isMatch('abc', '+()c')); assert(!isMatch('abc', '+()x')); assert(isMatch('abc', '+(*)c')); assert(!isMatch('abc', '+(*)x')); assert(!isMatch('abc', 'no-file+(a|b)stuff')); assert(!isMatch('abc', 'no-file+(a*(c)|b)stuff')); assert(isMatch('abd', 'a+(b|c)d')); assert(isMatch('acd', 'a+(b|c)d')); assert(!isMatch('abc', 'a+(b|c)d')); assert(isMatch('abd', 'a!(@(b|B))')); assert(isMatch('acd', 'a!(@(b|B))')); assert(isMatch('ac', 'a!(@(b|B))')); assert(!isMatch('ab', 'a!(@(b|B))')); assert(!isMatch('abc', 'a!(@(b|B))d')); assert(!isMatch('abd', 'a!(@(b|B))d')); assert(isMatch('acd', 'a!(@(b|B))d')); assert(isMatch('abd', 'a[b*(foo|bar)]d')); assert(!isMatch('abc', 'a[b*(foo|bar)]d')); assert(!isMatch('acd', 'a[b*(foo|bar)]d')); }); it('stuff from korn\'s book', () => { assert(!isMatch('para', 'para+([0-9])')); assert(!isMatch('para381', 'para?([345]|99)1')); assert(!isMatch('paragraph', 'para*([0-9])')); assert(!isMatch('paramour', 'para@(chute|graph)')); assert(isMatch('para', 'para*([0-9])')); assert(isMatch('para.38', 'para!(*.[0-9])')); assert(isMatch('para.38', 'para!(*.[00-09])')); assert(isMatch('para.graph', 'para!(*.[0-9])')); assert(isMatch('para13829383746592', 'para*([0-9])')); assert(isMatch('para39', 'para!(*.[0-9])')); assert(isMatch('para987346523', 'para+([0-9])')); assert(isMatch('para991', 'para?([345]|99)1')); assert(isMatch('paragraph', 'para!(*.[0-9])')); assert(isMatch('paragraph', 'para@(chute|graph)')); }); it('simple kleene star tests', () => { assert(!isMatch('foo', '*(a|b[)')); assert(!isMatch('(', '*(a|b[)')); assert(!isMatch(')', '*(a|b[)')); assert(!isMatch('|', '*(a|b[)')); assert(isMatch('a', '*(a|b)')); assert(isMatch('b', '*(a|b)')); assert(isMatch('b[', '*(a|b\\[)')); assert(isMatch('ab[', '+(a|b\\[)')); assert(!isMatch('ab[cde', '+(a|b\\[)')); assert(isMatch('ab[cde', '+(a|b\\[)*')); assert(isMatch('foo', '*(a|b|f)*')); assert(isMatch('foo', '*(a|b|o)*')); assert(isMatch('foo', '*(a|b|f|o)')); assert(isMatch('*(a|b[)', '\\*\\(a\\|b\\[\\)')); assert(!isMatch('foo', '*(a|b)')); assert(!isMatch('foo', '*(a|b\\[)')); assert(isMatch('foo', '*(a|b\\[)|f*')); }); it('should support multiple extglobs:', () => { assert(isMatch('moo.cow', '@(*).@(*)')); assert(isMatch('a.a', '*.@(a|b|@(ab|a*@(b))*@(c)d)')); assert(isMatch('a.b', '*.@(a|b|@(ab|a*@(b))*@(c)d)')); assert(!isMatch('a.c', '*.@(a|b|@(ab|a*@(b))*@(c)d)')); assert(!isMatch('a.c.d', '*.@(a|b|@(ab|a*@(b))*@(c)d)')); assert(!isMatch('c.c', '*.@(a|b|@(ab|a*@(b))*@(c)d)')); assert(!isMatch('a.', '*.@(a|b|@(ab|a*@(b))*@(c)d)')); assert(!isMatch('d.d', '*.@(a|b|@(ab|a*@(b))*@(c)d)')); assert(!isMatch('e.e', '*.@(a|b|@(ab|a*@(b))*@(c)d)')); assert(!isMatch('f.f', '*.@(a|b|@(ab|a*@(b))*@(c)d)')); assert(isMatch('a.abcd', '*.@(a|b|@(ab|a*@(b))*@(c)d)')); assert(!isMatch('a.a', '!(*.a|*.b|*.c)')); assert(!isMatch('a.b', '!(*.a|*.b|*.c)')); assert(!isMatch('a.c', '!(*.a|*.b|*.c)')); assert(isMatch('a.c.d', '!(*.a|*.b|*.c)')); assert(!isMatch('c.c', '!(*.a|*.b|*.c)')); assert(isMatch('a.', '!(*.a|*.b|*.c)')); assert(isMatch('d.d', '!(*.a|*.b|*.c)')); assert(isMatch('e.e', '!(*.a|*.b|*.c)')); assert(isMatch('f.f', '!(*.a|*.b|*.c)')); assert(isMatch('a.abcd', '!(*.a|*.b|*.c)')); assert(isMatch('a.a', '!(*.[^a-c])')); assert(isMatch('a.b', '!(*.[^a-c])')); assert(isMatch('a.c', '!(*.[^a-c])')); assert(!isMatch('a.c.d', '!(*.[^a-c])')); assert(isMatch('c.c', '!(*.[^a-c])')); assert(isMatch('a.', '!(*.[^a-c])')); assert(!isMatch('d.d', '!(*.[^a-c])')); assert(!isMatch('e.e', '!(*.[^a-c])')); assert(!isMatch('f.f', '!(*.[^a-c])')); assert(isMatch('a.abcd', '!(*.[^a-c])')); assert(!isMatch('a.a', '!(*.[a-c])')); assert(!isMatch('a.b', '!(*.[a-c])')); assert(!isMatch('a.c', '!(*.[a-c])')); assert(isMatch('a.c.d', '!(*.[a-c])')); assert(!isMatch('c.c', '!(*.[a-c])')); assert(isMatch('a.', '!(*.[a-c])')); assert(isMatch('d.d', '!(*.[a-c])')); assert(isMatch('e.e', '!(*.[a-c])')); assert(isMatch('f.f', '!(*.[a-c])')); assert(isMatch('a.abcd', '!(*.[a-c])')); assert(!isMatch('a.a', '!(*.[a-c]*)')); assert(!isMatch('a.b', '!(*.[a-c]*)')); assert(!isMatch('a.c', '!(*.[a-c]*)')); assert(!isMatch('a.c.d', '!(*.[a-c]*)')); assert(!isMatch('c.c', '!(*.[a-c]*)')); assert(isMatch('a.', '!(*.[a-c]*)')); assert(isMatch('d.d', '!(*.[a-c]*)')); assert(isMatch('e.e', '!(*.[a-c]*)')); assert(isMatch('f.f', '!(*.[a-c]*)')); assert(!isMatch('a.abcd', '!(*.[a-c]*)')); assert(!isMatch('a.a', '*.!(a|b|c)')); assert(!isMatch('a.b', '*.!(a|b|c)')); assert(!isMatch('a.c', '*.!(a|b|c)')); assert(isMatch('a.c.d', '*.!(a|b|c)')); assert(!isMatch('c.c', '*.!(a|b|c)')); assert(isMatch('a.', '*.!(a|b|c)')); assert(isMatch('d.d', '*.!(a|b|c)')); assert(isMatch('e.e', '*.!(a|b|c)')); assert(isMatch('f.f', '*.!(a|b|c)')); assert(isMatch('a.abcd', '*.!(a|b|c)')); assert(isMatch('a.a', '*!(.a|.b|.c)')); assert(isMatch('a.b', '*!(.a|.b|.c)')); assert(isMatch('a.c', '*!(.a|.b|.c)')); assert(isMatch('a.c.d', '*!(.a|.b|.c)')); assert(isMatch('c.c', '*!(.a|.b|.c)')); assert(isMatch('a.', '*!(.a|.b|.c)')); assert(isMatch('d.d', '*!(.a|.b|.c)')); assert(isMatch('e.e', '*!(.a|.b|.c)')); assert(isMatch('f.f', '*!(.a|.b|.c)')); assert(isMatch('a.abcd', '*!(.a|.b|.c)')); assert(!isMatch('a.a', '!(*.[a-c])*')); assert(!isMatch('a.b', '!(*.[a-c])*')); assert(!isMatch('a.c', '!(*.[a-c])*')); assert(!isMatch('a.c.d', '!(*.[a-c])*')); assert(!isMatch('c.c', '!(*.[a-c])*')); assert(isMatch('a.', '!(*.[a-c])*')); assert(isMatch('d.d', '!(*.[a-c])*')); assert(isMatch('e.e', '!(*.[a-c])*')); assert(isMatch('f.f', '!(*.[a-c])*')); assert(!isMatch('a.abcd', '!(*.[a-c])*')); assert(isMatch('a.a', '*!(.a|.b|.c)*')); assert(isMatch('a.b', '*!(.a|.b|.c)*')); assert(isMatch('a.c', '*!(.a|.b|.c)*')); assert(isMatch('a.c.d', '*!(.a|.b|.c)*')); assert(isMatch('c.c', '*!(.a|.b|.c)*')); assert(isMatch('a.', '*!(.a|.b|.c)*')); assert(isMatch('d.d', '*!(.a|.b|.c)*')); assert(isMatch('e.e', '*!(.a|.b|.c)*')); assert(isMatch('f.f', '*!(.a|.b|.c)*')); assert(isMatch('a.abcd', '*!(.a|.b|.c)*')); assert(!isMatch('a.a', '*.!(a|b|c)*')); assert(!isMatch('a.b', '*.!(a|b|c)*')); assert(!isMatch('a.c', '*.!(a|b|c)*')); assert(isMatch('a.c.d', '*.!(a|b|c)*')); assert(!isMatch('c.c', '*.!(a|b|c)*')); assert(isMatch('a.', '*.!(a|b|c)*')); assert(isMatch('d.d', '*.!(a|b|c)*')); assert(isMatch('e.e', '*.!(a|b|c)*')); assert(isMatch('f.f', '*.!(a|b|c)*')); assert(!isMatch('a.abcd', '*.!(a|b|c)*')); }); it('should correctly match empty parens', () => { assert(!isMatch('def', '@()ef')); assert(isMatch('ef', '@()ef')); assert(!isMatch('def', '()ef')); assert(isMatch('ef', '()ef')); }); it('should match escaped parens', () => { if (process.platform !== 'win32') { assert(isMatch('a\\(b', 'a\\\\\\(b')); } assert(isMatch('a(b', 'a(b')); assert(isMatch('a(b', 'a\\(b')); assert(!isMatch('a((b', 'a(b')); assert(!isMatch('a((((b', 'a(b')); assert(!isMatch('ab', 'a(b')); assert(isMatch('a(b', 'a\\(b')); assert(!isMatch('a((b', 'a\\(b')); assert(!isMatch('a((((b', 'a\\(b')); assert(!isMatch('ab', 'a\\(b')); assert(isMatch('a(b', 'a(*b')); assert(isMatch('a(ab', 'a\\(*b')); assert(isMatch('a((b', 'a(*b')); assert(isMatch('a((((b', 'a(*b')); assert(!isMatch('ab', 'a(*b')); }); it('should match escaped backslashes', () => { if (process.platform !== 'win32') { assert(isMatch('a\\(b', 'a\\(b')); assert(isMatch('a\\b', 'a\\b')); } assert(isMatch('a\\\\(b', 'a\\\\(b')); assert(!isMatch('a(b', 'a\\\\(b')); assert(!isMatch('a\\(b', 'a\\\\(b')); assert(!isMatch('a((b', 'a\\(b')); assert(!isMatch('a((((b', 'a\\(b')); assert(!isMatch('ab', 'a\\(b')); assert(!isMatch('a/b', 'a\\b')); assert(!isMatch('ab', 'a\\b')); }); // these are not extglobs, and do not need to pass, but they are included // to test integration with other features it('should support regex characters', () => { let fixtures = ['a c', 'a.c', 'a.xy.zc', 'a.zc', 'a123c', 'a1c', 'abbbbc', 'abbbc', 'abbc', 'abc', 'abq', 'axy zc', 'axy', 'axy.zc', 'axyzc']; if (process.platform !== 'win32') { assert.deepEqual(mm(['a\\b', 'a/b', 'ab'], 'a/b'), ['a/b']); } assert.deepEqual(mm(['a/b', 'ab'], 'a/b'), ['a/b']); assert.deepEqual(mm(fixtures, 'ab?bc'), ['abbbc']); assert.deepEqual(mm(fixtures, 'ab*c'), ['abbbbc', 'abbbc', 'abbc', 'abc']); assert.deepEqual(mm(fixtures, 'a+(b)bc'), ['abbbbc', 'abbbc', 'abbc']); assert.deepEqual(mm(fixtures, '^abc$'), []); assert.deepEqual(mm(fixtures, 'a.c'), ['a.c']); assert.deepEqual(mm(fixtures, 'a.*c'), ['a.c', 'a.xy.zc', 'a.zc']); assert.deepEqual(mm(fixtures, 'a*c'), ['a c', 'a.c', 'a.xy.zc', 'a.zc', 'a123c', 'a1c', 'abbbbc', 'abbbc', 'abbc', 'abc', 'axy zc', 'axy.zc', 'axyzc']); assert.deepEqual(mm(fixtures, 'a[\\w]+c'), ['a123c', 'a1c', 'abbbbc', 'abbbc', 'abbc', 'abc', 'axyzc'], 'Should match word characters'); assert.deepEqual(mm(fixtures, 'a[\\W]+c'), ['a c', 'a.c'], 'Should match non-word characters'); assert.deepEqual(mm(fixtures, 'a[\\d]+c'), ['a123c', 'a1c'], 'Should match numbers'); assert.deepEqual(mm(['foo@#$%123ASD #$$%^&', 'foo!@#$asdfl;', '123'], '[\\d]+'), ['123']); assert.deepEqual(mm(['a123c', 'abbbc'], 'a[\\D]+c'), ['abbbc'], 'Should match non-numbers'); assert.deepEqual(mm(['foo', ' foo '], '(f|o)+\\b'), ['foo'], 'Should match word boundaries'); }); }); describe('extglobs from the bash spec', () => { it('should match negation extglobs', () => { assert(isMatch('bar', '!(foo)')); assert(isMatch('f', '!(foo)')); assert(isMatch('fa', '!(foo)')); assert(isMatch('fb', '!(foo)')); assert(isMatch('ff', '!(foo)')); assert(isMatch('fff', '!(foo)')); assert(isMatch('fo', '!(foo)')); assert(!isMatch('foo', '!(foo)')); assert(!isMatch('foo/bar', '!(foo)')); assert(!isMatch('a/b/c/bar', '**/!(bar)')); assert(isMatch('a/b/c/foo/bar', '**/!(baz)/bar')); assert(isMatch('foobar', '!(foo)')); assert(isMatch('foot', '!(foo)')); assert(isMatch('foox', '!(foo)')); assert(isMatch('o', '!(foo)')); assert(isMatch('of', '!(foo)')); assert(isMatch('ooo', '!(foo)')); assert(isMatch('ox', '!(foo)')); assert(isMatch('x', '!(foo)')); assert(isMatch('xx', '!(foo)')); assert(!isMatch('bar', '!(!(foo))')); assert(!isMatch('f', '!(!(foo))')); assert(!isMatch('fa', '!(!(foo))')); assert(!isMatch('fb', '!(!(foo))')); assert(!isMatch('ff', '!(!(foo))')); assert(!isMatch('fff', '!(!(foo))')); assert(!isMatch('fo', '!(!(foo))')); assert(isMatch('foo', '!(!(foo))')); assert(!isMatch('foo/bar', '!(!(foo))')); assert(!isMatch('foobar', '!(!(foo))')); assert(!isMatch('foot', '!(!(foo))')); assert(!isMatch('foox', '!(!(foo))')); assert(!isMatch('o', '!(!(foo))')); assert(!isMatch('of', '!(!(foo))')); assert(!isMatch('ooo', '!(!(foo))')); assert(!isMatch('ox', '!(!(foo))')); assert(!isMatch('x', '!(!(foo))')); assert(!isMatch('xx', '!(!(foo))')); assert(isMatch('bar', '!(!(!(foo)))')); assert(isMatch('f', '!(!(!(foo)))')); assert(isMatch('fa', '!(!(!(foo)))')); assert(isMatch('fb', '!(!(!(foo)))')); assert(isMatch('ff', '!(!(!(foo)))')); assert(isMatch('fff', '!(!(!(foo)))')); assert(isMatch('fo', '!(!(!(foo)))')); assert(!isMatch('foo', '!(!(!(foo)))')); assert(!isMatch('foo/bar', '!(!(!(foo)))')); assert(isMatch('foobar', '!(!(!(foo)))')); assert(isMatch('foot', '!(!(!(foo)))')); assert(isMatch('foox', '!(!(!(foo)))')); assert(isMatch('o', '!(!(!(foo)))')); assert(isMatch('of', '!(!(!(foo)))')); assert(isMatch('ooo', '!(!(!(foo)))')); assert(isMatch('ox', '!(!(!(foo)))')); assert(isMatch('x', '!(!(!(foo)))')); assert(isMatch('xx', '!(!(!(foo)))')); assert(!isMatch('bar', '!(!(!(!(foo))))')); assert(!isMatch('f', '!(!(!(!(foo))))')); assert(!isMatch('fa', '!(!(!(!(foo))))')); assert(!isMatch('fb', '!(!(!(!(foo))))')); assert(!isMatch('ff', '!(!(!(!(foo))))')); assert(!isMatch('fff', '!(!(!(!(foo))))')); assert(!isMatch('fo', '!(!(!(!(foo))))')); assert(isMatch('foo', '!(!(!(!(foo))))')); assert(!isMatch('foo/bar', '!(!(!(!(foo))))')); assert(!isMatch('foot', '!(!(!(!(foo))))')); assert(!isMatch('o', '!(!(!(!(foo))))')); assert(!isMatch('of', '!(!(!(!(foo))))')); assert(!isMatch('ooo', '!(!(!(!(foo))))')); assert(!isMatch('ox', '!(!(!(!(foo))))')); assert(!isMatch('x', '!(!(!(!(foo))))')); assert(!isMatch('xx', '!(!(!(!(foo))))')); assert(!isMatch('bar', '!(!(foo))*')); assert(!isMatch('f', '!(!(foo))*')); assert(!isMatch('fa', '!(!(foo))*')); assert(!isMatch('fb', '!(!(foo))*')); assert(!isMatch('ff', '!(!(foo))*')); assert(!isMatch('fff', '!(!(foo))*')); assert(!isMatch('fo', '!(!(foo))*')); assert(isMatch('foo', '!(!(foo))*')); assert(!isMatch('foo/bar', '!(!(foo))*')); assert(isMatch('foobar', '!(!(foo))*')); assert(isMatch('foot', '!(!(foo))*')); assert(isMatch('foox', '!(!(foo))*')); assert(!isMatch('o', '!(!(foo))*')); assert(!isMatch('of', '!(!(foo))*')); assert(!isMatch('ooo', '!(!(foo))*')); assert(!isMatch('ox', '!(!(foo))*')); assert(!isMatch('x', '!(!(foo))*')); assert(!isMatch('xx', '!(!(foo))*')); assert(isMatch('bar', '!(f!(o))')); assert(!isMatch('f', '!(f!(o))')); assert(!isMatch('fa', '!(f!(o))')); assert(!isMatch('fb', '!(f!(o))')); assert(!isMatch('ff', '!(f!(o))')); assert(!isMatch('fff', '!(f!(o))')); assert(isMatch('fo', '!(f!(o))')); assert(isMatch('foo', '!(!(foo))')); assert(isMatch('go', '!(f!(o))')); assert(!isMatch('foo', '!(f!(o))')); assert(!isMatch('foo/bar', '!(f!(o))')); assert(!isMatch('foobar', '!(f)!(o)')); assert(!isMatch('foobar', '!(f)!(o)!(o)bar')); assert(isMatch('barbar', '!(f)!(o)!(o)bar')); assert(!isMatch('foobar', '!(f!(o))')); assert(!isMatch('foot', '!(f!(o))')); assert(!isMatch('foox', '!(f!(o))')); assert(isMatch('o', '!(f!(o))')); assert(isMatch('of', '!(f!(o))')); assert(isMatch('ooo', '!(f!(o))')); assert(isMatch('ox', '!(f!(o))')); assert(isMatch('x', '!(f!(o))')); assert(isMatch('xx', '!(f!(o))')); assert(isMatch('bar', '!(f(o))')); assert(isMatch('f', '!(f(o))')); assert(isMatch('fa', '!(f(o))')); assert(isMatch('fb', '!(f(o))')); assert(isMatch('ff', '!(f(o))')); assert(isMatch('fff', '!(f(o))')); assert(!isMatch('fo', '!(f(o))')); assert(isMatch('foo', '!(f(o))')); assert(!isMatch('foo/bar', '!(f(o))')); assert(isMatch('foobar', '!(f(o))')); assert(isMatch('foot', '!(f(o))')); assert(isMatch('foox', '!(f(o))')); assert(isMatch('o', '!(f(o))')); assert(isMatch('of', '!(f(o))')); assert(isMatch('ooo', '!(f(o))')); assert(isMatch('ox', '!(f(o))')); assert(isMatch('x', '!(f(o))')); assert(isMatch('xx', '!(f(o))')); assert(isMatch('bar', '!(f)')); assert(!isMatch('f', '!(f)')); assert(isMatch('fa', '!(f)')); assert(isMatch('fb', '!(f)')); assert(isMatch('ff', '!(f)')); assert(isMatch('fff', '!(f)')); assert(isMatch('fo', '!(f)')); assert(isMatch('foo', '!(f)')); assert(!isMatch('foo/bar', '!(f)')); assert(isMatch('foobar', '!(f)')); assert(isMatch('foot', '!(f)')); assert(isMatch('foox', '!(f)')); assert(isMatch('o', '!(f)')); assert(isMatch('of', '!(f)')); assert(isMatch('ooo', '!(f)')); assert(isMatch('ox', '!(f)')); assert(isMatch('x', '!(f)')); assert(isMatch('xx', '!(f)')); assert(isMatch('bar', '!(f)')); assert(!isMatch('f', '!(f)')); assert(isMatch('fa', '!(f)')); assert(isMatch('fb', '!(f)')); assert(isMatch('ff', '!(f)')); assert(isMatch('fff', '!(f)')); assert(isMatch('fo', '!(f)')); assert(isMatch('foo', '!(f)')); assert(!isMatch('foo/bar', '!(f)')); assert(isMatch('foobar', '!(f)')); assert(isMatch('foot', '!(f)')); assert(isMatch('foox', '!(f)')); assert(isMatch('o', '!(f)')); assert(isMatch('of', '!(f)')); assert(isMatch('ooo', '!(f)')); assert(isMatch('ox', '!(f)')); assert(isMatch('x', '!(f)')); assert(isMatch('xx', '!(f)')); assert(isMatch('bar', '!(foo)')); assert(isMatch('f', '!(foo)')); assert(isMatch('fa', '!(foo)')); assert(isMatch('fb', '!(foo)')); assert(isMatch('ff', '!(foo)')); assert(isMatch('fff', '!(foo)')); assert(isMatch('fo', '!(foo)')); assert(!isMatch('foo', '!(foo)')); assert(!isMatch('foo/bar', '!(foo)')); assert(isMatch('foobar', '!(foo)')); assert(isMatch('foot', '!(foo)')); assert(isMatch('foox', '!(foo)')); assert(isMatch('o', '!(foo)')); assert(isMatch('of', '!(foo)')); assert(isMatch('ooo', '!(foo)')); assert(isMatch('ox', '!(foo)')); assert(isMatch('x', '!(foo)')); assert(isMatch('xx', '!(foo)')); assert(isMatch('bar', '!(foo)*')); assert(isMatch('f', '!(foo)*')); assert(isMatch('fa', '!(foo)*')); assert(isMatch('fb', '!(foo)*')); assert(isMatch('ff', '!(foo)*')); assert(isMatch('fff', '!(foo)*')); assert(isMatch('fo', '!(foo)*')); assert(!isMatch('foo', '!(foo)*')); assert(!isMatch('foo/bar', '!(foo)*')); assert(!isMatch('foobar', '!(foo)*')); assert(!isMatch('foot', '!(foo)*')); assert(!isMatch('foox', '!(foo)*')); assert(isMatch('o', '!(foo)*')); assert(isMatch('of', '!(foo)*')); assert(isMatch('ooo', '!(foo)*')); assert(isMatch('ox', '!(foo)*')); assert(isMatch('x', '!(foo)*')); assert(isMatch('xx', '!(foo)*')); assert(isMatch('bar', '!(x)')); assert(isMatch('f', '!(x)')); assert(isMatch('fa', '!(x)')); assert(isMatch('fb', '!(x)')); assert(isMatch('ff', '!(x)')); assert(isMatch('fff', '!(x)')); assert(isMatch('fo', '!(x)')); assert(isMatch('foo', '!(x)')); assert(!isMatch('foo/bar', '!(x)')); assert(isMatch('foobar', '!(x)')); assert(isMatch('foot', '!(x)')); assert(isMatch('foox', '!(x)')); assert(isMatch('o', '!(x)')); assert(isMatch('of', '!(x)')); assert(isMatch('ooo', '!(x)')); assert(isMatch('ox', '!(x)')); assert(!isMatch('x', '!(x)')); assert(isMatch('xx', '!(x)')); assert(isMatch('bar', '!(x)*')); assert(isMatch('f', '!(x)*')); assert(isMatch('fa', '!(x)*')); assert(isMatch('fb', '!(x)*')); assert(isMatch('ff', '!(x)*')); assert(isMatch('fff', '!(x)*')); assert(isMatch('fo', '!(x)*')); assert(isMatch('foo', '!(x)*')); assert(!isMatch('foo/bar', '!(x)*')); assert(isMatch('foobar', '!(x)*')); assert(isMatch('foot', '!(x)*')); assert(isMatch('foox', '!(x)*')); assert(isMatch('o', '!(x)*')); assert(isMatch('of', '!(x)*')); assert(isMatch('ooo', '!(x)*')); assert(isMatch('ox', '!(x)*')); assert(!isMatch('x', '!(x)*')); assert(!isMatch('xx', '!(x)*')); assert(isMatch('bar', '*(!(f))')); assert(!isMatch('f', '*(!(f))')); assert(isMatch('fa', '*(!(f))')); assert(isMatch('fb', '*(!(f))')); assert(isMatch('ff', '*(!(f))')); assert(isMatch('fff', '*(!(f))')); assert(isMatch('fo', '*(!(f))')); assert(isMatch('foo', '*(!(f))')); assert(!isMatch('foo/bar', '*(!(f))')); assert(isMatch('foobar', '*(!(f))')); assert(isMatch('foot', '*(!(f))')); assert(isMatch('foox', '*(!(f))')); assert(isMatch('o', '*(!(f))')); assert(isMatch('of', '*(!(f))')); assert(isMatch('ooo', '*(!(f))')); assert(isMatch('ox', '*(!(f))')); assert(isMatch('x', '*(!(f))')); assert(isMatch('xx', '*(!(f))')); assert(!isMatch('bar', '*((foo))')); assert(!isMatch('f', '*((foo))')); assert(!isMatch('fa', '*((foo))')); assert(!isMatch('fb', '*((foo))')); assert(!isMatch('ff', '*((foo))')); assert(!isMatch('fff', '*((foo))')); assert(!isMatch('fo', '*((foo))')); assert(isMatch('foo', '*((foo))')); assert(!isMatch('foo/bar', '*((foo))')); assert(!isMatch('foobar', '*((foo))')); assert(!isMatch('foot', '*((foo))')); assert(!isMatch('foox', '*((foo))')); assert(!isMatch('o', '*((foo))')); assert(!isMatch('of', '*((foo))')); assert(!isMatch('ooo', '*((foo))')); assert(!isMatch('ox', '*((foo))')); assert(!isMatch('x', '*((foo))')); assert(!isMatch('xx', '*((foo))')); assert(isMatch('bar', '+(!(f))')); assert(!isMatch('f', '+(!(f))')); assert(isMatch('fa', '+(!(f))')); assert(isMatch('fb', '+(!(f))')); assert(isMatch('ff', '+(!(f))')); assert(isMatch('fff', '+(!(f))')); assert(isMatch('fo', '+(!(f))')); assert(isMatch('foo', '+(!(f))')); assert(!isMatch('foo/bar', '+(!(f))')); assert(isMatch('foobar', '+(!(f))')); assert(isMatch('foot', '+(!(f))')); assert(isMatch('foox', '+(!(f))')); assert(isMatch('o', '+(!(f))')); assert(isMatch('of', '+(!(f))')); assert(isMatch('ooo', '+(!(f))')); assert(isMatch('ox', '+(!(f))')); assert(isMatch('x', '+(!(f))')); assert(isMatch('xx', '+(!(f))')); assert(isMatch('bar', '@(!(z*)|*x)')); assert(isMatch('f', '@(!(z*)|*x)')); assert(isMatch('fa', '@(!(z*)|*x)')); assert(isMatch('fb', '@(!(z*)|*x)')); assert(isMatch('ff', '@(!(z*)|*x)')); assert(isMatch('fff', '@(!(z*)|*x)')); assert(isMatch('fo', '@(!(z*)|*x)')); assert(isMatch('foo', '@(!(z*)|*x)')); assert(isMatch('foo/bar', '@(!(z*/*)|*x)')); assert(!isMatch('foo/bar', '@(!(z*)|*x)')); assert(isMatch('foobar', '@(!(z*)|*x)')); assert(isMatch('foot', '@(!(z*)|*x)')); assert(isMatch('foox', '@(!(z*)|*x)')); assert(isMatch('o', '@(!(z*)|*x)')); assert(isMatch('of', '@(!(z*)|*x)')); assert(isMatch('ooo', '@(!(z*)|*x)')); assert(isMatch('ox', '@(!(z*)|*x)')); assert(isMatch('x', '@(!(z*)|*x)')); assert(isMatch('xx', '@(!(z*)|*x)')); assert(!isMatch('bar', 'foo/!(foo)')); assert(!isMatch('f', 'foo/!(foo)')); assert(!isMatch('fa', 'foo/!(foo)')); assert(!isMatch('fb', 'foo/!(foo)')); assert(!isMatch('ff', 'foo/!(foo)')); assert(!isMatch('fff', 'foo/!(foo)')); assert(!isMatch('fo', 'foo/!(foo)')); assert(!isMatch('foo', 'foo/!(foo)')); assert(isMatch('foo/bar', 'foo/!(foo)')); assert(!isMatch('foobar', 'foo/!(foo)')); assert(!isMatch('foot', 'foo/!(foo)')); assert(!isMatch('foox', 'foo/!(foo)')); assert(!isMatch('o', 'foo/!(foo)')); assert(!isMatch('of', 'foo/!(foo)')); assert(!isMatch('ooo', 'foo/!(foo)')); assert(!isMatch('ox', 'foo/!(foo)')); assert(!isMatch('x', 'foo/!(foo)')); assert(!isMatch('xx', 'foo/!(foo)')); assert(!isMatch('ffffffo', '(foo)bb')); assert(!isMatch('fffooofoooooffoofffooofff', '(foo)bb')); assert(!isMatch('ffo', '(foo)bb')); assert(!isMatch('fofo', '(foo)bb')); assert(!isMatch('fofoofoofofoo', '(foo)bb')); assert(!isMatch('foo', '(foo)bb')); assert(!isMatch('foob', '(foo)bb')); assert(isMatch('foobb', '(foo)bb')); assert(!isMatch('foofoofo', '(foo)bb')); assert(!isMatch('fooofoofofooo', '(foo)bb')); assert(!isMatch('foooofo', '(foo)bb')); assert(!isMatch('foooofof', '(foo)bb')); assert(!isMatch('foooofofx', '(foo)bb')); assert(!isMatch('foooxfooxfoxfooox', '(foo)bb')); assert(!isMatch('foooxfooxfxfooox', '(foo)bb')); assert(!isMatch('foooxfooxofoxfooox', '(foo)bb')); assert(!isMatch('foot', '(foo)bb')); assert(!isMatch('foox', '(foo)bb')); assert(!isMatch('ofoofo', '(foo)bb')); assert(!isMatch('ofooofoofofooo', '(foo)bb')); assert(!isMatch('ofoooxoofxo', '(foo)bb')); assert(!isMatch('ofoooxoofxoofoooxoofxo', '(foo)bb')); assert(!isMatch('ofoooxoofxoofoooxoofxofo', '(foo)bb')); assert(!isMatch('ofoooxoofxoofoooxoofxoo', '(foo)bb')); assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '(foo)bb')); assert(!isMatch('ofxoofxo', '(foo)bb')); assert(!isMatch('oofooofo', '(foo)bb')); assert(!isMatch('ooo', '(foo)bb')); assert(!isMatch('oxfoxfox', '(foo)bb')); assert(!isMatch('oxfoxoxfox', '(foo)bb')); assert(!isMatch('xfoooofof', '(foo)bb')); assert(isMatch('ffffffo', '*(*(f)*(o))')); assert(isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))')); assert(isMatch('ffo', '*(*(f)*(o))')); assert(isMatch('fofo', '*(*(f)*(o))')); assert(isMatch('fofoofoofofoo', '*(*(f)*(o))')); assert(isMatch('foo', '*(*(f)*(o))')); assert(!isMatch('foob', '*(*(f)*(o))')); assert(!isMatch('foobb', '*(*(f)*(o))')); assert(isMatch('foofoofo', '*(*(f)*(o))')); assert(isMatch('fooofoofofooo', '*(*(f)*(o))')); assert(isMatch('foooofo', '*(*(f)*(o))')); assert(isMatch('foooofof', '*(*(f)*(o))')); assert(!isMatch('foooofofx', '*(*(f)*(o))')); assert(!isMatch('foooxfooxfoxfooox', '*(*(f)*(o))')); assert(!isMatch('foooxfooxfxfooox', '*(*(f)*(o))')); assert(!isMatch('foooxfooxofoxfooox', '*(*(f)*(o))')); assert(!isMatch('foot', '*(*(f)*(o))')); assert(!isMatch('foox', '*(*(f)*(o))')); assert(isMatch('ofoofo', '*(*(f)*(o))')); assert(isMatch('ofooofoofofooo', '*(*(f)*(o))')); assert(!isMatch('ofoooxoofxo', '*(*(f)*(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(*(f)*(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(*(f)*(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(*(f)*(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(f)*(o))')); assert(!isMatch('ofxoofxo', '*(*(f)*(o))')); assert(isMatch('oofooofo', '*(*(f)*(o))')); assert(isMatch('ooo', '*(*(f)*(o))')); assert(!isMatch('oxfoxfox', '*(*(f)*(o))')); assert(!isMatch('oxfoxoxfox', '*(*(f)*(o))')); assert(!isMatch('xfoooofof', '*(*(f)*(o))')); assert(!isMatch('ffffffo', '*(*(of*(o)x)o)')); assert(!isMatch('fffooofoooooffoofffooofff', '*(*(of*(o)x)o)')); assert(!isMatch('ffo', '*(*(of*(o)x)o)')); assert(!isMatch('fofo', '*(*(of*(o)x)o)')); assert(!isMatch('fofoofoofofoo', '*(*(of*(o)x)o)')); assert(!isMatch('foo', '*(*(of*(o)x)o)')); assert(!isMatch('foob', '*(*(of*(o)x)o)')); assert(!isMatch('foobb', '*(*(of*(o)x)o)')); assert(!isMatch('foofoofo', '*(*(of*(o)x)o)')); assert(!isMatch('fooofoofofooo', '*(*(of*(o)x)o)')); assert(!isMatch('foooofo', '*(*(of*(o)x)o)')); assert(!isMatch('foooofof', '*(*(of*(o)x)o)')); assert(!isMatch('foooofofx', '*(*(of*(o)x)o)')); assert(!isMatch('foooxfooxfoxfooox', '*(*(of*(o)x)o)')); assert(!isMatch('foooxfooxfxfooox', '*(*(of*(o)x)o)')); assert(!isMatch('foooxfooxofoxfooox', '*(*(of*(o)x)o)')); assert(!isMatch('foot', '*(*(of*(o)x)o)')); assert(!isMatch('foox', '*(*(of*(o)x)o)')); assert(!isMatch('ofoofo', '*(*(of*(o)x)o)')); assert(!isMatch('ofooofoofofooo', '*(*(of*(o)x)o)')); assert(isMatch('ofoooxoofxo', '*(*(of*(o)x)o)')); assert(isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)')); assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)')); assert(isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)')); assert(isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)')); assert(isMatch('ofxoofxo', '*(*(of*(o)x)o)')); assert(!isMatch('oofooofo', '*(*(of*(o)x)o)')); assert(isMatch('ooo', '*(*(of*(o)x)o)')); assert(!isMatch('oxfoxfox', '*(*(of*(o)x)o)')); assert(!isMatch('oxfoxoxfox', '*(*(of*(o)x)o)')); assert(!isMatch('xfoooofof', '*(*(of*(o)x)o)')); assert(isMatch('ffffffo', '*(f*(o))')); assert(isMatch('fffooofoooooffoofffooofff', '*(f*(o))')); assert(isMatch('ffo', '*(f*(o))')); assert(isMatch('fofo', '*(f*(o))')); assert(isMatch('fofoofoofofoo', '*(f*(o))')); assert(isMatch('foo', '*(f*(o))')); assert(!isMatch('foob', '*(f*(o))')); assert(!isMatch('foobb', '*(f*(o))')); assert(isMatch('foofoofo', '*(f*(o))')); assert(isMatch('fooofoofofooo', '*(f*(o))')); assert(isMatch('foooofo', '*(f*(o))')); assert(isMatch('foooofof', '*(f*(o))')); assert(!isMatch('foooofofx', '*(f*(o))')); assert(!isMatch('foooxfooxfoxfooox', '*(f*(o))')); assert(!isMatch('foooxfooxfxfooox', '*(f*(o))')); assert(!isMatch('foooxfooxofoxfooox', '*(f*(o))')); assert(!isMatch('foot', '*(f*(o))')); assert(!isMatch('foox', '*(f*(o))')); assert(!isMatch('ofoofo', '*(f*(o))')); assert(!isMatch('ofooofoofofooo', '*(f*(o))')); assert(!isMatch('ofoooxoofxo', '*(f*(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(f*(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(f*(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(f*(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(f*(o))')); assert(!isMatch('ofxoofxo', '*(f*(o))')); assert(!isMatch('oofooofo', '*(f*(o))')); assert(!isMatch('ooo', '*(f*(o))')); assert(!isMatch('oxfoxfox', '*(f*(o))')); assert(!isMatch('oxfoxoxfox', '*(f*(o))')); assert(!isMatch('xfoooofof', '*(f*(o))')); assert(!isMatch('ffffffo', '*(f*(o)x)')); assert(!isMatch('fffooofoooooffoofffooofff', '*(f*(o)x)')); assert(!isMatch('ffo', '*(f*(o)x)')); assert(!isMatch('fofo', '*(f*(o)x)')); assert(!isMatch('fofoofoofofoo', '*(f*(o)x)')); assert(!isMatch('foo', '*(f*(o)x)')); assert(!isMatch('foob', '*(f*(o)x)')); assert(!isMatch('foobb', '*(f*(o)x)')); assert(!isMatch('foofoofo', '*(f*(o)x)')); assert(!isMatch('fooofoofofooo', '*(f*(o)x)')); assert(!isMatch('foooofo', '*(f*(o)x)')); assert(!isMatch('foooofof', '*(f*(o)x)')); assert(!isMatch('foooofofx', '*(f*(o)x)')); assert(isMatch('foooxfooxfoxfooox', '*(f*(o)x)')); assert(isMatch('foooxfooxfxfooox', '*(f*(o)x)')); assert(!isMatch('foooxfooxofoxfooox', '*(f*(o)x)')); assert(!isMatch('foot', '*(f*(o)x)')); assert(isMatch('foox', '*(f*(o)x)')); assert(!isMatch('ofoofo', '*(f*(o)x)')); assert(!isMatch('ofooofoofofooo', '*(f*(o)x)')); assert(!isMatch('ofoooxoofxo', '*(f*(o)x)')); assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(f*(o)x)')); assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(f*(o)x)')); assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(f*(o)x)')); assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(f*(o)x)')); assert(!isMatch('ofxoofxo', '*(f*(o)x)')); assert(!isMatch('oofooofo', '*(f*(o)x)')); assert(!isMatch('ooo', '*(f*(o)x)')); assert(!isMatch('oxfoxfox', '*(f*(o)x)')); assert(!isMatch('oxfoxoxfox', '*(f*(o)x)')); assert(!isMatch('xfoooofof', '*(f*(o)x)')); assert(!isMatch('ffffffo', '*(f+(o))')); assert(!isMatch('fffooofoooooffoofffooofff', '*(f+(o))')); assert(!isMatch('ffo', '*(f+(o))')); assert(isMatch('fofo', '*(f+(o))')); assert(isMatch('fofoofoofofoo', '*(f+(o))')); assert(isMatch('foo', '*(f+(o))')); assert(!isMatch('foob', '*(f+(o))')); assert(!isMatch('foobb', '*(f+(o))')); assert(isMatch('foofoofo', '*(f+(o))')); assert(isMatch('fooofoofofooo', '*(f+(o))')); assert(isMatch('foooofo', '*(f+(o))')); assert(!isMatch('foooofof', '*(f+(o))')); assert(!isMatch('foooofofx', '*(f+(o))')); assert(!isMatch('foooxfooxfoxfooox', '*(f+(o))')); assert(!isMatch('foooxfooxfxfooox', '*(f+(o))')); assert(!isMatch('foooxfooxofoxfooox', '*(f+(o))')); assert(!isMatch('foot', '*(f+(o))')); assert(!isMatch('foox', '*(f+(o))')); assert(!isMatch('ofoofo', '*(f+(o))')); assert(!isMatch('ofooofoofofooo', '*(f+(o))')); assert(!isMatch('ofoooxoofxo', '*(f+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(f+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(f+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(f+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(f+(o))')); assert(!isMatch('ofxoofxo', '*(f+(o))')); assert(!isMatch('oofooofo', '*(f+(o))')); assert(!isMatch('ooo', '*(f+(o))')); assert(!isMatch('oxfoxfox', '*(f+(o))')); assert(!isMatch('oxfoxoxfox', '*(f+(o))')); assert(!isMatch('xfoooofof', '*(f+(o))')); assert(!isMatch('ffffffo', '*(of+(o))')); assert(!isMatch('fffooofoooooffoofffooofff', '*(of+(o))')); assert(!isMatch('ffo', '*(of+(o))')); assert(!isMatch('fofo', '*(of+(o))')); assert(!isMatch('fofoofoofofoo', '*(of+(o))')); assert(!isMatch('foo', '*(of+(o))')); assert(!isMatch('foob', '*(of+(o))')); assert(!isMatch('foobb', '*(of+(o))')); assert(!isMatch('foofoofo', '*(of+(o))')); assert(!isMatch('fooofoofofooo', '*(of+(o))')); assert(!isMatch('foooofo', '*(of+(o))')); assert(!isMatch('foooofof', '*(of+(o))')); assert(!isMatch('foooofofx', '*(of+(o))')); assert(!isMatch('foooxfooxfoxfooox', '*(of+(o))')); assert(!isMatch('foooxfooxfxfooox', '*(of+(o))')); assert(!isMatch('foooxfooxofoxfooox', '*(of+(o))')); assert(!isMatch('foot', '*(of+(o))')); assert(!isMatch('foox', '*(of+(o))')); assert(isMatch('ofoofo', '*(of+(o))')); assert(!isMatch('ofooofoofofooo', '*(of+(o))')); assert(!isMatch('ofoooxoofxo', '*(of+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(of+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(of+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(of+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(of+(o))')); assert(!isMatch('ofxoofxo', '*(of+(o))')); assert(!isMatch('oofooofo', '*(of+(o))')); assert(!isMatch('ooo', '*(of+(o))')); assert(!isMatch('oxfoxfox', '*(of+(o))')); assert(!isMatch('oxfoxoxfox', '*(of+(o))')); assert(!isMatch('xfoooofof', '*(of+(o))')); assert(!isMatch('ffffffo', '*(of+(o)|f)')); assert(!isMatch('fffooofoooooffoofffooofff', '*(of+(o)|f)')); assert(!isMatch('ffo', '*(of+(o)|f)')); assert(isMatch('fofo', '*(of+(o)|f)')); assert(isMatch('fofoofoofofoo', '*(of+(o)|f)')); assert(!isMatch('foo', '*(of+(o)|f)')); assert(!isMatch('foob', '*(of+(o)|f)')); assert(!isMatch('foobb', '*(of+(o)|f)')); assert(!isMatch('foofoofo', '*(of+(o)|f)')); assert(!isMatch('fooofoofofooo', '*(of+(o)|f)')); assert(!isMatch('foooofo', '*(of+(o)|f)')); assert(!isMatch('foooofof', '*(of+(o)|f)')); assert(!isMatch('foooofofx', '*(of+(o)|f)')); assert(!isMatch('foooxfooxfoxfooox', '*(of+(o)|f)')); assert(!isMatch('foooxfooxfxfooox', '*(of+(o)|f)')); assert(!isMatch('foooxfooxofoxfooox', '*(of+(o)|f)')); assert(!isMatch('foot', '*(of+(o)|f)')); assert(!isMatch('foox', '*(of+(o)|f)')); assert(isMatch('ofoofo', '*(of+(o)|f)')); assert(isMatch('ofooofoofofooo', '*(of+(o)|f)')); assert(!isMatch('ofoooxoofxo', '*(of+(o)|f)')); assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(of+(o)|f)')); assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(of+(o)|f)')); assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(of+(o)|f)')); assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(of+(o)|f)')); assert(!isMatch('ofxoofxo', '*(of+(o)|f)')); assert(!isMatch('oofooofo', '*(of+(o)|f)')); assert(!isMatch('ooo', '*(of+(o)|f)')); assert(!isMatch('oxfoxfox', '*(of+(o)|f)')); assert(!isMatch('oxfoxoxfox', '*(of+(o)|f)')); assert(!isMatch('xfoooofof', '*(of+(o)|f)')); assert(!isMatch('ffffffo', '*(of|oof+(o))')); assert(!isMatch('fffooofoooooffoofffooofff', '*(of|oof+(o))')); assert(!isMatch('ffo', '*(of|oof+(o))')); assert(!isMatch('fofo', '*(of|oof+(o))')); assert(!isMatch('fofoofoofofoo', '*(of|oof+(o))')); assert(!isMatch('foo', '*(of|oof+(o))')); assert(!isMatch('foob', '*(of|oof+(o))')); assert(!isMatch('foobb', '*(of|oof+(o))')); assert(!isMatch('foofoofo', '*(of|oof+(o))')); assert(!isMatch('fooofoofofooo', '*(of|oof+(o))')); assert(!isMatch('foooofo', '*(of|oof+(o))')); assert(!isMatch('foooofof', '*(of|oof+(o))')); assert(!isMatch('foooofofx', '*(of|oof+(o))')); assert(!isMatch('foooxfooxfoxfooox', '*(of|oof+(o))')); assert(!isMatch('foooxfooxfxfooox', '*(of|oof+(o))')); assert(!isMatch('foooxfooxofoxfooox', '*(of|oof+(o))')); assert(!isMatch('foot', '*(of|oof+(o))')); assert(!isMatch('foox', '*(of|oof+(o))')); assert(isMatch('ofoofo', '*(of|oof+(o))')); assert(!isMatch('ofooofoofofooo', '*(of|oof+(o))')); assert(!isMatch('ofoooxoofxo', '*(of|oof+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(of|oof+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(of|oof+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(of|oof+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(of|oof+(o))')); assert(!isMatch('ofxoofxo', '*(of|oof+(o))')); assert(isMatch('oofooofo', '*(of|oof+(o))')); assert(!isMatch('ooo', '*(of|oof+(o))')); assert(!isMatch('oxfoxfox', '*(of|oof+(o))')); assert(!isMatch('oxfoxoxfox', '*(of|oof+(o))')); assert(!isMatch('xfoooofof', '*(of|oof+(o))')); assert(!isMatch('ffffffo', '*(oxf+(ox))')); assert(!isMatch('fffooofoooooffoofffooofff', '*(oxf+(ox))')); assert(!isMatch('ffo', '*(oxf+(ox))')); assert(!isMatch('fofo', '*(oxf+(ox))')); assert(!isMatch('fofoofoofofoo', '*(oxf+(ox))')); assert(!isMatch('foo', '*(oxf+(ox))')); assert(!isMatch('foob', '*(oxf+(ox))')); assert(!isMatch('foobb', '*(oxf+(ox))')); assert(!isMatch('foofoofo', '*(oxf+(ox))')); assert(!isMatch('fooofoofofooo', '*(oxf+(ox))')); assert(!isMatch('foooofo', '*(oxf+(ox))')); assert(!isMatch('foooofof', '*(oxf+(ox))')); assert(!isMatch('foooofofx', '*(oxf+(ox))')); assert(!isMatch('foooxfooxfoxfooox', '*(oxf+(ox))')); assert(!isMatch('foooxfooxfxfooox', '*(oxf+(ox))')); assert(!isMatch('foooxfooxofoxfooox', '*(oxf+(ox))')); assert(!isMatch('foot', '*(oxf+(ox))')); assert(!isMatch('foox', '*(oxf+(ox))')); assert(!isMatch('ofoofo', '*(oxf+(ox))')); assert(!isMatch('ofooofoofofooo', '*(oxf+(ox))')); assert(!isMatch('ofoooxoofxo', '*(oxf+(ox))')); assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(oxf+(ox))')); assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(oxf+(ox))')); assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(oxf+(ox))')); assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(oxf+(ox))')); assert(!isMatch('ofxoofxo', '*(oxf+(ox))')); assert(!isMatch('oofooofo', '*(oxf+(ox))')); assert(!isMatch('ooo', '*(oxf+(ox))')); assert(!isMatch('oxfoxfox', '*(oxf+(ox))')); assert(isMatch('oxfoxoxfox', '*(oxf+(ox))')); assert(!isMatch('xfoooofof', '*(oxf+(ox))')); assert(isMatch('ffffffo', '@(!(z*)|*x)')); assert(isMatch('fffooofoooooffoofffooofff', '@(!(z*)|*x)')); assert(isMatch('ffo', '@(!(z*)|*x)')); assert(isMatch('fofo', '@(!(z*)|*x)')); assert(isMatch('fofoofoofofoo', '@(!(z*)|*x)')); assert(isMatch('foo', '@(!(z*)|*x)')); assert(isMatch('foob', '@(!(z*)|*x)')); assert(isMatch('foobb', '@(!(z*)|*x)')); assert(isMatch('foofoofo', '@(!(z*)|*x)')); assert(isMatch('fooofoofofooo', '@(!(z*)|*x)')); assert(isMatch('foooofo', '@(!(z*)|*x)')); assert(isMatch('foooofof', '@(!(z*)|*x)')); assert(isMatch('foooofofx', '@(!(z*)|*x)')); assert(isMatch('foooxfooxfoxfooox', '@(!(z*)|*x)')); assert(isMatch('foooxfooxfxfooox', '@(!(z*)|*x)')); assert(isMatch('foooxfooxofoxfooox', '@(!(z*)|*x)')); assert(isMatch('foot', '@(!(z*)|*x)')); assert(isMatch('foox', '@(!(z*)|*x)')); assert(isMatch('ofoofo', '@(!(z*)|*x)')); assert(isMatch('ofooofoofofooo', '@(!(z*)|*x)')); assert(isMatch('ofoooxoofxo', '@(!(z*)|*x)')); assert(isMatch('ofoooxoofxoofoooxoofxo', '@(!(z*)|*x)')); assert(isMatch('ofoooxoofxoofoooxoofxofo', '@(!(z*)|*x)')); assert(isMatch('ofoooxoofxoofoooxoofxoo', '@(!(z*)|*x)')); assert(isMatch('ofoooxoofxoofoooxoofxooofxofxo', '@(!(z*)|*x)')); assert(isMatch('ofxoofxo', '@(!(z*)|*x)')); assert(isMatch('oofooofo', '@(!(z*)|*x)')); assert(isMatch('ooo', '@(!(z*)|*x)')); assert(isMatch('oxfoxfox', '@(!(z*)|*x)')); assert(isMatch('oxfoxoxfox', '@(!(z*)|*x)')); assert(isMatch('xfoooofof', '@(!(z*)|*x)')); assert(!isMatch('ffffffo', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('fffooofoooooffoofffooofff', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('ffo', '@(foo|f|fo)*(f|of+(o))')); assert(isMatch('fofo', '@(foo|f|fo)*(f|of+(o))')); assert(isMatch('fofoofoofofoo', '@(foo|f|fo)*(f|of+(o))')); assert(isMatch('foo', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('foob', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('foobb', '@(foo|f|fo)*(f|of+(o))')); assert(isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))')); assert(isMatch('fooofoofofooo', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('foooofo', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('foooofof', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('foooofofx', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('foooxfooxfoxfooox', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('foooxfooxfxfooox', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('foooxfooxofoxfooox', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('foot', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('foox', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('ofoofo', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('ofooofoofofooo', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('ofoooxoofxo', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxo', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxofo', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxoo', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('ofxoofxo', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('oofooofo', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('ooo', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('oxfoxfox', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('oxfoxoxfox', '@(foo|f|fo)*(f|of+(o))')); assert(!isMatch('xfoooofof', '@(foo|f|fo)*(f|of+(o))')); assert(isMatch('aaac', '*(@(a))a@(c)')); assert(isMatch('aac', '*(@(a))a@(c)')); assert(isMatch('ac', '*(@(a))a@(c)')); assert(!isMatch('abbcd', '*(@(a))a@(c)')); assert(!isMatch('abcd', '*(@(a))a@(c)')); assert(!isMatch('acd', '*(@(a))a@(c)')); assert(!isMatch('baaac', '*(@(a))a@(c)')); assert(!isMatch('c', '*(@(a))a@(c)')); assert(!isMatch('foo', '*(@(a))a@(c)')); assert(!isMatch('aaac', '@(ab|a*(b))*(c)d')); assert(!isMatch('aac', '@(ab|a*(b))*(c)d')); assert(!isMatch('ac', '@(ab|a*(b))*(c)d')); assert(isMatch('abbcd', '@(ab|a*(b))*(c)d')); assert(isMatch('abcd', '@(ab|a*(b))*(c)d')); assert(isMatch('acd', '@(ab|a*(b))*(c)d')); assert(!isMatch('baaac', '@(ab|a*(b))*(c)d')); assert(!isMatch('c', '@(ab|a*(b))*(c)d')); assert(!isMatch('foo', '@(ab|a*(b))*(c)d')); assert(!isMatch('aaac', '?@(a|b)*@(c)d')); assert(!isMatch('aac', '?@(a|b)*@(c)d')); assert(!isMatch('ac', '?@(a|b)*@(c)d')); assert(isMatch('abbcd', '?@(a|b)*@(c)d')); assert(isMatch('abcd', '?@(a|b)*@(c)d')); assert(!isMatch('acd', '?@(a|b)*@(c)d')); assert(!isMatch('baaac', '?@(a|b)*@(c)d')); assert(!isMatch('c', '?@(a|b)*@(c)d')); assert(!isMatch('foo', '?@(a|b)*@(c)d')); assert(!isMatch('aaac', '@(ab|a*@(b))*(c)d')); assert(!isMatch('aac', '@(ab|a*@(b))*(c)d')); assert(!isMatch('ac', '@(ab|a*@(b))*(c)d')); assert(isMatch('abbcd', '@(ab|a*@(b))*(c)d')); assert(isMatch('abcd', '@(ab|a*@(b))*(c)d')); assert(!isMatch('acd', '@(ab|a*@(b))*(c)d')); assert(!isMatch('baaac', '@(ab|a*@(b))*(c)d')); assert(!isMatch('c', '@(ab|a*@(b))*(c)d')); assert(!isMatch('foo', '@(ab|a*@(b))*(c)d')); assert(!isMatch('aac', '*(@(a))b@(c)')); }); it('should backtrack in alternation matches', () => { assert(!isMatch('ffffffo', '*(fo|foo)')); assert(!isMatch('fffooofoooooffoofffooofff', '*(fo|foo)')); assert(!isMatch('ffo', '*(fo|foo)')); assert(isMatch('fofo', '*(fo|foo)')); assert(isMatch('fofoofoofofoo', '*(fo|foo)')); assert(isMatch('foo', '*(fo|foo)')); assert(!isMatch('foob', '*(fo|foo)')); assert(!isMatch('foobb', '*(fo|foo)')); assert(isMatch('foofoofo', '*(fo|foo)')); assert(!isMatch('fooofoofofooo', '*(fo|foo)')); assert(!isMatch('foooofo', '*(fo|foo)')); assert(!isMatch('foooofof', '*(fo|foo)')); assert(!isMatch('foooofofx', '*(fo|foo)')); assert(!isMatch('foooxfooxfoxfooox', '*(fo|foo)')); assert(!isMatch('foooxfooxfxfooox', '*(fo|foo)')); assert(!isMatch('foooxfooxofoxfooox', '*(fo|foo)')); assert(!isMatch('foot', '*(fo|foo)')); assert(!isMatch('foox', '*(fo|foo)')); assert(!isMatch('ofoofo', '*(fo|foo)')); assert(!isMatch('ofooofoofofooo', '*(fo|foo)')); assert(!isMatch('ofoooxoofxo', '*(fo|foo)')); assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(fo|foo)')); assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(fo|foo)')); assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(fo|foo)')); assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(fo|foo)')); assert(!isMatch('ofxoofxo', '*(fo|foo)')); assert(!isMatch('oofooofo', '*(fo|foo)')); assert(!isMatch('ooo', '*(fo|foo)')); assert(!isMatch('oxfoxfox', '*(fo|foo)')); assert(!isMatch('oxfoxoxfox', '*(fo|foo)')); assert(!isMatch('xfoooofof', '*(fo|foo)')); }); it('should support exclusions', () => { assert(!isMatch('foob', '!(foo)b*')); assert(!isMatch('foobb', '!(foo)b*')); assert(!isMatch('foo', '!(foo)b*')); assert(isMatch('bar', '!(foo)b*')); assert(isMatch('baz', '!(foo)b*')); assert(!isMatch('foobar', '!(foo)b*')); assert(!isMatch('foo', '*(!(foo))')); assert(isMatch('bar', '*(!(foo))')); assert(isMatch('baz', '*(!(foo))')); assert(isMatch('foobar', '*(!(foo))')); // Bash 4.3 says this should match `foo` and `foobar`, which makes no sense assert(!isMatch('foo', '!(foo)*')); assert(!isMatch('foobar', '!(foo)*')); assert(isMatch('bar', '!(foo)*')); assert(isMatch('baz', '!(foo)*')); assert(!isMatch('moo.cow', '!(*.*)')); assert(isMatch('moo', '!(*.*)')); assert(isMatch('cow', '!(*.*)')); assert(isMatch('moo.cow', '!(a*).!(b*)')); assert(!isMatch('moo.cow', '!(*).!(*)')); assert(!isMatch('moo.cow.moo.cow', '!(*.*).!(*.*)')); assert(!isMatch('mad.moo.cow', '!(*.*).!(*.*)')); assert(!isMatch('moo.cow', '!(*.*).')); assert(!isMatch('moo', '!(*.*).')); assert(!isMatch('cow', '!(*.*).')); assert(!isMatch('moo.cow', '.!(*.*)')); assert(!isMatch('moo', '.!(*.*)')); assert(!isMatch('cow', '.!(*.*)')); assert(!isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?')); assert(isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))')); assert(isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))')); assert(isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))')); assert(!isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))')); assert(isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))')); }); it('valid numbers', () => { assert(isMatch('/dev/udp/129.22.8.102/45', '/dev/@(tcp|udp)/*/*')); assert(!isMatch('0', '[1-6]([0-9])')); assert(isMatch('12', '[1-6]([0-9])')); assert(!isMatch('1', '[1-6]([0-9])')); assert(!isMatch('12abc', '[1-6]([0-9])')); assert(!isMatch('555', '[1-6]([0-9])')); assert(!isMatch('0', '[1-6]*([0-9])')); assert(isMatch('12', '[1-6]*([0-9])')); assert(isMatch('1', '[1-6]*([0-9])')); assert(!isMatch('12abc', '[1-6]*([0-9])')); assert(isMatch('555', '[1-6]*([0-9])')); assert(!isMatch('0', '[1-5]*([6-9])')); assert(!isMatch('12', '[1-5]*([6-9])')); assert(isMatch('1', '[1-5]*([6-9])')); assert(!isMatch('12abc', '[1-5]*([6-9])')); assert(!isMatch('555', '[1-5]*([6-9])')); assert(isMatch('0', '0|[1-6]*([0-9])')); assert(isMatch('12', '0|[1-6]*([0-9])')); assert(isMatch('1', '0|[1-6]*([0-9])')); assert(!isMatch('12abc', '0|[1-6]*([0-9])')); assert(isMatch('555', '0|[1-6]*([0-9])')); assert(isMatch('07', '+([0-7])')); assert(isMatch('0377', '+([0-7])')); assert(!isMatch('09', '+([0-7])')); }); it('check extended globbing in pattern removal', () => { assert(isMatch('a', '+(a|abc)')); assert(isMatch('abc', '+(a|abc)')); assert(!isMatch('abcd', '+(a|abc)')); assert(!isMatch('abcde', '+(a|abc)')); assert(!isMatch('abcedf', '+(a|abc)')); assert(isMatch('f', '+(def|f)')); assert(isMatch('def', '+(f|def)')); assert(!isMatch('cdef', '+(f|def)')); assert(!isMatch('bcdef', '+(f|def)')); assert(!isMatch('abcedf', '+(f|def)')); assert(isMatch('abcd', '*(a|b)cd')); assert(!isMatch('a', '*(a|b)cd')); assert(!isMatch('ab', '*(a|b)cd')); assert(!isMatch('abc', '*(a|b)cd')); assert(!isMatch('a', '"*(a|b)cd"')); assert(!isMatch('ab', '"*(a|b)cd"')); assert(!isMatch('abc', '"*(a|b)cd"')); assert(!isMatch('abcde', '"*(a|b)cd"')); assert(!isMatch('abcdef', '"*(a|b)cd"')); }); it('More tests derived from a bug report (in bash) concerning extended glob patterns following a *', () => { assert(isMatch('/dev/udp/129.22.8.102/45', '/dev\\/@(tcp|udp)\\/*\\/*')); assert(!isMatch('123abc', '(a+|b)*')); assert(isMatch('ab', '(a+|b)*')); assert(isMatch('abab', '(a+|b)*')); assert(isMatch('abcdef', '(a+|b)*')); assert(isMatch('accdef', '(a+|b)*')); assert(isMatch('abcfefg', '(a+|b)*')); assert(isMatch('abef', '(a+|b)*')); assert(isMatch('abcfef', '(a+|b)*')); assert(isMatch('abd', '(a+|b)*')); assert(isMatch('acd', '(a+|b)*')); assert(!isMatch('123abc', '(a+|b)+')); assert(isMatch('ab', '(a+|b)+')); assert(isMatch('abab', '(a+|b)+')); assert(!isMatch('abcdef', '(a+|b)+')); assert(!isMatch('accdef', '(a+|b)+')); assert(!isMatch('abcfefg', '(a+|b)+')); assert(!isMatch('abef', '(a+|b)+')); assert(!isMatch('abcfef', '(a+|b)+')); assert(!isMatch('abd', '(a+|b)+')); assert(!isMatch('acd', '(a+|b)+')); assert(!isMatch('123abc', 'a(b*(foo|bar))d')); assert(!isMatch('ab', 'a(b*(foo|bar))d')); assert(!isMatch('abab', 'a(b*(foo|bar))d')); assert(!isMatch('abcdef', 'a(b*(foo|bar))d')); assert(!isMatch('accdef', 'a(b*(foo|bar))d')); assert(!isMatch('abcfefg', 'a(b*(foo|bar))d')); assert(!isMatch('abef', 'a(b*(foo|bar))d')); assert(!isMatch('abcfef', 'a(b*(foo|bar))d')); assert(isMatch('abd', 'a(b*(foo|bar))d')); assert(!isMatch('acd', 'a(b*(foo|bar))d')); assert(!isMatch('123abc', 'ab*(e|f)')); assert(isMatch('ab', 'ab*(e|f)')); assert(!isMatch('abab', 'ab*(e|f)')); assert(!isMatch('abcdef', 'ab*(e|f)')); assert(!isMatch('accdef', 'ab*(e|f)')); assert(!isMatch('abcfefg', 'ab*(e|f)')); assert(isMatch('abef', 'ab*(e|f)')); assert(!isMatch('abcfef', 'ab*(e|f)')); assert(!isMatch('abd', 'ab*(e|f)')); assert(!isMatch('acd', 'ab*(e|f)')); assert(!isMatch('123abc', 'ab**(e|f)')); assert(isMatch('ab', 'ab**(e|f)')); assert(isMatch('abab', 'ab**(e|f)')); assert(isMatch('abcdef', 'ab**(e|f)')); assert(!isMatch('accdef', 'ab**(e|f)')); assert(isMatch('abcfefg', 'ab**(e|f)')); assert(isMatch('abef', 'ab**(e|f)')); assert(isMatch('abcfef', 'ab**(e|f)')); assert(isMatch('abd', 'ab**(e|f)')); assert(!isMatch('acd', 'ab**(e|f)')); assert(!isMatch('123abc', 'ab**(e|f)g')); assert(!isMatch('ab', 'ab**(e|f)g')); assert(!isMatch('abab', 'ab**(e|f)g')); assert(!isMatch('abcdef', 'ab**(e|f)g')); assert(!isMatch('accdef', 'ab**(e|f)g')); assert(isMatch('abcfefg', 'ab**(e|f)g')); assert(!isMatch('abef', 'ab**(e|f)g')); assert(!isMatch('abcfef', 'ab**(e|f)g')); assert(!isMatch('abd', 'ab**(e|f)g')); assert(!isMatch('acd', 'ab**(e|f)g')); assert(!isMatch('123abc', 'ab***ef')); assert(!isMatch('ab', 'ab***ef')); assert(!isMatch('abab', 'ab***ef')); assert(isMatch('abcdef', 'ab***ef')); assert(!isMatch('accdef', 'ab***ef')); assert(!isMatch('abcfefg', 'ab***ef')); assert(isMatch('abef', 'ab***ef')); assert(isMatch('abcfef', 'ab***ef')); assert(!isMatch('abd', 'ab***ef')); assert(!isMatch('acd', 'ab***ef')); assert(!isMatch('123abc', 'ab*+(e|f)')); assert(!isMatch('ab', 'ab*+(e|f)')); assert(!isMatch('abab', 'ab*+(e|f)')); assert(isMatch('abcdef', 'ab*+(e|f)')); assert(!isMatch('accdef', 'ab*+(e|f)')); assert(!isMatch('abcfefg', 'ab*+(e|f)')); assert(isMatch('abef', 'ab*+(e|f)')); assert(isMatch('abcfef', 'ab*+(e|f)')); assert(!isMatch('abd', 'ab*+(e|f)')); assert(!isMatch('acd', 'ab*+(e|f)')); assert(!isMatch('123abc', 'ab*d*(e|f)')); assert(!isMatch('ab', 'ab*d*(e|f)')); assert(!isMatch('abab', 'ab*d*(e|f)')); assert(isMatch('abcdef', 'ab*d*(e|f)')); assert(!isMatch('accdef', 'ab*d*(e|f)')); assert(!isMatch('abcfefg', 'ab*d*(e|f)')); assert(!isMatch('abef', 'ab*d*(e|f)')); assert(!isMatch('abcfef', 'ab*d*(e|f)')); assert(isMatch('abd', 'ab*d*(e|f)')); assert(!isMatch('acd', 'ab*d*(e|f)')); assert(!isMatch('123abc', 'ab*d+(e|f)')); assert(!isMatch('ab', 'ab*d+(e|f)')); assert(!isMatch('abab', 'ab*d+(e|f)')); assert(isMatch('abcdef', 'ab*d+(e|f)')); assert(!isMatch('accdef', 'ab*d+(e|f)')); assert(!isMatch('abcfefg', 'ab*d+(e|f)')); assert(!isMatch('abef', 'ab*d+(e|f)')); assert(!isMatch('abcfef', 'ab*d+(e|f)')); assert(!isMatch('abd', 'ab*d+(e|f)')); assert(!isMatch('acd', 'ab*d+(e|f)')); assert(!isMatch('123abc', 'ab?*(e|f)')); assert(!isMatch('ab', 'ab?*(e|f)')); assert(!isMatch('abab', 'ab?*(e|f)')); assert(!isMatch('abcdef', 'ab?*(e|f)')); assert(!isMatch('accdef', 'ab?*(e|f)')); assert(!isMatch('abcfefg', 'ab?*(e|f)')); assert(isMatch('abef', 'ab?*(e|f)')); assert(isMatch('abcfef', 'ab?*(e|f)')); assert(isMatch('abd', 'ab?*(e|f)')); assert(!isMatch('acd', 'ab?*(e|f)')); }); it('bug in all versions up to and including bash-2.05b', () => { assert(isMatch('123abc', '*?(a)bc')); }); it('should work with character classes', () => { let opts = { posix: true }; assert(isMatch('a.b', 'a[^[:alnum:]]b', opts)); assert(isMatch('a,b', 'a[^[:alnum:]]b', opts)); assert(isMatch('a:b', 'a[^[:alnum:]]b', opts)); assert(isMatch('a-b', 'a[^[:alnum:]]b', opts)); assert(isMatch('a;b', 'a[^[:alnum:]]b', opts)); assert(isMatch('a b', 'a[^[:alnum:]]b', opts)); assert(isMatch('a_b', 'a[^[:alnum:]]b', opts)); assert(isMatch('a.b', 'a[-.,:\\;\\ _]b')); assert(isMatch('a,b', 'a[-.,:\\;\\ _]b')); assert(isMatch('a:b', 'a[-.,:\\;\\ _]b')); assert(isMatch('a-b', 'a[-.,:\\;\\ _]b')); assert(isMatch('a;b', 'a[-.,:\\;\\ _]b')); assert(isMatch('a b', 'a[-.,:\\;\\ _]b')); assert(isMatch('a_b', 'a[-.,:\\;\\ _]b')); assert(isMatch('a.b', 'a@([^[:alnum:]])b', opts)); assert(isMatch('a,b', 'a@([^[:alnum:]])b', opts)); assert(isMatch('a:b', 'a@([^[:alnum:]])b', opts)); assert(isMatch('a-b', 'a@([^[:alnum:]])b', opts)); assert(isMatch('a;b', 'a@([^[:alnum:]])b', opts)); assert(isMatch('a b', 'a@([^[:alnum:]])b', opts)); assert(isMatch('a_b', 'a@([^[:alnum:]])b', opts)); assert(isMatch('a.b', 'a@([-.,:; _])b')); assert(isMatch('a,b', 'a@([-.,:; _])b')); assert(isMatch('a:b', 'a@([-.,:; _])b')); assert(isMatch('a-b', 'a@([-.,:; _])b')); assert(isMatch('a;b', 'a@([-.,:; _])b')); assert(isMatch('a b', 'a@([-.,:; _])b')); assert(isMatch('a_b', 'a@([-.,:; _])b')); assert(isMatch('a.b', 'a@([.])b')); assert(!isMatch('a,b', 'a@([.])b')); assert(!isMatch('a:b', 'a@([.])b')); assert(!isMatch('a-b', 'a@([.])b')); assert(!isMatch('a;b', 'a@([.])b')); assert(!isMatch('a b', 'a@([.])b')); assert(!isMatch('a_b', 'a@([.])b')); assert(!isMatch('a.b', 'a@([^.])b')); assert(isMatch('a,b', 'a@([^.])b')); assert(isMatch('a:b', 'a@([^.])b')); assert(isMatch('a-b', 'a@([^.])b')); assert(isMatch('a;b', 'a@([^.])b')); assert(isMatch('a b', 'a@([^.])b')); assert(isMatch('a_b', 'a@([^.])b')); assert(isMatch('a.b', 'a@([^x])b')); assert(isMatch('a,b', 'a@([^x])b')); assert(isMatch('a:b', 'a@([^x])b')); assert(isMatch('a-b', 'a@([^x])b')); assert(isMatch('a;b', 'a@([^x])b')); assert(isMatch('a b', 'a@([^x])b')); assert(isMatch('a_b', 'a@([^x])b')); assert(isMatch('a.b', 'a+([^[:alnum:]])b', opts)); assert(isMatch('a,b', 'a+([^[:alnum:]])b', opts)); assert(isMatch('a:b', 'a+([^[:alnum:]])b', opts)); assert(isMatch('a-b', 'a+([^[:alnum:]])b', opts)); assert(isMatch('a;b', 'a+([^[:alnum:]])b', opts)); assert(isMatch('a b', 'a+([^[:alnum:]])b', opts)); assert(isMatch('a_b', 'a+([^[:alnum:]])b', opts)); assert(isMatch('a.b', 'a@(.|[^[:alnum:]])b', opts)); assert(isMatch('a,b', 'a@(.|[^[:alnum:]])b', opts)); assert(isMatch('a:b', 'a@(.|[^[:alnum:]])b', opts)); assert(isMatch('a-b', 'a@(.|[^[:alnum:]])b', opts)); assert(isMatch('a;b', 'a@(.|[^[:alnum:]])b', opts)); assert(isMatch('a b', 'a@(.|[^[:alnum:]])b', opts)); assert(isMatch('a_b', 'a@(.|[^[:alnum:]])b', opts)); }); it('should support POSIX character classes in extglobs', () => { let opts = { posix: true }; assert(isMatch('a.c', '+([[:alpha:].])', opts)); assert(isMatch('a.c', '+([[:alpha:].])+([[:alpha:].])', opts)); assert(isMatch('a.c', '*([[:alpha:].])', opts)); assert(isMatch('a.c', '*([[:alpha:].])*([[:alpha:].])', opts)); assert(isMatch('a.c', '?([[:alpha:].])?([[:alpha:].])?([[:alpha:].])', opts)); assert(isMatch('a.c', '@([[:alpha:].])@([[:alpha:].])@([[:alpha:].])', opts)); assert(!isMatch('.', '!(\\.)', opts)); assert(!isMatch('.', '!([[:alpha:].])', opts)); assert(isMatch('.', '?([[:alpha:].])', opts)); assert(isMatch('.', '@([[:alpha:].])', opts)); }); // ported from http://www.bashcookbook.com/bashinfo/source/bash-4.3/tests/extglob2.tests it('should pass extglob2 tests', () => { assert(!isMatch('baaac', '*(@(a))a@(c)')); assert(!isMatch('c', '*(@(a))a@(c)')); assert(!isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))')); assert(!isMatch('foooofof', '*(f+(o))')); assert(!isMatch('foooofofx', '*(f*(o))')); assert(!isMatch('foooxfooxofoxfooox', '*(f*(o)x)')); assert(!isMatch('ofooofoofofooo', '*(f*(o))')); assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)')); assert(!isMatch('oxfoxfox', '*(oxf+(ox))')); assert(!isMatch('xfoooofof', '*(f*(o))')); assert(isMatch('aaac', '*(@(a))a@(c)')); assert(isMatch('aac', '*(@(a))a@(c)')); assert(isMatch('abbcd', '@(ab|a*(b))*(c)d')); assert(isMatch('abcd', '?@(a|b)*@(c)d')); assert(isMatch('abcd', '@(ab|a*@(b))*(c)d')); assert(isMatch('ac', '*(@(a))a@(c)')); assert(isMatch('acd', '@(ab|a*(b))*(c)d')); assert(isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))')); assert(isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))')); assert(isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))')); assert(isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))')); assert(isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))')); assert(isMatch('ffo', '*(f*(o))')); assert(isMatch('fofo', '*(f*(o))')); assert(isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))')); assert(isMatch('fooofoofofooo', '*(f*(o))')); assert(isMatch('foooofo', '*(f*(o))')); assert(isMatch('foooofof', '*(f*(o))')); assert(isMatch('foooxfooxfoxfooox', '*(f*(o)x)')); assert(isMatch('foooxfooxfxfooox', '*(f*(o)x)')); assert(isMatch('ofoofo', '*(of+(o))')); assert(isMatch('ofoofo', '*(of+(o)|f)')); assert(isMatch('ofoooxoofxo', '*(*(of*(o)x)o)')); assert(isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)')); assert(isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)')); assert(isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)')); assert(isMatch('ofxoofxo', '*(*(of*(o)x)o)')); assert(isMatch('oofooofo', '*(of|oof+(o))')); assert(isMatch('oxfoxoxfox', '*(oxf+(ox))')); }); it('should support backtracking in alternation matches', () => { assert(isMatch('fofoofoofofoo', '*(fo|foo)')); }); it('should support exclusions', () => { assert(!isMatch('f', '!(f)')); assert(!isMatch('f', '*(!(f))')); assert(!isMatch('f', '+(!(f))')); assert(!isMatch('foo', '!(foo)')); assert(!isMatch('foob', '!(foo)b*')); assert(!isMatch('mad.moo.cow', '!(*.*).!(*.*)')); assert(!isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?')); assert(!isMatch('zoot', '@(!(z*)|*x)')); assert(isMatch('fff', '!(f)')); assert(isMatch('fff', '*(!(f))')); assert(isMatch('fff', '+(!(f))')); assert(isMatch('foo', '!(f)')); assert(isMatch('foo', '!(x)')); assert(isMatch('foo', '!(x)*')); assert(isMatch('foo', '*(!(f))')); assert(isMatch('foo', '+(!(f))')); assert(isMatch('foobar', '!(foo)')); assert(isMatch('foot', '@(!(z*)|*x)')); assert(isMatch('foox', '@(!(z*)|*x)')); assert(isMatch('ooo', '!(f)')); assert(isMatch('ooo', '*(!(f))')); assert(isMatch('ooo', '+(!(f))')); assert(isMatch('zoox', '@(!(z*)|*x)')); }); }); micromatch-4.0.5/test/fixtures/000077500000000000000000000000001421714312500164765ustar00rootroot00000000000000micromatch-4.0.5/test/fixtures/dotglob.txt000066400000000000000000000007441421714312500206760ustar00rootroot00000000000000f a/b/.x **/.x/** f .x **/.x/** t .x/ **/.x/** t .x/a **/.x/** t .x/a/b **/.x/** f .x/.x **/.x/** f a/.x **/.x/** t a/b/.x/c **/.x/** t a/b/.x/c/d **/.x/** t a/b/.x/c/d/e **/.x/** t a/b/.x/ **/.x/** t a/.x/b **/.x/** f a/.x/b/.x/c **/.x/** f .bashrc ?bashrc f .bar.baz/ .*.* t .bar.baz/ .*.*/ t .bar.baz .*.* micromatch-4.0.5/test/fixtures/extglob000066400000000000000000000177221421714312500200760ustar00rootroot00000000000000 f foooofof *(f+(o)) f foooofofx *(f*(o)) f foooxfooxofoxfooox *(f*(o)x) f ofooofoofofooo *(f*(o)) f xfoooofof *(f*(o)) f ofoooxoofxoofoooxoofxofo *(*(of*(o)x)o) t ffo *(f*(o)) t fofo *(f*(o)) t fooofoofofooo *(f*(o)) t foooofo *(f*(o)) t foooofof *(f*(o)) t foooxfooxfoxfooox *(f*(o)x) t foooxfooxfxfooox *(f*(o)x) t ofoooxoofxo *(*(of*(o)x)o) t ofoooxoofxoofoooxoofxo *(*(of*(o)x)o) t ofoooxoofxoofoooxoofxoo *(*(of*(o)x)o) t ofoooxoofxoofoooxoofxooofxofxo *(*(of*(o)x)o) t ofxoofxo *(*(of*(o)x)o) t ofxoofxo *(*(of*(o)x)o) t aac *(@(a))a@(c) t ac *(@(a))a@(c) f c *(@(a))a@(c) t aaac *(@(a))a@(c) f baaac *(@(a))a@(c) t abcd ?@(a|b)*@(c)d t abcd @(ab|a*@(b))*(c)d t acd @(ab|a*(b))*(c)d t abbcd @(ab|a*(b))*(c)d t effgz @(b+(c)d|e*(f)g?|?(h)i@(j|k)) t efgz @(b+(c)d|e*(f)g?|?(h)i@(j|k)) t egz @(b+(c)d|e*(f)g?|?(h)i@(j|k)) t egzefffgzbcdij *(b+(c)d|e*(f)g?|?(h)i@(j|k)) f egz @(b+(c)d|e+(f)g?|?(h)i@(j|k)) t ofoofo *(of+(o)) t oxfoxoxfox *(oxf+(ox)) f oxfoxfox *(oxf+(ox)) t ofoofo *(of+(o)|f) # The following is supposed to match only as fo+ofo+ofo t foofoofo @(foo|f|fo)*(f|of+(o)) t oofooofo *(of|oof+(o)) t fffooofoooooffoofffooofff *(*(f)*(o)) # The following tests backtracking in alternation matches t fofoofoofofoo *(fo|foo) # Exclusion t foo !(x) t foo !(x)* f foo !(foo) t foobar !(foo) t foo !(foo)* t bar !(foo)* t baz !(foo)* t foobar !(foo)* t moo.cow !(*.*).!(*.*) f mad.moo.cow !(*.*).!(*.*) f moo .!(*.*) f cow .!(*.*) f moo.cow .!(*.*) f mad.moo.cow .!(*.*) f mucca.pazza mu!(*(c))?.pa!(*(z))? t fff !(f) t ooo !(f) t foo !(f) f f !(f) t fff *(!(f)) t ooo *(!(f)) t foo *(!(f)) f f *(!(f)) t fff +(!(f)) t ooo +(!(f)) t foo +(!(f)) f f +(!(f)) t foot @(!(z*)|*x) f zoot @(!(z*)|*x) t foox @(!(z*)|*x) t zoox @(!(z*)|*x) t foo *(!(foo)) f foob !(foo)b* t foobb !(foo)b* f a.b !(*.*) t abb !(*.*) t ab !(*.*) f a.a !(*.a|*.b|*.c) t a.abcd !(*.a|*.b|*.c) t a.c.d !(*.a|*.b|*.c) t a. !(*.a|*.b|*.c) t d.d !(*.a|*.b|*.c) t e.e !(*.a|*.b|*.c) t f.f !(*.a|*.b|*.c) f f.a !(*.a|*.b|*.c) t a.abcd *!(.a|.b|.c) t a.c.d *!(.a|.b|.c) t a. *!(.a|.b|.c) t d.d *!(.a|.b|.c) t e.e *!(.a|.b|.c) t f.f *!(.a|.b|.c) t f.a *!(.a|.b|.c) t a.abcd *.!(a|b|c) t a.c.d *.!(a|b|c) t a. *.!(a|b|c) t d.d *.!(a|b|c) t e.e *.!(a|b|c) t f.f *.!(a|b|c) f f.a *.!(a|b|c) f abd a!(@(b|B))d t acd a!(@(b|B))d f ab a!(@(b|B)) f aB a!(@(b|B)) t ab] a!(@(b|B)) t aBc a!(@(b|B)) t abd a!(@(b|B)) t ac a!(@(b|B)) t acd a!(@(b|B)) f a (a) t a *(a) t a +(a) f a !(a) t aa !(a) f aa @(a)b f aab @(c)b f ab a(*b t a(b a(*b t a((b a(*b t a((((b a(*b t a ? f aa ? f aab ? f a (b) t a ?(a|b) t a a?(a|b) f a b?(a|b) t ba b?(a|b) f bb a?(a|b) f aa ? f aab ? f a ?? t aa ?? f aab ?? f a a??b f aa a??b f aab a??b t aaab a??b t a a?(x) t foo.js.js *.!(js) f foo.js.js *.!(js)* f foo.js.js *.!(js)+ f foo.js.js *.!(js)*.!(js) f a.js *.!(js) t a.js.js *.!(js) f c.js *.!(js) t a.md *.!(js) t d.js.d *.!(js) f a.js !(*.js) f a.js.js !(*.js) f c.js !(*.js) t a.md !(*.js) t d.js.d !(*.js) t a.js *!(.js) t a.js.js *!(.js) t c.js *!(.js) t a.md *!(.js) t d.js.d *!(.js) t a.a *!(.a|.b|.c) t a.b *!(.a|.b|.c) t a.c *!(.a|.b|.c) t a.c.d *!(.a|.b|.c) t c.c *!(.a|.b|.c) t a. *!(.a|.b|.c) t d.d *!(.a|.b|.c) t e.e *!(.a|.b|.c) t f.f *!(.a|.b|.c) t a.abcd *!(.a|.b|.c) t b/b.txt b/!(c).txt f b/c.txt b/!(c).txt f b/cc.txt b/!(c).txt f b/ccc.txt b/!(c).txt t *(a|b[) *(a|b\\[) t parse.y !(*.c|*.h|Makefile.in|config*|README) f shell.c !(*.c|*.h|Makefile.in|config*|README) t Makefile !(*.c|*.h|Makefile.in|config*|README) f Makefile.in !(*.c|*.h|Makefile.in|config*|README) f a.a *.!(a) t a.b *.!(a) t a.a.a *.!(a) f c.a *.!(a) t a. *.!(a) t d.a.d *.!(a) f ax a?(b*) t ax ?(a*|b) t ab ab**(e|f) t abcdef ab**(e|f) t abef ab**(e|f) t abcfef ab**(e|f) f ab ab**(e|f)g f abcdef ab**(e|f)g f abef ab**(e|f)g f abcfef ab**(e|f)g f ab ab*+(e|f) t abcdef ab*+(e|f) t abef ab*+(e|f) t abcfef ab*+(e|f) f ab ab*d+(e|f) t abcdef ab*d+(e|f) f abef ab*d+(e|f) f abcfef ab*d+(e|f) f ab ab?*(e|f) f abcdef ab?*(e|f) t abef ab?*(e|f) t abcfef ab?*(e|f) f 123abc ab?*(e|f) f ab ab?*(e|f) f abcdef ab?*(e|f) f abcfefg ab?*(e|f) t abef ab?*(e|f) t abcfef ab?*(e|f) t abd ab?*(e|f) f acd ab?*(e|f) f 123abc ab*d+(e|f) f ab ab*d+(e|f) t abcdef ab*d+(e|f) f abcfefg ab*d+(e|f) f abef ab*d+(e|f) f abcfef ab*d+(e|f) f abd ab*d+(e|f) f acd ab*d+(e|f) f ab (a+|b)+ f abcdef (a+|b)+ f abcfefg (a+|b)+ f abef (a+|b)+ f abcfef (a+|b)+ f abd (a+|b)+ f acd (a+|b)+ f b (a+|b)* f zz (a+|b)* f abcdef (a+|b)* f abcfefg (a+|b)* f abef (a+|b)* f abcfef (a+|b)* f abd (a+|b)* f acd (a+|b)* f a.a !(*[a-b].[a-b]*) f a.b !(*[a-b].[a-b]*) f a.a.a !(*[a-b].[a-b]*) t c.a !(*[a-b].[a-b]*) t d.a.d !(*[a-b].[a-b]*) f a.bb !(*[a-b].[a-b]*) t a.ccc !(*[a-b].[a-b]*) t c.ccc !(*[a-b].[a-b]*) f a.a !(*.[a-b]*) f a.b !(*.[a-b]*) f a.a.a !(*.[a-b]*) f c.a !(*.[a-b]*) f d.a.d !(*.[a-b]*) f a.bb !(*.[a-b]*) t a.ccc !(*.[a-b]*) t c.ccc !(*.[a-b]*) f a.a !*.(a|b) f a.b !*.(a|b) f a.a.a !*.(a|b) f c.a !*.(a|b) f d.a.d !*.(a|b) f a.bb !*.(a|b) f a.ccc !*.(a|b) f a.a !*.(a|b)* f a.b !*.(a|b)* f a.a.a !*.(a|b)* f c.a !*.(a|b)* f d.a.d !*.(a|b)* f a.bb !*.(a|b)* f a.ccc !*.(a|b)* f a.a (a|d).(a|b)* f a.b (a|d).(a|b)* f a.bb (a|d).(a|b)* f a.a *.+(b|d) t a.b *.+(b|d) f a.a.a *.+(b|d) f c.a *.+(b|d) f a. *.+(b|d) t d.a.d *.+(b|d) t a.bb *.+(b|d) f a.ccc *.+(b|d) micromatch-4.0.5/test/fixtures/glob.txt000066400000000000000000000040151421714312500201620ustar00rootroot00000000000000f a/b/.x **/.x/** f .x **/.x/** t .x/ **/.x/** t .x/a **/.x/** t .x/a/b **/.x/** f .x/.x **/.x/** f a/.x **/.x/** t a/b/.x/c **/.x/** t a/b/.x/c/d **/.x/** t a/b/.x/c/d/e **/.x/** t a/b/.x/ **/.x/** t a/.x/b **/.x/** f a/.x/b/.x/c **/.x/** t a/c/b a/*/b f a/.d/b a/*/b f a/./b a/*/b f a/../b a/*/b t ab ab** t abcdef ab** t abef ab** t abcfef ab** f ab ab***ef t abcdef ab***ef t abef ab***ef t abcfef ab***ef f .bashrc ?bashrc f abbc ab?bc f abc ab?bc t a.a [a-d]*.[a-b] t a.b [a-d]*.[a-b] t c.a [a-d]*.[a-b] t a.a.a [a-d]*.[a-b] t a.a.a [a-d]*.[a-b]*.[a-b] t a.a *.[a-b] t a.b *.[a-b] t a.a.a *.[a-b] t c.a *.[a-b] f d.a.d *.[a-b] f a.bb *.[a-b] f a.ccc *.[a-b] f c.ccc *.[a-b] t a.a *.[a-b]* t a.b *.[a-b]* t a.a.a *.[a-b]* t c.a *.[a-b]* t d.a.d *.[a-b]* f d.a.d *.[a-b]*.[a-b]* t d.a.d *.[a-d]*.[a-d]* t a.bb *.[a-b]* f a.ccc *.[a-b]* f c.ccc *.[a-b]* t a.a *[a-b].[a-b]* t a.b *[a-b].[a-b]* t a.a.a *[a-b].[a-b]* f c.a *[a-b].[a-b]* f d.a.d *[a-b].[a-b]* t a.bb *[a-b].[a-b]* f a.ccc *[a-b].[a-b]* f c.ccc *[a-b].[a-b]* t abd [a-y]*[^c] t abe [a-y]*[^c] t bb [a-y]*[^c] t bcd [a-y]*[^c] t ca [a-y]*[^c] t cb [a-y]*[^c] t dd [a-y]*[^c] t de [a-y]*[^c] t bdir/ [a-y]*[^c] t abd **/* micromatch-4.0.5/test/fixtures/globstar.txt000066400000000000000000000011751421714312500210600ustar00rootroot00000000000000t a.js **/*.js t a/a.js **/*.js t a/a/b.js **/*.js t a/b/z.js a/b/**/*.js t a/b/c/z.js a/b/**/*.js t foo.md **/*.md t foo/bar.md **/*.md t foo/bar foo/**/bar t foo/bar foo/**bar t ab/a/d **/* t ab/b **/* t a/b/c/d/a.js **/* t a/b/c.js **/* t a/b/c.txt **/* f a/b/.js/c.txt **/* t a.js **/* t za.js **/* t ab **/* t a.b **/* t foo/ foo/**/ f foo/bar foo/**/ f foo/bazbar foo/**/ f foo/barbar foo/**/ f foo/bar/baz/qux foo/**/ t foo/bar/baz/qux/ foo/**/ micromatch-4.0.5/test/fixtures/negation000066400000000000000000000003301421714312500202210ustar00rootroot00000000000000f a/b.js !**/*.md f a.js !**/*.md f a/b.md !**/*.md f a.md !**/*.md f a/b.js !*.md f a.js !*.md f a/b.md !*.md f a.md !*.md f a.js !**/*.md f b.md !**/*.md f c.txt !**/*.mdmicromatch-4.0.5/test/fixtures/patterns.js000066400000000000000000000204071421714312500206770ustar00rootroot00000000000000'use strict'; /** * The contents of this file was copied (and modified) from: * minimatch v3.0.3, ISC LICENSE, Copyright (c) Isaac Z. Schlueter and Contributors * https://github.com/isaacs/minimatch */ let fixtures = ['a', 'b', 'c', 'd', 'abc', 'abd', 'abe', 'bb', 'bcd', 'ca', 'cb', 'dd', 'de', 'bdir/', 'bdir/cfile']; // pattern | expected | options | fixtures module.exports = [ 'http://www.bashcookbook.com/bashinfo/source/bash-1.14.7/tests/glob-test', ['a*', ['a', 'abc', 'abd', 'abe']], ['X*', ['X*'], {nonull: true}], 'allow null glob expansion', ['X*', []], 'micromatch has same results as Bash. Minimatch does this differently', ['\\*', ['\\*'], {nonull: true}], ['\\**', ['\\**'], {nonull: true}], ['\\*\\*', ['\\*\\*'], {nonull: true}], ['b*/', ['bdir/']], ['c*', ['c', 'ca', 'cb']], ['**', fixtures], ['\\.\\./*/', ['\\.\\./*/'], {nonull: true}], ['s/\\..*//', ['s/\\..*//'], {nonull: true}], 'legendary larry crashes bashes', ['/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\\1/', ['/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\\1/'], {nonull: true, bash: {skip: true}}], ['/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\u0001/', ['/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\u0001/'], {nonull: true, bash: {skip: true}}], /** * Character classes */ 'character classes', ['[a-c]b*', ['abc', 'abd', 'abe', 'bb', 'cb']], ['[a-y]*[^c]', ['abd', 'abe', 'bb', 'bcd', 'bdir/', 'ca', 'cb', 'dd', 'de'], {bash: true}], ['a*[^c]', ['abd', 'abe']], () => { fixtures.push('a-b', 'aXb'); }, ['a[X-]b', ['a-b', 'aXb']], () => { fixtures.push('.x', '.y'); }, ['[^a-c]*', ['d', 'dd', 'de']], () => { fixtures.push('a*b/', 'a*b/ooo', 'ab/ooo'); }, 'trailing slashes', ['a*b/*', ['ab/ooo', 'a*b/ooo']], ['a*?/*', ['ab/ooo', 'a*b/ooo']], ['a\\*b/*', ['a*b/ooo']], ['a\\*?/*', ['a*b/ooo']], ['*\\\\!*', [], {null: true}, ['echo !7']], ['*\\!*', ['echo !7'], null, ['echo !7']], ['*.\\*', ['r.*'], null, ['r.*']], ['a[b]c', ['abc']], ['a[\\\\b]c', ['abc']], ['a?c', ['abc']], ['a\\*c', [], {null: true}, ['abc']], /** * Bash tests */ 'http://www.opensource.apple.com/source/bash/bash-23/bash/tests/glob-test', () => { fixtures.push('man/', 'man/man1/', 'man/man1/bash.1'); }, ['*/man*/bash.*', ['man/man1/bash.1']], ['man/man1/bash.1', ['man/man1/bash.1']], ['a***c', ['abc'], null, ['abc']], ['a*****?c', ['abc'], null, ['abc']], ['?*****??', ['abc'], null, ['abc']], ['*****??', ['abc'], null, ['abc']], ['?*****?c', ['abc'], null, ['abc']], ['?***?****c', ['abc'], null, ['abc']], ['?***?****?', ['abc'], null, ['abc']], ['?***?****', ['abc'], null, ['abc']], ['*******c', ['abc'], null, ['abc']], ['*******?', ['abc'], null, ['abc']], ['a*cd**?**??k', ['abcdecdhjk'], null, ['abcdecdhjk']], ['a**?**cd**?**??k', ['abcdecdhjk'], null, ['abcdecdhjk']], ['a**?**cd**?**??k***', ['abcdecdhjk'], null, ['abcdecdhjk']], ['a**?**cd**?**??***k', ['abcdecdhjk'], null, ['abcdecdhjk']], ['a**?**cd**?**??***k**', ['abcdecdhjk'], null, ['abcdecdhjk']], ['a****c**?**??*****', ['abcdecdhjk'], null, ['abcdecdhjk']], ['[-abc]', ['-'], null, ['-']], ['[abc-]', ['-'], null, ['-']], ['[[]', ['['], null, ['[']], ['[', ['['], null, ['[']], ['[*', ['[abc'], null, ['[abc']], 'a right bracket shall lose its special meaning and represent itself in a bracket expression if it occurs first in the list. -- POSIX.2 2.8.3.2', ['[]]', [']'], null, [']']], ['[]-]', [']'], null, [']']], ['[a-\z]', ['p'], null, ['p']], ['??**********?****?', [], { null: true }, ['abc']], ['??**********?****c', [], { null: true }, ['abc']], ['?************c****?****', [], { null: true }, ['abc']], ['*c*?**', [], { null: true }, ['abc']], ['a*****c*?**', [], { null: true }, ['abc']], ['a********???*******', [], { null: true }, ['abc']], ['[]', [], { null: true }, ['a']], ['[abc', [], { null: true }, ['[']], 'nocase tests', ['XYZ', ['xYz'], { nocase: true, null: true }, ['xYz', 'ABC', 'IjK']], [ 'ab*', ['ABC'], { nocase: true, null: true }, ['xYz', 'ABC', 'IjK'] ], [ '[ia]?[ck]', ['ABC', 'IjK'], { nocase: true, null: true }, ['xYz', 'ABC', 'IjK'] ], 'braces: onestar/twostar', ['{/*,*}', [], {null: true}, ['/asdf/asdf/asdf']], ['{/?,*}', ['/a', 'bb'], {null: true}, ['/a', '/b/b', '/a/b/c', 'bb']], 'dots should not match unless requested', ['**', ['a/b'], {}, ['a/b', 'a/.d', '.a/.d']], // .. and . can only match patterns starting with ., // even when options.dot is set. () => { fixtures = ['a/./b', 'a/../b', 'a/c/b', 'a/.d/b']; }, ['a/*/b', ['a/c/b', 'a/.d/b'], {dot: true}], ['a/*/b', ['a/c/b'], {dot: false}], ['a/.*/b', ['a/./b', 'a/../b', 'a/.d/b'], {dot: true}], ['a/.*/b', ['a/./b', 'a/../b', 'a/.d/b'], {dot: false}], // this also tests that changing the options needs // to change the cache key, even if the pattern is // the same! ['**', ['a/b', 'a/.d', '.a/.d'], { dot: true }, [ '.a/.d', 'a/.d', 'a/b'] ], // '~~paren sets cannot contain slashes~~', // 'paren sets _can_ contain slashes', ['*(a/b)', ['a/b'], {}, ['a/b']], // brace sets trump all else. // // invalid glob pattern. fails on bash4 and bsdglob. // however, in this implementation, it's easier just // to do the intuitive thing, and let brace-expansion // actually come before parsing any extglob patterns, // like the documentation seems to say. // // XXX: if anyone complains about this, either fix it // or tell them to grow up and stop complaining. // // bash/bsdglob says this: // ["*(a|{b),c)}", ["*(a|{b),c)}"], {}, ["a", "ab", "ac", "ad"]], // but we do this instead: ['*(a|{b),c)}', ['a', 'ab', 'ac'], {expand: true}, ['a', 'ab', 'ac', 'ad']], // test partial parsing in the presence of comment/negation chars ['[!a*', ['[!ab'], {}, ['[!ab', '[ab']], // like: {a,b|c\\,d\\\|e} except it's unclosed, so it has to be escaped. // [ // '+(a|*\\|c\\\\|d\\\\\\|e\\\\\\\\|f\\\\\\\\\\|g', // ['+(a|b\\|c\\\\|d\\\\|e\\\\\\\\|f\\\\\\\\|g'], // {}, // ['+(a|b\\|c\\\\|d\\\\|e\\\\\\\\|f\\\\\\\\|g', 'a', 'b\\c'] // ], // crazy nested {,,} and *(||) tests. () => { fixtures = [ 'a', 'b', 'c', 'd', 'ab', 'ac', 'ad', 'bc', 'cb', 'bc,d', 'c,db', 'c,d', 'd)', '(b|c', '*(b|c', 'b|c', 'b|cc', 'cb|c', 'x(a|b|c)', 'x(a|c)', '(a|b|c)', '(a|c)' ]; }, ['*(a|{b,c})', ['a', 'b', 'c', 'ab', 'ac'], {expand: true}], // ['{a,*(b|c,d)}', ['a', '(b|c', '*(b|c', 'd)'], {expand: true}], //<= minimatch (wrong) ['{a,*(b|c,d)}', ['a', 'b', 'bc,d', 'c,db', 'c,d'], {expand: true}], // a // *(b|c) // *(b|d) ['{a,*(b|{c,d})}', ['a', 'b', 'bc', 'cb', 'c', 'd'], {expand: true}], ['*(a|{b|c,c})', ['a', 'b', 'c', 'ab', 'ac', 'bc', 'cb']], ['*(a|{b|c,c})', ['a', 'b', 'c', 'ab', 'ac', 'bc', 'cb'], {expand: true}], // test various flag settings. ['a?b', ['acb', 'acb/'], {}, ['x/y/acb', 'acb', 'acb/', 'acb/d/e']], ['a?b', ['x/y/acb', 'acb/', 'acb'], {matchBase: true}, ['x/y/acb', 'acb', 'acb/', 'acb/d/e']], // begin channelling Boole and deMorgan... 'negation tests', () => { fixtures = ['d', 'e', '!ab', '!abc', 'a!b']; }, // anything that is NOT a* matches. ['!a*', ['d', 'e', '!ab', '!abc']], // anything that IS !a* matches. ['!a*', ['!ab', '!abc'], {nonegate: true}], // anything that IS a* matches ['a*', ['a!b']], // anything that is NOT !a* matches ['!\\!a*', ['a!b', 'd', 'e']], // negation nestled within a pattern () => { fixtures = [ 'foo.js', 'foo.bar', 'foo.js.js', 'blar.js', 'foo.', 'boo.js.boo' ]; }, // last one is tricky! * matches foo, . matches ., and 'js.js' != 'js' // copy bash 4.3 behavior on this. 'https://github.com/isaacs/minimatch/issues/5', () => { fixtures = [ 'a/b/.x/c', 'a/b/.x/c/d', 'a/b/.x/c/d/e', 'a/b/.x', 'a/b/.x/', 'a/.x/b', '.x', '.x/', '.x/a', '.x/a/b', 'a/.x/b/.x/c', '.x/.x' ]; }, [ '**/.x/**', [ '.x/', '.x/a', '.x/a/b', 'a/.x/b', 'a/b/.x/', 'a/b/.x/c', 'a/b/.x/c/d', 'a/b/.x/c/d/e' ] ], 'https://github.com/isaacs/minimatch/issues/59', ['[z-a]', []], ['a/[2015-03-10T00:23:08.647Z]/z', []], ['[a-0][a-\u0100]', []] ]; Object.defineProperty(module.exports, 'fixtures', { get: () => { return fixtures; } }); micromatch-4.0.5/test/globstars.js000066400000000000000000000002531421714312500171630ustar00rootroot00000000000000'use strict'; require('mocha'); const assert = require('assert'); const mm = require('..'); const { isMatch } = require('..'); describe('globstars - "**"', () => { }); micromatch-4.0.5/test/issue-related.js000066400000000000000000000054751421714312500177440ustar00rootroot00000000000000'use strict'; const assert = require('assert'); const mm = require('..'); describe('issue-related tests', () => { it('micromatch issue #140', () => { let a = ['a/b/some/c.md', 'a/b/c.md', 'a/b-b/c.md', 'a/bb/c.md', 'a/bbc/c.md']; assert.deepEqual(mm(a, '**/b/**/c.md'), ['a/b/some/c.md', 'a/b/c.md']); let b = ['packages/foo-foo/package.json', 'packages/foo/package.json']; assert.deepEqual(mm(b, '**/foo/**/package.json'), ['packages/foo/package.json']); }); it('micromatch issue#15', () => { assert(mm.isMatch('a/b-c/d/e/z.js', 'a/b-*/**/z.js')); assert(mm.isMatch('z.js', 'z*')); assert(mm.isMatch('z.js', '**/z*')); assert(mm.isMatch('z.js', '**/z*.js')); assert(mm.isMatch('z.js', '**/*.js')); assert(mm.isMatch('foo', '**/foo')); }); it('micromatch issue#23', () => { assert(!mm.isMatch('zzjs', 'z*.js')); assert(!mm.isMatch('zzjs', '*z.js')); }); it('micromatch issue#24', () => { assert(!mm.isMatch('a/b/c/d/', 'a/b/**/f')); assert(mm.isMatch('a', 'a/**')); assert(mm.isMatch('a', '**')); assert(mm.isMatch('a/', '**')); assert(mm.isMatch('a/b/c/d', '**')); assert(mm.isMatch('a/b/c/d/', '**')); assert(mm.isMatch('a/b/c/d/', '**/**')); assert(mm.isMatch('a/b/c/d/', '**/b/**')); assert(mm.isMatch('a/b/c/d/', 'a/b/**')); assert(mm.isMatch('a/b/c/d/', 'a/b/**/')); assert(mm.isMatch('a/b/c/d/e.f', 'a/b/**/**/*.*')); assert(mm.isMatch('a/b/c/d/e.f', 'a/b/**/*.*')); assert(mm.isMatch('a/b/c/d/g/e.f', 'a/b/**/d/**/*.*')); assert(mm.isMatch('a/b/c/d/g/g/e.f', 'a/b/**/d/**/*.*')); }); it('micromatch issue#58 - only match nested dirs when `**` is the only thing in a segment', () => { assert(!mm.isMatch('a/b/c', 'a/b**')); assert(!mm.isMatch('a/c/b', 'a/**b')); }); it('micromatch issue#63 (dots)', () => { assert(!mm.isMatch('/aaa/.git/foo', '/aaa/**/*')); assert(!mm.isMatch('/aaa/bbb/.git', '/aaa/bbb/*')); assert(!mm.isMatch('/aaa/bbb/.git', '/aaa/bbb/**')); assert(!mm.isMatch('/aaa/bbb/ccc/.git', '/aaa/bbb/**')); assert(!mm.isMatch('aaa/bbb/.git', 'aaa/bbb/**')); assert(mm.isMatch('/aaa/.git/foo', '/aaa/**/*', { dot: true })); assert(mm.isMatch('/aaa/bbb/', '/aaa/bbb/**')); assert(mm.isMatch('/aaa/bbb/.git', '/aaa/bbb/*', { dot: true })); assert(mm.isMatch('/aaa/bbb/.git', '/aaa/bbb/**', { dot: true })); assert(mm.isMatch('/aaa/bbb/ccc/.git', '/aaa/bbb/**', { dot: true })); assert(mm.isMatch('/aaa/bbb/foo', '/aaa/bbb/**')); assert(mm.isMatch('aaa/bbb/.git', 'aaa/bbb/**', { dot: true })); }); it('micromatch issue#79', () => { assert(mm.isMatch('a/foo.js', '**/foo.js')); assert(mm.isMatch('foo.js', '**/foo.js')); assert(mm.isMatch('a/foo.js', '**/foo.js', { dot: true })); assert(mm.isMatch('foo.js', '**/foo.js', { dot: true })); }); }); micromatch-4.0.5/test/malicious.js000066400000000000000000000016551421714312500171570ustar00rootroot00000000000000'use strict'; const assert = require('assert'); const mm = require('..'); const generate = n => '\\'.repeat(n); /** * These tests are based on minimatch unit tests */ describe('handling of potential regex exploits', () => { it('should support long escape sequences', () => { assert(mm.isMatch('A', `!(${generate(65500)}A)`), 'within the limits, and valid match'); assert(!mm.isMatch('A', `[!(${generate(65500)}A`), 'within the limits, but invalid regex'); }); it('should throw an error when the pattern is too long', () => { assert.throws(() => { assert(!mm.isMatch('A', `!(${generate(65536)}A)`)); }, /Input length: 65540, exceeds maximum allowed length: 65536/); }); it('should allow max bytes to be customized', () => { assert.throws(() => { assert(!mm.isMatch('A', `!(${generate(500)}A)`, { maxLength: 499 })); }, /Input length: 504, exceeds maximum allowed length: 499/); }); }); micromatch-4.0.5/test/micromatch.js000066400000000000000000000217471421714312500173240ustar00rootroot00000000000000'use strict'; const assert = require('assert'); const path = require('path'); const mm = require('..'); const sep = path.sep; describe('micromatch', () => { afterEach(() => (path.sep = sep)); after(() => (path.sep = sep)); describe('empty list', () => { it('should return an empty array', () => { assert.deepEqual(mm([], '*'), []); }); }); describe('posix paths', () => { it('should return an array of matches', () => { assert.deepEqual(mm(['a', 'a', 'a'], ['*', 'a*']), ['a']); }); it('should return an array of matches for a literal string', () => { assert.deepEqual(mm(['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c'], '(a/b)'), ['a/b']); assert.deepEqual(mm(['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c'], 'a/b'), ['a/b']); }); it('should return an array of matches for an array of literal strings', () => { assert.deepEqual(mm(['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c'], ['(a/b)', 'a/c']), ['a/b', 'a/c']); assert.deepEqual(mm(['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c'], ['a/b', 'b/b']), ['a/b', 'b/b']); }); it('should support regex logical or', () => { assert.deepEqual(mm(['a/a', 'a/b', 'a/c'], ['a/(a|c)']), ['a/a', 'a/c']); assert.deepEqual(mm(['a/a', 'a/b', 'a/c'], ['a/(a|b|c)', 'a/b']), ['a/a', 'a/b', 'a/c']); }); it('should support regex ranges', () => { assert.deepEqual(mm(['a/a', 'a/b', 'a/c'], 'a/[b-c]'), ['a/b', 'a/c']); assert.deepEqual(mm(['a/a', 'a/b', 'a/c', 'a/x/y', 'a/x'], 'a/[a-z]'), ['a/a', 'a/b', 'a/c', 'a/x']); }); it('should support single globs (*)', () => { let fixtures = ['a', 'b', 'a/a', 'a/b', 'a/c', 'a/x', 'a/a/a', 'a/a/b', 'a/a/a/a', 'a/a/a/a/a', 'x/y', 'z/z']; assert.deepEqual(mm(fixtures, ['*']), ['a', 'b']); assert.deepEqual(mm(fixtures, ['*/*']), ['a/a', 'a/b', 'a/c', 'a/x', 'x/y', 'z/z']); assert.deepEqual(mm(fixtures, ['*/*/*']), ['a/a/a', 'a/a/b']); assert.deepEqual(mm(fixtures, ['*/*/*/*']), ['a/a/a/a']); assert.deepEqual(mm(fixtures, ['*/*/*/*/*']), ['a/a/a/a/a']); assert.deepEqual(mm(fixtures, ['a/*']), ['a/a', 'a/b', 'a/c', 'a/x']); assert.deepEqual(mm(fixtures, ['a/*/*']), ['a/a/a', 'a/a/b']); assert.deepEqual(mm(fixtures, ['a/*/*/*']), ['a/a/a/a']); assert.deepEqual(mm(fixtures, ['a/*/*/*/*']), ['a/a/a/a/a']); assert.deepEqual(mm(fixtures, ['a/*/a']), ['a/a/a']); assert.deepEqual(mm(fixtures, ['a/*/b']), ['a/a/b']); }); it('should support globstars (**)', () => { let fixtures = ['a', 'a/', 'a/a', 'a/b', 'a/c', 'a/x', 'a/x/y', 'a/x/y/z']; assert.deepEqual(mm(fixtures, ['*{,/}']), ['a', 'a/']); assert.deepEqual(mm(fixtures, ['*/']), ['a/']); assert.deepEqual(mm(fixtures, ['*/*']), ['a/a', 'a/b', 'a/c', 'a/x']); assert.deepEqual(mm(fixtures, ['**']), fixtures); assert.deepEqual(mm(fixtures, ['**/a']), ['a', 'a/a']); assert.deepEqual(mm(fixtures, ['a/*']), ['a/a', 'a/b', 'a/c', 'a/x']); assert.deepEqual(mm(fixtures, ['a/**']), ['a', 'a/', 'a/a', 'a/b', 'a/c', 'a/x', 'a/x/y', 'a/x/y/z']); assert.deepEqual(mm(fixtures, ['a/**/*']), ['a/a', 'a/b', 'a/c', 'a/x', 'a/x/y', 'a/x/y/z']); assert.deepEqual(mm(fixtures, ['a/**/**/*']), ['a/a', 'a/b', 'a/c', 'a/x', 'a/x/y', 'a/x/y/z']); assert.deepEqual(mm(['a/b/foo/bar/baz.qux'], 'a/b/**/bar/**/*.*'), ['a/b/foo/bar/baz.qux']); assert.deepEqual(mm(['a/b/bar/baz.qux'], 'a/b/**/bar/**/*.*'), ['a/b/bar/baz.qux']); }); it('should work with file extensions', () => { let fixtures = ['a.txt', 'a/b.txt', 'a/x/y.txt', 'a/x/y/z']; assert.deepEqual(mm(fixtures, ['a/**/*.txt']), ['a/b.txt', 'a/x/y.txt']); assert.deepEqual(mm(fixtures, ['a/*.txt']), ['a/b.txt']); assert.deepEqual(mm(fixtures, ['a*.txt']), ['a.txt']); assert.deepEqual(mm(fixtures, ['*.txt']), ['a.txt']); }); it('should match literal brackets', () => { assert.deepEqual(mm(['a [b]'], 'a \\[b\\]'), ['a [b]']); assert.deepEqual(mm(['a [b] c'], 'a [b] c'), ['a [b] c']); assert.deepEqual(mm(['a [b]'], 'a \\[b\\]*'), ['a [b]']); assert.deepEqual(mm(['a [bc]'], 'a \\[bc\\]*'), ['a [bc]']); assert.deepEqual(mm(['a [b]', 'a [b].js'], 'a \\[b\\].*'), ['a [b].js']); }); }); describe('windows paths', () => { beforeEach(() => { path.sep = '\\'; }); afterEach(() => { path.sep = sep; }); it('should return an array of matches for a literal string', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']; assert.deepEqual(mm(fixtures, '(a/b)'), ['a/b']); assert.deepEqual(mm(fixtures, 'a/b'), ['a/b']); assert.deepEqual(mm(fixtures, '(a/b)', { windows: false }), []); assert.deepEqual(mm(fixtures, 'a/b', { windows: false }), []); }); it('should return an array of matches for an array of literal strings', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']; assert.deepEqual(mm(fixtures, ['(a/b)', 'a/c']), ['a/b', 'a/c']); assert.deepEqual(mm(fixtures, ['a/b', 'b/b']), ['a/b', 'b/b']); assert.deepEqual(mm(fixtures, ['(a/b)', 'a/c'], { windows: false }), []); assert.deepEqual(mm(fixtures, ['a/b', 'b/b'], { windows: false }), []); }); it('should support regex logical or', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c']; assert.deepEqual(mm(fixtures, ['a/(a|c)']), ['a/a', 'a/c']); assert.deepEqual(mm(fixtures, ['a/(a|b|c)', 'a/b']), ['a/a', 'a/b', 'a/c']); assert.deepEqual(mm(fixtures, ['a/(a|c)'], { windows: false }), []); assert.deepEqual(mm(fixtures, ['a/(a|b|c)', 'a/b'], { windows: false }), []); }); it('should support regex ranges', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c', 'a\\x\\y', 'a\\x']; assert.deepEqual(mm(fixtures, 'a/[b-c]'), ['a/b', 'a/c']); assert.deepEqual(mm(fixtures, 'a/[a-z]'), ['a/a', 'a/b', 'a/c', 'a/x']); assert.deepEqual(mm(fixtures, 'a/[b-c]', { windows: false }), []); assert.deepEqual(mm(fixtures, 'a\\\\[b-c]', { windows: false }), ['a\\b', 'a\\c']); assert.deepEqual(mm(fixtures, 'a/[a-z]', { windows: false }), []); }); it('should support single globs (*)', () => { let fixtures = [ 'a', 'b', 'a\\a', 'a\\b', 'a\\c', 'a\\x', 'a\\a\\a', 'a\\a\\b', 'a\\a\\a\\a', 'a\\a\\a\\a\\a', 'x\\y', 'z\\z' ]; assert.deepEqual(mm(fixtures, ['*']), ['a', 'b']); assert.deepEqual(mm(fixtures, ['*/*']), ['a/a', 'a/b', 'a/c', 'a/x', 'x/y', 'z/z']); assert.deepEqual(mm(fixtures, ['*/*/*']), ['a/a/a', 'a/a/b']); assert.deepEqual(mm(fixtures, ['*/*/*/*']), ['a/a/a/a']); assert.deepEqual(mm(fixtures, ['*/*/*/*/*']), ['a/a/a/a/a']); assert.deepEqual(mm(fixtures, ['a/*']), ['a/a', 'a/b', 'a/c', 'a/x']); assert.deepEqual(mm(fixtures, ['a/*/*']), ['a/a/a', 'a/a/b']); assert.deepEqual(mm(fixtures, ['a/*/*/*']), ['a/a/a/a']); assert.deepEqual(mm(fixtures, ['a/*/*/*/*']), ['a/a/a/a/a']); assert.deepEqual(mm(fixtures, ['a/*/a']), ['a/a/a']); assert.deepEqual(mm(fixtures, ['a/*/b']), ['a/a/b']); let opts = { windows: false }; assert.deepEqual(mm(fixtures, ['*/*'], opts), []); assert.deepEqual(mm(fixtures, ['*/*/*'], opts), []); assert.deepEqual(mm(fixtures, ['*/*/*/*'], opts), []); assert.deepEqual(mm(fixtures, ['*/*/*/*/*'], opts), []); assert.deepEqual(mm(fixtures, ['a/*'], opts), []); assert.deepEqual(mm(fixtures, ['a/*/*'], opts), []); assert.deepEqual(mm(fixtures, ['a/*/*/*'], opts), []); assert.deepEqual(mm(fixtures, ['a/*/*/*/*'], opts), []); assert.deepEqual(mm(fixtures, ['a/*/a'], opts), []); assert.deepEqual(mm(fixtures, ['a/*/b'], opts), []); }); it('should support globstars (**)', () => { let fixtures = ['a\\a', 'a\\b', 'a\\c', 'a\\x', 'a\\x\\y', 'a\\x\\y\\z']; let expected = ['a/a', 'a/b', 'a/c', 'a/x', 'a/x/y', 'a/x/y/z']; assert.deepEqual(mm(fixtures, ['a/**']), expected); assert.deepEqual(mm(fixtures, ['a/**/*']), expected); assert.deepEqual(mm(fixtures, ['a/**/**/*']), expected); assert.deepEqual(mm(fixtures, ['a/**'], { windows: false }), []); assert.deepEqual(mm(fixtures, ['a/**/*'], { windows: false }), []); assert.deepEqual(mm(fixtures, ['a/**/**/*'], { windows: false }), []); }); it('should work with file extensions', () => { let fixtures = ['a.txt', 'a\\b.txt', 'a\\x\\y.txt', 'a\\x\\y\\z']; assert.deepEqual(mm(fixtures, ['a\\\\**\\\\*.txt']), []); assert.deepEqual(mm(fixtures, ['a\\\\*\\\\*.txt']), []); assert.deepEqual(mm(fixtures, ['a\\\\*.txt']), []); assert.deepEqual(mm(fixtures, ['a/**/*.txt']), ['a/b.txt', 'a/x/y.txt']); assert.deepEqual(mm(fixtures, ['a/*/*.txt']), ['a/x/y.txt']); assert.deepEqual(mm(fixtures, ['a/*.txt']), ['a/b.txt']); assert.deepEqual(mm(fixtures, ['a*.txt']), ['a.txt']); assert.deepEqual(mm(fixtures, ['a.txt']), ['a.txt']); }); }); }); micromatch-4.0.5/test/minimatch.js000066400000000000000000000112171421714312500171360ustar00rootroot00000000000000'use strict'; const path = require('path'); const assert = require('assert'); const isWindows = () => process.platform === 'win32' || path.sep === '\\'; const patterns = require('./fixtures/patterns'); const mm = require('..'); let sep = path.sep; /** * Minimatch comparison tests */ describe('basic tests', () => { afterEach(() => (path.sep = sep)); after(() => (path.sep = sep)); describe('minimatch parity', () => { patterns.forEach(function(unit, i) { it(i + ': ' + unit[0], () => { if (typeof unit === 'string') { console.log(); console.log(' ', unit); return; } // update fixtures list if (typeof unit === 'function') { unit(); return; } let pattern = unit[0]; let expected = (unit[1] || []).sort(compare); let options = Object.assign({}, unit[2]); let fixtures = unit[3] || patterns.fixtures; mm(fixtures, pattern, expected, options); }); }); }); describe('backslashes', () => { it('should match literal backslashes', () => { if (isWindows()) { mm(['\\'], '\\', ['/']); } else { mm(['\\'], '\\', ['\\']); } }); }); /** * Issues that minimatch fails on but micromatch passes */ describe('minimatch issues (as of 12/7/2016)', () => { it('https://github.com/isaacs/minimatch/issues/29', () => { assert(mm.isMatch('foo/bar.txt', 'foo/**/*.txt')); assert(mm.makeRe('foo/**/*.txt').test('foo/bar.txt')); assert(!mm.isMatch('n/!(axios)/**', 'n/axios/a.js')); assert(!mm.makeRe('n/!(axios)/**').test('n/axios/a.js')); }); it('https://github.com/isaacs/minimatch/issues/30', () => { let format = str => str.replace(/^\.\//, ''); assert(mm.isMatch('foo/bar.js', '**/foo/**')); assert(mm.isMatch('./foo/bar.js', './**/foo/**', { format })); assert(mm.isMatch('./foo/bar.js', '**/foo/**', { format })); assert(mm.isMatch('./foo/bar.txt', 'foo/**/*.txt', { format })); assert(mm.makeRe('./foo/**/*.txt').test('foo/bar.txt')); assert(!mm.isMatch('./foo/!(bar)/**', 'foo/bar/a.js')); assert(!mm.makeRe('./foo/!(bar)/**').test('foo/bar/a.js')); }); it('https://github.com/isaacs/minimatch/issues/50', () => { assert(mm.isMatch('foo/bar-[ABC].txt', 'foo/**/*-\\[ABC\\].txt')); assert(!mm.isMatch('foo/bar-[ABC].txt', 'foo/**/*-\\[abc\\].txt')); assert(mm.isMatch('foo/bar-[ABC].txt', 'foo/**/*-\\[abc\\].txt', {nocase: true})); }); it('https://github.com/isaacs/minimatch/issues/67 (should work consistently with `makeRe` and matcher functions)', () => { var re = mm.makeRe('node_modules/foobar/**/*.bar'); assert(re.test('node_modules/foobar/foo.bar')); assert(mm.isMatch('node_modules/foobar/foo.bar', 'node_modules/foobar/**/*.bar')); mm(['node_modules/foobar/foo.bar'], 'node_modules/foobar/**/*.bar', ['node_modules/foobar/foo.bar']); }); it('https://github.com/isaacs/minimatch/issues/75', () => { assert(mm.isMatch('foo/baz.qux.js', 'foo/@(baz.qux).js')); assert(mm.isMatch('foo/baz.qux.js', 'foo/+(baz.qux).js')); assert(mm.isMatch('foo/baz.qux.js', 'foo/*(baz.qux).js')); assert(!mm.isMatch('foo/baz.qux.js', 'foo/!(baz.qux).js')); assert(!mm.isMatch('foo/bar/baz.qux.js', 'foo/*/!(baz.qux).js')); assert(!mm.isMatch('foo/bar/bazqux.js', '**/!(bazqux).js')); assert(!mm.isMatch('foo/bar/bazqux.js', '**/bar/!(bazqux).js')); assert(!mm.isMatch('foo/bar/bazqux.js', 'foo/**/!(bazqux).js')); assert(!mm.isMatch('foo/bar/bazqux.js', 'foo/**/!(bazqux)*.js')); assert(!mm.isMatch('foo/bar/baz.qux.js', 'foo/**/!(baz.qux)*.js')); assert(!mm.isMatch('foo/bar/baz.qux.js', 'foo/**/!(baz.qux).js')); assert(!mm.isMatch('foobar.js', '!(foo)*.js')); assert(!mm.isMatch('foo.js', '!(foo).js')); assert(!mm.isMatch('foo.js', '!(foo)*.js')); }); it('https://github.com/isaacs/minimatch/issues/78', () => { path.sep = '\\'; assert(mm.isMatch('a\\b\\c.txt', 'a/**/*.txt')); assert(mm.isMatch('a/b/c.txt', 'a/**/*.txt')); path.sep = sep; }); it('https://github.com/isaacs/minimatch/issues/82', () => { let format = str => str.replace(/^\.\//, ''); assert(mm.isMatch('./src/test/a.js', '**/test/**', { format })); assert(mm.isMatch('src/test/a.js', '**/test/**')); }); it('https://github.com/isaacs/minimatch/issues/83', () => { assert(!mm.makeRe('foo/!(bar)/**').test('foo/bar/a.js')); assert(!mm.isMatch('foo/!(bar)/**', 'foo/bar/a.js')); }); }); }); function compare(a, b) { return a === b ? 0 : a > b ? 1 : -1; } micromatch-4.0.5/test/negation.js000066400000000000000000000175231421714312500167770ustar00rootroot00000000000000'use strict'; const path = require('path'); const sep = path.sep; const assert = require('assert'); const isWindows = () => process.platform === 'win32' || path.sep === '\\'; const mm = require('..'); describe('negation', () => { describe('posix paths', () => { it('should support negating with single *', () => { assert.deepEqual(mm(['a', 'b', 'c.md'], '!*.md'), ['a', 'b']); assert.deepEqual(mm(['a/a/a', 'a/b/a', 'a/c/a'], '!a/*/a'), []); assert.deepEqual(mm(['a/a/a/a', 'b/a/b/a', 'c/a/c/a'], '!a/*/*/a'), ['b/a/b/a', 'c/a/c/a']); assert.deepEqual(mm(['a/a', 'a/b', 'a/c'], '!a/a*'), ['a/b', 'a/c']); assert.deepEqual(mm(['a.a', 'a.b', 'a.c'], '!a.a*'), ['a.b', 'a.c']); assert.deepEqual(mm(['a/a', 'a/b', 'a/c'], '!a/*'), []); }); it('should support negation patterns', () => { let fixtures1 = ['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c']; assert.deepEqual(mm(fixtures1, ['!a/b']), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures1, ['*/*', '!a/b', '!*/c']), ['a/a', 'b/a', 'b/b']); assert.deepEqual(mm(fixtures1, ['*/*', '!a/b', '!*/c']), ['a/a', 'b/a', 'b/b']); assert.deepEqual(mm(fixtures1, ['*/*', '!a/b', '!a/c']), ['a/a', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures1, ['!a/(b)']), ['a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(['bar', 'baz', 'foo'], ['!bar', '*']), ['bar', 'baz', 'foo']); assert.deepEqual(mm(['bar', 'baz', 'foo'], ['*', '!bar']), ['baz', 'foo']); let fixtures2 = ['foo', 'bar', 'baz', 'main', 'other', 'foo/a/b/c', 'bar/a/b/d', 'baz/a/b/e', 'a/a/a', 'a/a/b', 'a/a/c', 'a/a/file']; assert.deepEqual(mm(fixtures2, ['a/**', '!a/a/file', 'main']), ['a/a/a', 'a/a/b', 'a/a/c', 'main']); assert.deepEqual(mm('foo', ['a/**', '!a/a/file', 'main']), []); assert.deepEqual(mm(['foo'], ['a/**', '!a/a/file', 'main']), []); }); it('should support negating with literal non-globs', () => { let fixtures = ['a', 'b', 'a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'b/c']; // assert.deepEqual(mm(fixtures, ['!a/a', '!a']), []); assert.deepEqual(mm(['bar', 'baz', 'foo'], '!foo'), ['bar', 'baz']); assert.deepEqual(mm(['bar', 'baz', 'foo'], ['!bar', 'bar']), ['bar']); assert.deepEqual(mm(['bar', 'baz', 'foo'], ['!foo', 'bar']), ['bar']); assert.deepEqual(mm(['bar', 'baz', 'foo'], ['!foo']), ['bar', 'baz']); assert.deepEqual(mm(['bar', 'baz', 'foo'], ['bar', '!foo', '!bar']), []); assert.deepEqual(mm(['foo!.md', 'bar.md'], 'foo!.md'), ['foo!.md']); assert.deepEqual(mm(['foo.md'], '!.md'), ['foo.md']); }); it('should negate files with extensions:', () => { assert.deepEqual(mm(['a.js', 'b.md', 'c.txt'], '!**/*.md'), ['a.js', 'c.txt']); assert.deepEqual(mm(['a.js', 'b.md', 'c.txt'], '!*.md'), ['a.js', 'c.txt']); assert.deepEqual(mm(['abc.md', 'abc.txt'], '!*.md'), ['abc.txt']); assert.deepEqual(mm(['foo.md'], '!*.md'), []); }); it('should only treat leading exclamation as special', () => { assert.deepEqual(mm(['foo!.md', 'bar.md'], '*.md'), ['foo!.md', 'bar.md']); assert.deepEqual(mm(['foo!.md', 'bar.md'], '*!.md'), ['foo!.md']); assert.deepEqual(mm(['foobar.md'], '*b*.md'), ['foobar.md']); assert.deepEqual(mm(['foo!bar.md', 'foo!.md', '!foo!.md'], '*!*.md'), ['foo!bar.md', 'foo!.md', '!foo!.md']); assert.deepEqual(mm(['foo!bar.md', 'foo!.md', '!foo!.md'], '\\!*!*.md'), ['!foo!.md']); assert.deepEqual(mm(['foo!.md', 'ba!r.js'], '**/*!*.*'), ['foo!.md', 'ba!r.js']); }); it('should support negated globstars ("**")', () => { assert.deepEqual(mm(['a.js', 'b.txt', 'c.md'], '!*.md'), ['a.js', 'b.txt']); assert.deepEqual(mm(['a/a/a.js', 'a/b/a.js', 'a/c/a.js', 'a/a/b.js'], '!**/a.js'), ['a/a/b.js']); assert.deepEqual(mm(['a/a/a/a.js', 'b/a/b/a.js', 'c/a/c/a.js'], '!a/**/a.js'), ['b/a/b/a.js', 'c/a/c/a.js']); assert.deepEqual(mm(['a/a.txt', 'a/b.txt', 'a/c.txt'], '!a/b.txt'), ['a/a.txt', 'a/c.txt']); assert.deepEqual(mm(['a/b.js', 'a.js', 'a/b.md', 'a.md'], '!**/*.md'), ['a/b.js', 'a.js']); assert.deepEqual(mm(['a/b.js', 'a.js', 'a/b.md', 'a.md'], '**/*.md'), ['a/b.md', 'a.md']); assert.deepEqual(mm(['a/b.js'], '!**/*.md'), ['a/b.js']); assert.deepEqual(mm(['a.js'], '!**/*.md'), ['a.js']); assert.deepEqual(mm(['a/b.md'], '!**/*.md'), []); assert.deepEqual(mm(['a.md'], '!**/*.md'), []); assert.deepEqual(mm(['a/b.js'], '!*.md'), ['a/b.js']); assert.deepEqual(mm(['a.js'], '!*.md'), ['a.js']); assert.deepEqual(mm(['a/b.md'], '!*.md'), ['a/b.md']); assert.deepEqual(mm(['a.md'], '!*.md'), []); assert.deepEqual(mm(['a.js'], '!**/*.md'), ['a.js']); assert.deepEqual(mm(['b.md'], '!**/*.md'), []); assert.deepEqual(mm(['c.txt'], '!**/*.md'), ['c.txt']); }); it('should negate dotfiles:', () => { assert.deepEqual(mm(['.dotfile.md'], '!*.md', { dot: true }), []); assert.deepEqual(mm(['.dotfile'], '!*.md'), ['.dotfile']); assert.deepEqual(mm(['.dotfile.txt'], '!*.md'), ['.dotfile.txt']); assert.deepEqual(mm(['.dotfile.txt', 'a/b/.dotfile'], '!*.md'), ['.dotfile.txt', 'a/b/.dotfile']); assert.deepEqual(mm(['.gitignore', 'a', 'b'], '!.gitignore'), ['a', 'b']); }); it('should negate files in the immediate directory:', () => { assert.deepEqual(mm(['a/b.js', 'a.js', 'a/b.md', 'a.md'], '!*.md'), ['a/b.js', 'a.js', 'a/b.md']); }); it('should not give special meaning to non-leading exclamations', () => { assert.deepEqual(mm(['a', 'aa', 'a/b', 'a!b', 'a!!b', 'a/!!/b'], 'a!!b'), ['a!!b']); }); it('should negate files in any directory:', () => { assert.deepEqual(mm(['a/a.txt', 'a/b.txt', 'a/c.txt'], '!a/b.txt'), ['a/a.txt', 'a/c.txt']); }); }); describe('windows paths', () => { beforeEach(() => { path.sep = '\\'; }); afterEach(() => { path.sep = sep; }); it('should support negation patterns', () => { let fixtures = ['a', 'a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']; assert.deepEqual(mm(fixtures, ['!a/b']), ['a', 'a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, ['*/*', '!a/b', '!*/c']), ['a/a', 'b/a', 'b/b']); assert.deepEqual(mm(fixtures, ['!*/c']), ['a', 'a/a', 'a/b', 'b/a', 'b/b']); assert.deepEqual(mm(fixtures, ['**', '!a/b', '!*/c']), ['a', 'a/a', 'b/a', 'b/b']); assert.deepEqual(mm(fixtures, ['**', '!a/b', '!a/c']), ['a', 'a/a', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, ['!a/(b)']), ['a', 'a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, ['!(a/b)']), ['a', 'a/a', 'a/c', 'b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, ['!(a)**']), ['b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, ['**', '!(a)**']), ['b/a', 'b/b', 'b/c']); assert.deepEqual(mm(fixtures, ['!a/b'], { windows: false }), ['a', 'a\\a', 'a\\b', 'a\\c', 'b\\a', 'b\\b', 'b\\c']); assert.deepEqual(mm(fixtures, ['!a\\\\b'], { windows: false }), ['a', 'a\\a', 'a\\c', 'b\\a', 'b\\b', 'b\\c']); assert.deepEqual(mm(fixtures, ['*/*', '!a/b', '!*/c'], { windows: false }), []); assert.deepEqual(mm(fixtures, ['!*\\\\c'], { windows: false }), ['a', 'a\\a', 'a\\b', 'b\\a', 'b\\b']); assert.deepEqual(mm(fixtures, ['**', '!a\\\\b', '!*\\\\c'], { windows: false }), ['a', 'a\\a', 'b\\a', 'b\\b']); assert.deepEqual(mm(fixtures, ['**', '!a\\\\b', '!a\\\\c'], { windows: false }), ['a', 'a\\a', 'b\\a', 'b\\b', 'b\\c']); assert.deepEqual(mm(fixtures, ['**', '!a\\\\b'], { windows: false }), ['a', 'a\\a', 'a\\c', 'b\\a', 'b\\b', 'b\\c']); assert.deepEqual(mm(fixtures, ['**', '!a\\\\(b)'], { windows: false }), ['a', 'a\\a', 'a\\c', 'b\\a', 'b\\b', 'b\\c']); assert.deepEqual(mm(fixtures, ['**', '!(a\\\\b)'], { windows: false }), ['a', 'a\\a', 'a\\c', 'b\\a', 'b\\b', 'b\\c']); }); }); }); micromatch-4.0.5/test/options.js000066400000000000000000000402011421714312500166530ustar00rootroot00000000000000'use strict'; const path = require('path'); const assert = require('assert'); const mm = require('..'); const mi = require('minimatch'); if (!process.env.ORIGINAL_PATH_SEP) { process.env.ORIGINAL_PATH_SEP = path.sep } describe('options', () => { beforeEach(() => (path.sep = '\\')); afterEach(() => (path.sep = process.env.ORIGINAL_PATH_SEP)); after(() => (path.sep = process.env.ORIGINAL_PATH_SEP)); describe('options.failglob (from Bash 4.3 tests)', () => { it('should throw an error when no matches are found:', () => { assert.throws(() => mm(['foo'], '\\^', { failglob: true }), /No matches found for/); }); }); describe('options.ignore', () => { let negations = ['a/a', 'a/b', 'a/c', 'a/d', 'a/e', 'b/a', 'b/b', 'b/c']; let globs = ['.a', '.a/a', '.a/a/a', '.a/a/a/a', 'a', 'a/.a', 'a/a', 'a/a/.a', 'a/a/a', 'a/a/a/a', 'a/a/a/a/a', 'a/a/b', 'a/b', 'a/b/c', 'a/c', 'a/x', 'b', 'b/b/b', 'b/b/c', 'c/c/c', 'e/f/g', 'h/i/a', 'x/x/x', 'x/y', 'z/z', 'z/z/z']; it('should filter out ignored patterns', () => { let opts = { ignore: ['a/**'], strictSlashes: true }; let dotOpts = { ...opts, dot: true }; assert.deepEqual(mm(globs, '*', opts), ['a', 'b']); assert.deepEqual(mm(globs, '*', { ...opts, strictSlashes: false }), ['b']); assert.deepEqual(mm(globs, '*', { ignore: '**/a' }), ['b']); assert.deepEqual(mm(globs, '*/*', opts), ['x/y', 'z/z']); assert.deepEqual(mm(globs, '*/*/*', opts), ['b/b/b', 'b/b/c', 'c/c/c', 'e/f/g', 'h/i/a', 'x/x/x', 'z/z/z']); assert.deepEqual(mm(globs, '*/*/*/*', opts), []); assert.deepEqual(mm(globs, '*/*/*/*/*', opts), []); assert.deepEqual(mm(globs, 'a/*', opts), []); assert.deepEqual(mm(globs, '**/*/x', opts), ['x/x/x']); assert.deepEqual(mm(globs, '**/*/[b-z]', opts), ['b/b/b', 'b/b/c', 'c/c/c', 'e/f/g', 'x/x/x', 'x/y', 'z/z', 'z/z/z']); assert.deepEqual(mm(globs, '*', { ignore: '**/a', dot: true }), ['.a', 'b']); assert.deepEqual(mm(globs, '*', dotOpts), ['.a', 'a', 'b']); assert.deepEqual(mm(globs, '*/*', dotOpts), ['.a/a', 'x/y', 'z/z']); assert.deepEqual(mm(globs, '*/*/*', dotOpts), ['.a/a/a', 'b/b/b', 'b/b/c', 'c/c/c', 'e/f/g', 'h/i/a', 'x/x/x', 'z/z/z']); assert.deepEqual(mm(globs, '*/*/*/*', dotOpts), ['.a/a/a/a']); assert.deepEqual(mm(globs, '*/*/*/*/*', dotOpts), []); assert.deepEqual(mm(globs, 'a/*', dotOpts), []); assert.deepEqual(mm(globs, '**/*/x', dotOpts), ['x/x/x']); // see https://github.com/jonschlinkert/micromatch/issues/79 assert.deepEqual(mm(['foo.js', 'a/foo.js'], '**/foo.js'), ['foo.js', 'a/foo.js']); assert.deepEqual(mm(['foo.js', 'a/foo.js'], '**/foo.js', { dot: true }), ['foo.js', 'a/foo.js']); assert.deepEqual(mm(negations, '!b/a', opts), ['b/b', 'b/c']); assert.deepEqual(mm(negations, '!b/(a)', opts), ['b/b', 'b/c']); assert.deepEqual(mm(negations, '!(b/(a))', opts), ['b/b', 'b/c']); assert.deepEqual(mm(negations, '!(b/a)', opts), ['b/b', 'b/c']); assert.deepEqual(mm(negations, '**'), negations, 'nothing is ignored'); assert.deepEqual(mm(negations, '**', { ignore: ['*/b', '*/a'] }), ['a/c', 'a/d', 'a/e', 'b/c']); assert.deepEqual(mm(negations, '**', { ignore: ['**'] }), []); }); }); describe('options.matchBase', () => { it('should match the basename of file paths when `options.matchBase` is true', () => { assert.deepEqual(mm(['a/b/c/d.md'], '*.md'), [], 'should not match multiple levels'); assert.deepEqual(mm(['a/b/c/foo.md'], '*.md'), [], 'should not match multiple levels'); assert.deepEqual(mm(['ab', 'acb', 'acb/', 'acb/d/e', 'x/y/acb', 'x/y/acb/d'], 'a?b'), ['acb'], 'should not match multiple levels'); assert.deepEqual(mm(['a/b/c/d.md'], '*.md', { matchBase: true }), ['a/b/c/d.md']); assert.deepEqual(mm(['a/b/c/foo.md'], '*.md', { matchBase: true }), ['a/b/c/foo.md']); assert.deepEqual(mm(['x/y/acb', 'acb/', 'acb/d/e', 'x/y/acb/d'], 'a?b', { matchBase: true }), ['x/y/acb', 'acb/']); }); it('should work with negation patterns', () => { assert(mm.isMatch('./x/y.js', '*.js', { matchBase: true })); assert(!mm.isMatch('./x/y.js', '!*.js', { matchBase: true })); assert(mm.isMatch('./x/y.js', '**/*.js', { matchBase: true })); assert(!mm.isMatch('./x/y.js', '!**/*.js', { matchBase: true })); }); }); describe('options.flags', () => { it('should be case-sensitive by default', () => { assert.deepEqual(mm(['a/b/d/e.md'], 'a/b/D/*.md'), [], 'should not match a dirname'); assert.deepEqual(mm(['a/b/c/e.md'], 'A/b/*/E.md'), [], 'should not match a basename'); assert.deepEqual(mm(['a/b/c/e.md'], 'A/b/C/*.MD'), [], 'should not match a file extension'); }); it('should not be case-sensitive when `i` is set on `options.flags`', () => { assert.deepEqual(mm(['a/b/d/e.md'], 'a/b/D/*.md', { flags: 'i' }), ['a/b/d/e.md']); assert.deepEqual(mm(['a/b/c/e.md'], 'A/b/*/E.md', { flags: 'i' }), ['a/b/c/e.md']); assert.deepEqual(mm(['a/b/c/e.md'], 'A/b/C/*.MD', { flags: 'i' }), ['a/b/c/e.md']); }); }); describe('options.nobrace', () => { it('should not expand braces when disabled', () => { assert.deepEqual(mm(['a', 'b', 'c'], '{a,b,c,d}'), ['a', 'b', 'c']); assert.deepEqual(mm(['a', 'b', 'c'], '{a,b,c,d}', { nobrace: true }), []); assert.deepEqual(mm(['1', '2', '3'], '{1..2}', { nobrace: true }), []); }); }); describe('options.nocase', () => { it('should not be case-sensitive when `options.nocase` is true', () => { assert.deepEqual(mm(['a/b/c/e.md'], 'A/b/*/E.md', { nocase: true }), ['a/b/c/e.md']); assert.deepEqual(mm(['a/b/c/e.md'], 'A/b/C/*.MD', { nocase: true }), ['a/b/c/e.md']); assert.deepEqual(mm(['a/b/c/e.md'], 'A/b/C/*.md', { nocase: true }), ['a/b/c/e.md']); assert.deepEqual(mm(['a/b/d/e.md'], 'a/b/D/*.md', { nocase: true }), ['a/b/d/e.md']); }); it('should not double-set `i` when both `nocase` and the `i` flag are set', () => { let opts = { nocase: true, flags: 'i' }; assert.deepEqual(mm(['a/b/d/e.md'], 'a/b/D/*.md', opts), ['a/b/d/e.md']); assert.deepEqual(mm(['a/b/c/e.md'], 'A/b/*/E.md', opts), ['a/b/c/e.md']); assert.deepEqual(mm(['a/b/c/e.md'], 'A/b/C/*.MD', opts), ['a/b/c/e.md']); }); }); describe('options.noextglob', () => { it('should match literal parens when noextglob is true (issue #116)', () => { assert(mm.isMatch('a/(dir)', 'a/(dir)', { noextglob: true })); }); it('should not match extglobs when noextglob is true', () => { assert(!mm.isMatch('ax', '?(a*|b)', { noextglob: true })); assert.deepEqual(mm(['a.j.js', 'a.md.js'], '*.*(j).js', { noextglob: true }), ['a.j.js']); assert.deepEqual(mm(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)', { noextglob: true }), ['a/!(z)']); assert.deepEqual(mm(['a/z', 'a/b'], 'a/!(z)', { noextglob: true }), []); assert.deepEqual(mm(['c/a/v'], 'c/!(z)/v', { noextglob: true }), []); assert.deepEqual(mm(['c/z/v', 'c/a/v'], 'c/!(z)/v', { noextglob: true }), []); assert.deepEqual(mm(['c/z/v', 'c/a/v'], 'c/@(z)/v', { noextglob: true }), []); assert.deepEqual(mm(['c/z/v', 'c/a/v'], 'c/+(z)/v', { noextglob: true }), []); assert.deepEqual(mm(['c/z/v', 'c/a/v'], 'c/*(z)/v', { noextglob: true }), ['c/z/v']); assert.deepEqual(mm(['c/z/v', 'z', 'zf', 'fz'], '?(z)', { noextglob: true }), ['fz']); assert.deepEqual(mm(['c/z/v', 'z', 'zf', 'fz'], '+(z)', { noextglob: true }), []); assert.deepEqual(mm(['c/z/v', 'z', 'zf', 'fz'], '*(z)', { noextglob: true }), ['z', 'fz']); assert.deepEqual(mm(['cz', 'abz', 'az'], 'a@(z)', { noextglob: true }), []); assert.deepEqual(mm(['cz', 'abz', 'az'], 'a*@(z)', { noextglob: true }), []); assert.deepEqual(mm(['cz', 'abz', 'az'], 'a!(z)', { noextglob: true }), []); assert.deepEqual(mm(['cz', 'abz', 'az', 'azz'], 'a?(z)', { noextglob: true }), ['abz', 'azz']); assert.deepEqual(mm(['cz', 'abz', 'az', 'azz', 'a+z'], 'a+(z)', { noextglob: true }), ['a+z']); assert.deepEqual(mm(['cz', 'abz', 'az'], 'a*(z)', { noextglob: true }), ['abz', 'az']); assert.deepEqual(mm(['cz', 'abz', 'az'], 'a**(z)', { noextglob: true }), ['abz', 'az']); assert.deepEqual(mm(['cz', 'abz', 'az'], 'a*!(z)', { noextglob: true }), []); }); }); describe('options.nodupes', () => { beforeEach(() => { path.sep = '\\'; }); afterEach(() => { path.sep = process.env.ORIGINAL_PATH_SEP; }); it('should remove duplicate elements from the result array:', () => { let fixtures = ['.editorconfig', '.git', '.gitignore', '.nyc_output', '.travis.yml', '.verb.md', 'CHANGELOG.md', 'CONTRIBUTING.md', 'LICENSE', 'coverage', 'example.js', 'example.md', 'example.css', 'index.js', 'node_modules', 'package.json', 'test.js', 'utils.js']; assert.deepEqual(mm(['abc', '/a/b/c', '\\a\\b\\c'], '/a/b/c', { windows: true }), ['/a/b/c']); assert.deepEqual(mm(['abc', '/a/b/c', '\\a\\b\\c'], '\\a\\b\\c', { windows: true }), ['/a/b/c']); assert.deepEqual(mm(['abc', '/a/b/c', '\\a\\b\\c'], '/a/b/c', { windows: true, nodupes: true }), ['/a/b/c']); assert.deepEqual(mm(['abc', '/a/b/c', '\\a\\b\\c'], '\\a\\b\\c', { windows: true, nodupes: true }), ['/a/b/c']); assert.deepEqual(mm(fixtures, ['example.*', '*.js'], { windows: true, nodupes: true }), ['example.js', 'example.md', 'example.css', 'index.js', 'test.js', 'utils.js']); }); it('should not remove duplicates', () => { assert.deepEqual(mm(['abc', '/a/b/c', '\\a\\b\\c'], '/a/b/c'), ['/a/b/c']); assert.deepEqual(mm(['abc', '/a/b/c', '\\a\\b\\c'], '/a/b/c', { nodupes: true }), ['/a/b/c']); assert.deepEqual(mm(['abc', '/a/b/c', '\\a\\b\\c'], '/a/b/c', { windows: true, nodupes: true }), ['/a/b/c']); }); }); describe('options.nonegate', () => { it('should support the `nonegate` option:', () => { assert.deepEqual(mm(['a/a/a', 'a/b/a', 'b/b/a', 'c/c/a', 'c/c/b'], '!**/a'), ['c/c/b']); assert.deepEqual(mm(['a.md', '!a.md', 'a.txt'], '!*.md', { nonegate: true }), ['!a.md']); // this should not return more than one nested directory, since "!**/a" is // collapsed to "!*/a", given that "**" is not the only thing in the segment. assert.deepEqual(mm(['!a/a/a', 'a/b/a', 'b/b/a', '!c/c/a', '!a/a'], '!**/a', { nonegate: true }), ['!a/a']); assert.deepEqual(mm(['!*.md', '.dotfile.txt', 'a/b/.dotfile'], '!*.md', { nonegate: true }), ['!*.md']); }); }); describe('options.nonull', () => { it('should support the `nonull` option:', () => { assert.deepEqual(mm(['*', '\\*'], '\\*', { nonull: true }), ['*', '\\*']); assert.deepEqual(mm(['*', '\\^'], '\\^', { nonull: true }), ['\\^']); assert.deepEqual(mm(['*', 'a\\*'], 'a\\*', { nonull: true }), ['a\\*']); }); }); describe('options.windows', () => { it('should windows file paths by default', () => { assert.deepEqual(mm(['a\\b\\c.md'], '**/*.md'), ['a/b/c.md']); assert.deepEqual(mm(['a\\b\\c.md'], '**\\\\*.md', { windows: false }), ['a\\b\\c.md']); }); it('should windows absolute paths', () => { assert.deepEqual(mm(['E:\\a\\b\\c.md'], 'E:/**/*.md'), ['E:/a/b/c.md']); assert.deepEqual(mm(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: false }), []); }); it('should strip leading `./`', () => { let fixtures = ['./a', './a/a/a', './a/a/a/a', './a/a/a/a/a', './a/b', './a/x', './z/z', 'a', 'a/a', 'a/a/b', 'a/c', 'b', 'x/y'].sort(); let format = str => str.replace(/^\.\//, ''); let opts = { format }; assert.deepEqual(mm(fixtures, '*', opts), ['a', 'b']); assert.deepEqual(mm(fixtures, '**/a/**', opts), ['a', 'a/a/a', 'a/a/a/a', 'a/a/a/a/a', 'a/b', 'a/x', 'a/a', 'a/a/b', 'a/c']); assert.deepEqual(mm(fixtures, '*/*', opts), ['a/b', 'a/x', 'z/z', 'a/a', 'a/c', 'x/y']); assert.deepEqual(mm(fixtures, '*/*/*', opts), ['a/a/a', 'a/a/b']); assert.deepEqual(mm(fixtures, '*/*/*/*', opts), ['a/a/a/a']); assert.deepEqual(mm(fixtures, '*/*/*/*/*', opts), ['a/a/a/a/a']); assert.deepEqual(mm(fixtures, './*', opts), ['a', 'b']); assert.deepEqual(mm(fixtures, './**/a/**', opts), ['a', 'a/a/a', 'a/a/a/a', 'a/a/a/a/a', 'a/b', 'a/x', 'a/a', 'a/a/b', 'a/c']); assert.deepEqual(mm(fixtures, 'a/*/a', opts), ['a/a/a']); assert.deepEqual(mm(fixtures, 'a/*', opts), ['a/b', 'a/x', 'a/a', 'a/c']); assert.deepEqual(mm(fixtures, 'a/*/*', opts), ['a/a/a', 'a/a/b']); assert.deepEqual(mm(fixtures, 'a/*/*/*', opts), ['a/a/a/a']); assert.deepEqual(mm(fixtures, 'a/*/*/*/*', opts), ['a/a/a/a/a']); assert.deepEqual(mm(fixtures, 'a/*/a', opts), ['a/a/a']); assert.deepEqual(mm(fixtures, '*', { ...opts, windows: false }), ['a', 'b']); assert.deepEqual(mm(fixtures, '**/a/**', { ...opts, windows: false }), ['a', 'a/a/a', 'a/a/a/a', 'a/a/a/a/a', 'a/b', 'a/x', 'a/a', 'a/a/b', 'a/c']); assert.deepEqual(mm(fixtures, '*/*', { ...opts, windows: false }), ['a/b', 'a/x', 'z/z', 'a/a', 'a/c', 'x/y']); assert.deepEqual(mm(fixtures, '*/*/*', { ...opts, windows: false }), ['a/a/a', 'a/a/b']); assert.deepEqual(mm(fixtures, '*/*/*/*', { ...opts, windows: false }), ['a/a/a/a']); assert.deepEqual(mm(fixtures, '*/*/*/*/*', { ...opts, windows: false }), ['a/a/a/a/a']); assert.deepEqual(mm(fixtures, './*', { ...opts, windows: false }), ['a', 'b']); assert.deepEqual(mm(fixtures, './**/a/**', { ...opts, windows: false }), ['a', 'a/a/a', 'a/a/a/a', 'a/a/a/a/a', 'a/b', 'a/x', 'a/a', 'a/a/b', 'a/c']); assert.deepEqual(mm(fixtures, './a/*/a', { ...opts, windows: false }), ['a/a/a']); assert.deepEqual(mm(fixtures, 'a/*', { ...opts, windows: false }), ['a/b', 'a/x', 'a/a', 'a/c']); assert.deepEqual(mm(fixtures, 'a/*/*', { ...opts, windows: false }), ['a/a/a', 'a/a/b']); assert.deepEqual(mm(fixtures, 'a/*/*/*', { ...opts, windows: false }), ['a/a/a/a']); assert.deepEqual(mm(fixtures, 'a/*/*/*/*', { ...opts, windows: false }), ['a/a/a/a/a']); assert.deepEqual(mm(fixtures, 'a/*/a', { ...opts, windows: false }), ['a/a/a']); }); }); describe('options.dot', () => { describe('when `dot` or `dotfile` is NOT true:', () => { it('should not match dotfiles by default:', () => { let format = str => str.replace(/^\.\//, ''); let opts = { format, result: format }; assert.deepEqual(mm(['.dotfile'], '*'), []); assert.deepEqual(mm(['.dotfile'], '**'), []); assert.deepEqual(mm(['a/b/c/.dotfile.md'], '*.md'), []); assert.deepEqual(mm(['a/b', 'a/.b', '.a/b', '.a/.b'], '**'), ['a/b']); assert.deepEqual(mm(['a/b/c/.dotfile'], '*.*'), []); // https://github.com/isaacs/minimatch/issues/30 assert.deepEqual(mm(['foo/bar.js'], '**/foo/**', opts), ['foo/bar.js']); assert.deepEqual(mm(['./foo/bar.js'], './**/foo/**', opts), ['foo/bar.js']); assert.deepEqual(mm(['./foo/bar.js'], '**/foo/**', opts), ['foo/bar.js']); assert.deepEqual(mm(['./foo/bar.js'], './**/foo/**', { ...opts, windows: false }), ['foo/bar.js']); assert.deepEqual(mm(['./foo/bar.js'], '**/foo/**', { ...opts, windows: false }), ['foo/bar.js']); }); it('should match dotfiles when a leading dot is defined in the path:', () => { assert.deepEqual(mm(['a/b/c/.dotfile.md'], '**/.*'), ['a/b/c/.dotfile.md']); assert.deepEqual(mm(['a/b/c/.dotfile.md'], '**/.*.md'), ['a/b/c/.dotfile.md']); }); it('should use negation patterns on dotfiles:', () => { assert.deepEqual(mm(['.a', '.b', 'c', 'c.md'], '!.*'), ['c', 'c.md']); assert.deepEqual(mm(['.a', '.b', 'c', 'c.md'], '!.b'), ['.a', 'c', 'c.md']); }); }); }); describe('windows', () => { it('should windows file paths', () => { assert.deepEqual(mm(['a\\b\\c.md'], '**/*.md'), ['a/b/c.md']); assert.deepEqual(mm(['a\\b\\c.md'], '**/*.md', { windows: false }), ['a\\b\\c.md']); assert.deepEqual(mm(['a\\b\\c.md'], '**\\\\*.md', { windows: false }), ['a\\b\\c.md']); }); it('should windows absolute paths', () => { assert.deepEqual(mm(['E:\\a\\b\\c.md'], 'E:/**/*.md'), ['E:/a/b/c.md']); assert.deepEqual(mm(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: false }), []); }); }); }); micromatch-4.0.5/test/posix-classes.js000066400000000000000000000421261421714312500177650ustar00rootroot00000000000000'use strict'; require('mocha'); const assert = require('assert'); const mm = require('..'); const opts = { strictSlashes: true, posix: true }; const isMatch = (...args) => { return mm.isMatch(...args, opts); }; const convert = (...args) => { let res = mm.parse(...args, opts); let str = ''; res.forEach(state => (str += state.output)); return str; }; describe('posix classes', () => { describe('posix bracket type conversion', () => { it('should create regex character classes from POSIX bracket expressions:', () => { assert.equal(convert('foo[[:lower:]]bar'), 'foo[a-z]bar'); assert.equal(convert('foo[[:lower:][:upper:]]bar'), 'foo[a-zA-Z]bar'); assert.equal(convert('[[:alpha:]123]'), '(?=.)[a-zA-Z123]'); assert.equal(convert('[[:lower:]]'), '(?=.)[a-z]'); assert.equal(convert('[![:lower:]]'), '(?=.)[^a-z]'); assert.equal(convert('[[:digit:][:upper:][:space:]]'), '(?=.)[0-9A-Z \\t\\r\\n\\v\\f]'); assert.equal(convert('[[:xdigit:]]'), '(?=.)[A-Fa-f0-9]'); assert.equal(convert('[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'), '(?=.)[a-zA-Z0-9a-zA-Z \\t\\x00-\\x1F\\x7F0-9\\x21-\\x7Ea-z\\x20-\\x7E \\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~ \\t\\r\\n\\v\\fA-ZA-Fa-f0-9]'); assert.equal(convert('[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'), '(?=.)[^a-zA-Z0-9a-zA-Z \\t\\x00-\\x1F\\x7F0-9a-z \\t\\r\\n\\v\\fA-ZA-Fa-f0-9]'); assert.equal(convert('[a-c[:digit:]x-z]'), '(?=.)[a-c0-9x-z]'); if (process.platform !== 'win32') { assert.equal(convert('[_[:alpha:]][_[:alnum:]][_[:alnum:]]*'), '(?=.)[_a-zA-Z][_a-zA-Z0-9][_a-zA-Z0-9][^/]*?', []); } }); }); describe('integration: posix classes with globs', () => { it('should work with globs', () => { let fixtures = ['a.b', 'a,b', 'a:b', 'a-b', 'a;b', 'a b', 'a_b']; assert.deepEqual(mm(fixtures, 'a[^[:alnum:]]b', { posix: true }), fixtures); assert.deepEqual(mm(fixtures, 'a@([^[:alnum:]])b', { posix: true }), fixtures); assert.deepEqual(mm(fixtures, 'a@([-.,:; _])b', { posix: true }), fixtures); assert.deepEqual(mm(fixtures, 'a@([^x])b', { posix: true }), ['a.b', 'a,b', 'a:b', 'a-b', 'a;b', 'a b', 'a_b']); assert.deepEqual(mm(fixtures, 'a+([^[:alnum:]])b', { posix: true }), fixtures); }); }); describe('.isMatch', () => { it('should support POSIX.2 character classes', () => { assert(isMatch('e', '[[:xdigit:]]')); assert(isMatch('a', '[[:alpha:]123]')); assert(isMatch('1', '[[:alpha:]123]')); assert(!isMatch('5', '[[:alpha:]123]')); assert(isMatch('A', '[[:alpha:]123]')); assert(isMatch('A', '[[:alpha:]]')); assert(!isMatch('9', '[[:alpha:]]')); assert(isMatch('b', '[[:alpha:]]')); assert(!isMatch('A', '[![:alpha:]]')); assert(isMatch('9', '[![:alpha:]]')); assert(!isMatch('b', '[![:alpha:]]')); assert(!isMatch('A', '[^[:alpha:]]')); assert(isMatch('9', '[^[:alpha:]]')); assert(!isMatch('b', '[^[:alpha:]]')); assert(!isMatch('A', '[[:digit:]]')); assert(isMatch('9', '[[:digit:]]')); assert(!isMatch('b', '[[:digit:]]')); assert(isMatch('A', '[^[:digit:]]')); assert(!isMatch('9', '[^[:digit:]]')); assert(isMatch('b', '[^[:digit:]]')); assert(isMatch('A', '[![:digit:]]')); assert(!isMatch('9', '[![:digit:]]')); assert(isMatch('b', '[![:digit:]]')); assert(isMatch('a', '[[:lower:]]')); assert(!isMatch('A', '[[:lower:]]')); assert(!isMatch('9', '[[:lower:]]')); assert(isMatch('a', '[:alpha:]'), 'invalid posix bracket, but valid char class'); assert(isMatch('l', '[:alpha:]'), 'invalid posix bracket, but valid char class'); assert(isMatch('p', '[:alpha:]'), 'invalid posix bracket, but valid char class'); assert(isMatch('h', '[:alpha:]'), 'invalid posix bracket, but valid char class'); assert(isMatch(':', '[:alpha:]'), 'invalid posix bracket, but valid char class'); assert(!isMatch('b', '[:alpha:]'), 'invalid posix bracket, but valid char class'); }); it('should support multiple posix brackets in one character class', () => { assert(isMatch('9', '[[:lower:][:digit:]]')); assert(isMatch('a', '[[:lower:][:digit:]]')); assert(!isMatch('A', '[[:lower:][:digit:]]')); assert(!isMatch('aa', '[[:lower:][:digit:]]')); assert(!isMatch('99', '[[:lower:][:digit:]]')); assert(!isMatch('a9', '[[:lower:][:digit:]]')); assert(!isMatch('9a', '[[:lower:][:digit:]]')); assert(!isMatch('aA', '[[:lower:][:digit:]]')); assert(!isMatch('9A', '[[:lower:][:digit:]]')); assert(isMatch('aa', '[[:lower:][:digit:]]+')); assert(isMatch('99', '[[:lower:][:digit:]]+')); assert(isMatch('a9', '[[:lower:][:digit:]]+')); assert(isMatch('9a', '[[:lower:][:digit:]]+')); assert(!isMatch('aA', '[[:lower:][:digit:]]+')); assert(!isMatch('9A', '[[:lower:][:digit:]]+')); assert(isMatch('a', '[[:lower:][:digit:]]*')); assert(!isMatch('A', '[[:lower:][:digit:]]*')); assert(!isMatch('AA', '[[:lower:][:digit:]]*')); assert(isMatch('aa', '[[:lower:][:digit:]]*')); assert(isMatch('aaa', '[[:lower:][:digit:]]*')); assert(isMatch('999', '[[:lower:][:digit:]]*')); }); it('should match word characters', () => { assert(!isMatch('a c', 'a[[:word:]]+c')); assert(!isMatch('a.c', 'a[[:word:]]+c')); assert(!isMatch('a.xy.zc', 'a[[:word:]]+c')); assert(!isMatch('a.zc', 'a[[:word:]]+c')); assert(!isMatch('abq', 'a[[:word:]]+c')); assert(!isMatch('axy zc', 'a[[:word:]]+c')); assert(!isMatch('axy', 'a[[:word:]]+c')); assert(!isMatch('axy.zc', 'a[[:word:]]+c')); assert(isMatch('a123c', 'a[[:word:]]+c')); assert(isMatch('a1c', 'a[[:word:]]+c')); assert(isMatch('abbbbc', 'a[[:word:]]+c')); assert(isMatch('abbbc', 'a[[:word:]]+c')); assert(isMatch('abbc', 'a[[:word:]]+c')); assert(isMatch('abc', 'a[[:word:]]+c')); assert(!isMatch('a c', 'a[[:word:]]+')); assert(!isMatch('a.c', 'a[[:word:]]+')); assert(!isMatch('a.xy.zc', 'a[[:word:]]+')); assert(!isMatch('a.zc', 'a[[:word:]]+')); assert(!isMatch('axy zc', 'a[[:word:]]+')); assert(!isMatch('axy.zc', 'a[[:word:]]+')); assert(isMatch('a123c', 'a[[:word:]]+')); assert(isMatch('a1c', 'a[[:word:]]+')); assert(isMatch('abbbbc', 'a[[:word:]]+')); assert(isMatch('abbbc', 'a[[:word:]]+')); assert(isMatch('abbc', 'a[[:word:]]+')); assert(isMatch('abc', 'a[[:word:]]+')); assert(isMatch('abq', 'a[[:word:]]+')); assert(isMatch('axy', 'a[[:word:]]+')); assert(isMatch('axyzc', 'a[[:word:]]+')); assert(isMatch('axyzc', 'a[[:word:]]+')); }); it('should match character classes', () => { assert(!isMatch('abc', 'a[bc]d')); assert(isMatch('abd', 'a[bc]d')); }); it('should match character class alphabetical ranges', () => { assert(!isMatch('abc', 'a[b-d]e')); assert(!isMatch('abd', 'a[b-d]e')); assert(isMatch('abe', 'a[b-d]e')); assert(!isMatch('ac', 'a[b-d]e')); assert(!isMatch('a-', 'a[b-d]e')); assert(!isMatch('abc', 'a[b-d]')); assert(!isMatch('abd', 'a[b-d]')); assert(isMatch('abd', 'a[b-d]+')); assert(!isMatch('abe', 'a[b-d]')); assert(isMatch('ac', 'a[b-d]')); assert(!isMatch('a-', 'a[b-d]')); }); it('should match character classes with leading dashes', () => { assert(!isMatch('abc', 'a[-c]')); assert(isMatch('ac', 'a[-c]')); assert(isMatch('a-', 'a[-c]')); }); it('should match character classes with trailing dashes', () => { assert(!isMatch('abc', 'a[c-]')); assert(isMatch('ac', 'a[c-]')); assert(isMatch('a-', 'a[c-]')); }); it('should match bracket literals', () => { assert(isMatch('a]c', 'a[]]c')); assert(isMatch('a]c', 'a]c')); assert(isMatch('a]', 'a]')); assert(isMatch('a[c', 'a[\\[]c')); assert(isMatch('a[c', 'a[c')); assert(isMatch('a[', 'a[')); }); it('should support negated character classes', () => { assert(!isMatch('a]', 'a[^bc]d')); assert(!isMatch('acd', 'a[^bc]d')); assert(isMatch('aed', 'a[^bc]d')); assert(isMatch('azd', 'a[^bc]d')); assert(!isMatch('ac', 'a[^bc]d')); assert(!isMatch('a-', 'a[^bc]d')); }); it('should match negated dashes', () => { assert(!isMatch('abc', 'a[^-b]c')); assert(isMatch('adc', 'a[^-b]c')); assert(!isMatch('a-c', 'a[^-b]c')); }); it('should match negated mm', () => { assert(isMatch('a-c', 'a[^\\]b]c')); assert(!isMatch('abc', 'a[^\\]b]c')); assert(!isMatch('a]c', 'a[^\\]b]c')); assert(isMatch('adc', 'a[^\\]b]c')); }); it('should match alpha-numeric characters', () => { assert(!isMatch('0123e45g78', '[\\de]+')); assert(isMatch('0123e456', '[\\de]+')); assert(isMatch('01234', '[\\de]+')); }); it('should not create an invalid posix character class:', () => { assert.equal(convert('[:al:]'), '(?:\\[:al:\\]|[:al:])'); assert.equal(convert('[abc[:punct:][0-9]'), '(?=.)[abc\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~\\[0-9]'); }); it('should return `true` when the pattern matches:', () => { assert(isMatch('a', '[[:lower:]]')); assert(isMatch('A', '[[:upper:]]')); assert(isMatch('A', '[[:digit:][:upper:][:space:]]')); assert(isMatch('1', '[[:digit:][:upper:][:space:]]')); assert(isMatch(' ', '[[:digit:][:upper:][:space:]]')); assert(isMatch('5', '[[:xdigit:]]')); assert(isMatch('f', '[[:xdigit:]]')); assert(isMatch('D', '[[:xdigit:]]')); assert(isMatch('_', '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]')); assert(isMatch('_', '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]')); assert(isMatch('.', '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]')); assert(isMatch('5', '[a-c[:digit:]x-z]')); assert(isMatch('b', '[a-c[:digit:]x-z]')); assert(isMatch('y', '[a-c[:digit:]x-z]')); }); it('should return `false` when the pattern does not match:', () => { assert(!isMatch('A', '[[:lower:]]')); assert(isMatch('A', '[![:lower:]]')); assert(!isMatch('a', '[[:upper:]]')); assert(!isMatch('a', '[[:digit:][:upper:][:space:]]')); assert(!isMatch('.', '[[:digit:][:upper:][:space:]]')); assert(!isMatch('.', '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]')); assert(!isMatch('q', '[a-c[:digit:]x-z]')); }); }); describe('literals', () => { it('should match literal brackets when escaped', () => { assert(isMatch('a [b]', 'a [b]')); assert(isMatch('a b', 'a [b]')); assert(isMatch('a [b] c', 'a [b] c')); assert(isMatch('a b c', 'a [b] c')); assert(isMatch('a [b]', 'a \\[b\\]')); assert(!isMatch('a b', 'a \\[b\\]')); assert(isMatch('a [b]', 'a ([b])')); assert(isMatch('a b', 'a ([b])')); assert(isMatch('a b', 'a (\\[b\\]|[b])')); assert(isMatch('a [b]', 'a (\\[b\\]|[b])')); }); }); describe('.makeRe()', () => { it('should make a regular expression for the given pattern:', () => { assert.deepEqual(mm.makeRe('[[:alpha:]123]', opts), /^(?:(?=.)[a-zA-Z123])$/); assert.deepEqual(mm.makeRe('[![:lower:]]', opts), /^(?:(?=.)[^a-z])$/); }); }); describe('POSIX: From the test suite for the POSIX.2 (BRE) pattern matching code:', () => { it('First, test POSIX.2 character classes', () => { assert(isMatch('e', '[[:xdigit:]]')); assert(isMatch('1', '[[:xdigit:]]')); assert(isMatch('a', '[[:alpha:]123]')); assert(isMatch('1', '[[:alpha:]123]')); }); it('should match using POSIX.2 negation patterns', () => { assert(isMatch('9', '[![:alpha:]]')); assert(isMatch('9', '[^[:alpha:]]')); }); it('should match word characters', () => { assert(isMatch('A', '[[:word:]]')); assert(isMatch('B', '[[:word:]]')); assert(isMatch('a', '[[:word:]]')); assert(isMatch('b', '[[:word:]]')); }); it('should match digits with word class', () => { assert(isMatch('1', '[[:word:]]')); assert(isMatch('2', '[[:word:]]')); }); it('should not digits', () => { assert(isMatch('1', '[[:digit:]]')); assert(isMatch('2', '[[:digit:]]')); }); it('should not match word characters with digit class', () => { assert(!isMatch('a', '[[:digit:]]')); assert(!isMatch('A', '[[:digit:]]')); }); it('should match uppercase alpha characters', () => { assert(isMatch('A', '[[:upper:]]')); assert(isMatch('B', '[[:upper:]]')); }); it('should not match lowercase alpha characters', () => { assert(!isMatch('a', '[[:upper:]]')); assert(!isMatch('b', '[[:upper:]]')); }); it('should not match digits with upper class', () => { assert(!isMatch('1', '[[:upper:]]')); assert(!isMatch('2', '[[:upper:]]')); }); it('should match lowercase alpha characters', () => { assert(isMatch('a', '[[:lower:]]')); assert(isMatch('b', '[[:lower:]]')); }); it('should not match uppercase alpha characters', () => { assert(!isMatch('A', '[[:lower:]]')); assert(!isMatch('B', '[[:lower:]]')); }); it('should match one lower and one upper character', () => { assert(isMatch('aA', '[[:lower:]][[:upper:]]')); assert(!isMatch('AA', '[[:lower:]][[:upper:]]')); assert(!isMatch('Aa', '[[:lower:]][[:upper:]]')); }); it('should match hexidecimal digits', () => { assert(isMatch('ababab', '[[:xdigit:]]*')); assert(isMatch('020202', '[[:xdigit:]]*')); assert(isMatch('900', '[[:xdigit:]]*')); }); it('should match punctuation characters (\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~)', () => { assert(isMatch('!', '[[:punct:]]')); assert(isMatch('?', '[[:punct:]]')); assert(isMatch('#', '[[:punct:]]')); assert(isMatch('&', '[[:punct:]]')); assert(isMatch('@', '[[:punct:]]')); assert(isMatch('+', '[[:punct:]]')); assert(isMatch('*', '[[:punct:]]')); assert(isMatch(':', '[[:punct:]]')); assert(isMatch('=', '[[:punct:]]')); assert(isMatch('|', '[[:punct:]]')); assert(isMatch('|++', '[[:punct:]]*')); }); it('should only match one character', () => { assert(!isMatch('?*+', '[[:punct:]]')); }); it('should only match one or more punctuation characters', () => { assert(isMatch('?*+', '[[:punct:]]*')); assert(!isMatch('foo', 'foo[[:punct:]]*')); assert(isMatch('foo?*+', 'foo[[:punct:]]*')); }); it('invalid character class expressions are just characters to be matched', () => { assert(isMatch('a', '[:al:]')); assert(isMatch('a', '[[:al:]')); assert(isMatch('!', '[abc[:punct:][0-9]')); }); it('should match the start of a valid sh identifier', () => { assert(isMatch('PATH', '[_[:alpha:]]*')); }); it('should match the first two characters of a valid sh identifier', () => { assert(isMatch('PATH', '[_[:alpha:]][_[:alnum:]]*')); }); it('should match multiple posix classses', () => { assert(isMatch('a1B', '[[:alpha:]][[:digit:]][[:upper:]]')); assert(!isMatch('a1b', '[[:alpha:]][[:digit:]][[:upper:]]')); assert(isMatch('.', '[[:digit:][:punct:][:space:]]')); assert(!isMatch('a', '[[:digit:][:punct:][:space:]]')); assert(isMatch('!', '[[:digit:][:punct:][:space:]]')); assert(!isMatch('!', '[[:digit:]][[:punct:]][[:space:]]')); assert(isMatch('1! ', '[[:digit:]][[:punct:]][[:space:]]')); assert(!isMatch('1! ', '[[:digit:]][[:punct:]][[:space:]]')); }); /** * Some of these tests (and their descriptions) were ported directly * from the Bash 4.3 unit tests. */ it('how about A?', () => { assert(isMatch('9', '[[:digit:]]')); assert(!isMatch('X', '[[:digit:]]')); assert(isMatch('aB', '[[:lower:]][[:upper:]]')); assert(isMatch('a', '[[:alpha:][:digit:]]')); assert(isMatch('3', '[[:alpha:][:digit:]]')); assert(!isMatch('aa', '[[:alpha:][:digit:]]')); assert(!isMatch('a3', '[[:alpha:][:digit:]]')); assert(!isMatch('a', '[[:alpha:]\\]')); assert(!isMatch('b', '[[:alpha:]\\]')); }); it('OK, what\'s a tab? is it a blank? a space?', () => { assert(isMatch('\t', '[[:blank:]]')); assert(isMatch('\t', '[[:space:]]')); assert(isMatch(' ', '[[:space:]]')); }); it('let\'s check out characters in the ASCII range', () => { assert(!isMatch('\\377', '[[:ascii:]]')); assert(!isMatch('9', '[1[:alpha:]123]')); }); it('punctuation', () => { assert(!isMatch(' ', '[[:punct:]]')); }); it('graph', () => { assert(isMatch('A', '[[:graph:]]')); assert(!isMatch('\b', '[[:graph:]]')); assert(!isMatch('\n', '[[:graph:]]')); assert(isMatch('\s', '[[:graph:]]')); }); }); }); micromatch-4.0.5/test/qmarks.js000066400000000000000000000132311421714312500164610ustar00rootroot00000000000000'use strict'; const path = require('path'); const assert = require('assert'); const mm = require('..'); const { isMatch } = mm; describe('qmarks and stars', () => { it('should match with qmarks', () => { assert(!isMatch('/ab', '/?')); assert(!isMatch('/ab', '?/?')); assert(isMatch('a/b', '?/?')); assert(isMatch('/ab', '/??')); assert(isMatch('/ab', '/?b')); assert(!isMatch('/ab', ['?/?', 'foo', 'bar'])); assert(!isMatch('/ab', ['a/*', 'foo', 'bar'])); }); it('should support qmark matching', () => { let arr = ['a', 'aa', 'ab', 'aaa', 'abcdefg']; assert.deepEqual(mm(arr, '?'), ['a']); assert.deepEqual(mm(arr, '??'), ['aa', 'ab']); assert.deepEqual(mm(arr, '???'), ['aaa']); }); it('should correctly handle question marks in globs', () => { assert.deepEqual(mm(['?', '??', '???'], '?'), ['?']); assert.deepEqual(mm(['?', '??', '???'], '??'), ['??']); assert.deepEqual(mm(['?', '??', '???'], '???'), ['???']); assert.deepEqual(mm(['/a/', '/a/b/', '/a/b/c/', '/a/b/c/d/'], '??'), []); mm(['/a/', '/a/b/', '/a/b/c/', '/a/b/c/d/'], '??', { dot: true }, []); assert.deepEqual(mm(['x/y/acb', 'acb', 'acb/', 'acb/d/e'], 'a?b'), ['acb']); assert.deepEqual(mm(['aaa', 'aac', 'abc'], 'a?c'), ['aac', 'abc']); assert.deepEqual(mm(['aaa', 'aac', 'abc'], 'a*?c'), ['aac', 'abc']); assert.deepEqual(mm(['a', 'aa', 'ab', 'ab?', 'ac', 'ac?', 'abcd', 'abbb'], 'ab?'), ['ab?']); assert.deepEqual(mm(['abc', 'abb', 'acc'], 'a**?c'), ['abc', 'acc']); assert.deepEqual(mm(['abc'], 'a*****?c'), ['abc']); assert.deepEqual(mm(['a', 'aa', 'abc', 'zzz', 'bbb', 'aaaa'], '*****?'), ['a', 'aa', 'abc', 'zzz', 'bbb', 'aaaa']); assert.deepEqual(mm(['a', 'aa', 'abc', 'zzz', 'bbb', 'aaaa'], '*****??'), ['aa', 'abc', 'zzz', 'bbb', 'aaaa']); assert.deepEqual(mm(['a', 'aa', 'abc', 'zzz', 'bbb', 'aaaa'], '?*****??'), ['abc', 'zzz', 'bbb', 'aaaa']); assert.deepEqual(mm(['abc', 'abb', 'zzz'], '?*****?c'), ['abc']); assert.deepEqual(mm(['abc', 'bbb', 'zzz'], '?***?****c'), ['abc']); assert.deepEqual(mm(['abc', 'bbb', 'zzz'], '?***?****?'), ['abc', 'bbb', 'zzz']); assert.deepEqual(mm(['abc'], '?***?****'), ['abc']); assert.deepEqual(mm(['abc'], '*******c'), ['abc']); assert.deepEqual(mm(['abc'], '*******?'), ['abc']); assert.deepEqual(mm(['abcdecdhjk'], 'a*cd**?**??k'), ['abcdecdhjk']); assert.deepEqual(mm(['abcdecdhjk'], 'a**?**cd**?**??k'), ['abcdecdhjk']); assert.deepEqual(mm(['abcdecdhjk'], 'a**?**cd**?**??k***'), ['abcdecdhjk']); assert.deepEqual(mm(['abcdecdhjk'], 'a**?**cd**?**??***k'), ['abcdecdhjk']); assert.deepEqual(mm(['abcdecdhjk'], 'a**?**cd**?**??***k**'), ['abcdecdhjk']); assert.deepEqual(mm(['abcdecdhjk'], 'a****c**?**??*****'), ['abcdecdhjk']); }); it('should match one character per question mark', () => { assert.deepEqual(mm(['a/b/c.md'], 'a/?/c.md'), ['a/b/c.md']); assert.deepEqual(mm(['a/bb/c.md'], 'a/?/c.md'), []); assert.deepEqual(mm(['a/bb/c.md'], 'a/??/c.md'), ['a/bb/c.md']); assert.deepEqual(mm(['a/bbb/c.md'], 'a/??/c.md'), []); assert.deepEqual(mm(['a/bbb/c.md'], 'a/???/c.md'), ['a/bbb/c.md']); assert.deepEqual(mm(['a/bbbb/c.md'], 'a/????/c.md'), ['a/bbbb/c.md']); }); it('should match multiple groups of question marks', () => { assert.deepEqual(mm(['a/bb/c/dd/e.md'], 'a/?/c/?/e.md'), []); assert.deepEqual(mm(['a/b/c/d/e.md'], 'a/?/c/?/e.md'), ['a/b/c/d/e.md']); assert.deepEqual(mm(['a/b/c/d/e.md'], 'a/?/c/???/e.md'), []); assert.deepEqual(mm(['a/b/c/zzz/e.md'], 'a/?/c/???/e.md'), ['a/b/c/zzz/e.md']); }); it('should use qmarks with other special characters', () => { assert.deepEqual(mm(['a/b/c/d/e.md'], 'a/?/c/?/*/e.md'), []); assert.deepEqual(mm(['a/b/c/d/e/e.md'], 'a/?/c/?/*/e.md'), ['a/b/c/d/e/e.md']); assert.deepEqual(mm(['a/b/c/d/efghijk/e.md'], 'a/?/c/?/*/e.md'), ['a/b/c/d/efghijk/e.md']); assert.deepEqual(mm(['a/b/c/d/efghijk/e.md'], 'a/?/**/e.md'), ['a/b/c/d/efghijk/e.md']); assert.deepEqual(mm(['a/bb/e.md'], 'a/?/e.md'), []); assert.deepEqual(mm(['a/bb/e.md'], 'a/?/**/e.md'), []); assert.deepEqual(mm(['a/b/c/d/efghijk/e.md'], 'a/*/?/**/e.md'), ['a/b/c/d/efghijk/e.md']); assert.deepEqual(mm(['a/b/c/d/efgh.ijk/e.md'], 'a/*/?/**/e.md'), ['a/b/c/d/efgh.ijk/e.md']); assert.deepEqual(mm(['a/b.bb/c/d/efgh.ijk/e.md'], 'a/*/?/**/e.md'), ['a/b.bb/c/d/efgh.ijk/e.md']); assert.deepEqual(mm(['a/bbb/c/d/efgh.ijk/e.md'], 'a/*/?/**/e.md'), ['a/bbb/c/d/efgh.ijk/e.md']); }); it('question marks should not match slashes', () => { assert(!isMatch('aaa/bbb', 'aaa?bbb')); assert(!isMatch('aaa//bbb', 'aaa?bbb')); if (process.platform === 'win32') { assert(!isMatch('aaa\\bbb', 'aaa?bbb')); assert(!isMatch('aaa\\\\bbb', 'aaa??bbb')); } else { assert(isMatch('aaa\\bbb', 'aaa?bbb')); assert(!isMatch('aaa\\\\bbb', 'aaa?bbb')); assert(isMatch('aaa\\\\bbb', 'aaa??bbb')); } assert(!isMatch('aaa/bbb', 'aaa?bbb')); }); it('question marks should match arbitrary dots', () => { assert(isMatch('aaa.bbb', 'aaa?bbb')); }); it('question marks should not match leading dots', () => { assert(!isMatch('.aaa/bbb', '?aaa/bbb')); assert(!isMatch('aaa/.bbb', 'aaa/?bbb')); }); it('question marks should match leading dots when options.dot is true', () => { assert(isMatch('aaa/.bbb', 'aaa/?bbb', {dot: true})); assert(isMatch('.aaa/bbb', '?aaa/bbb', {dot: true})); }); it('question marks should match characters preceding a dot', () => { assert(isMatch('a/bbb/abcd.md', 'a/*/ab??.md')); assert(isMatch('a/bbb/abcd.md', 'a/bbb/ab??.md')); assert(isMatch('a/bbb/abcd.md', 'a/bbb/ab???md')); }); }); micromatch-4.0.5/test/regex-features.js000066400000000000000000000153731421714312500201220ustar00rootroot00000000000000'use strict'; require('mocha'); const version = process.version; const assert = require('assert'); const mm = require('..'); describe('regex features', () => { describe('back-references', () => { it('should support regex backreferences', () => { assert(!mm.isMatch('1/2', '(*)/\\1')); assert(mm.isMatch('1/1', '(*)/\\1')); assert(mm.isMatch('1/1/1/1', '(*)/\\1/\\1/\\1')); assert(!mm.isMatch('1/11/111/1111', '(*)/\\1/\\1/\\1')); assert(mm.isMatch('1/11/111/1111', '(*)/(\\1)+/(\\1)+/(\\1)+')); assert(!mm.isMatch('1/2/1/1', '(*)/\\1/\\1/\\1')); assert(!mm.isMatch('1/1/2/1', '(*)/\\1/\\1/\\1')); assert(!mm.isMatch('1/1/1/2', '(*)/\\1/\\1/\\1')); assert(mm.isMatch('1/1/1/1', '(*)/\\1/(*)/\\2')); assert(!mm.isMatch('1/1/2/1', '(*)/\\1/(*)/\\2')); assert(!mm.isMatch('1/1/2/1', '(*)/\\1/(*)/\\2')); assert(mm.isMatch('1/1/2/2', '(*)/\\1/(*)/\\2')); }); }); describe('character classes', () => { it('should match regex character classes', () => { assert(!mm.isMatch('foo/bar', '**/[jkl]*')); assert(mm.isMatch('foo/jar', '**/[jkl]*')); assert(mm.isMatch('foo/bar', '**/[^jkl]*')); assert(!mm.isMatch('foo/jar', '**/[^jkl]*')); assert(mm.isMatch('foo/bar', '**/[abc]*')); assert(!mm.isMatch('foo/jar', '**/[abc]*')); assert(!mm.isMatch('foo/bar', '**/[^abc]*')); assert(mm.isMatch('foo/jar', '**/[^abc]*')); assert(mm.isMatch('foo/bar', '**/[abc]ar')); assert(!mm.isMatch('foo/jar', '**/[abc]ar')); }); it('should support valid regex ranges', () => { assert(!mm.isMatch('a/a', 'a/[b-c]')); assert(!mm.isMatch('a/z', 'a/[b-c]')); assert(mm.isMatch('a/b', 'a/[b-c]')); assert(mm.isMatch('a/c', 'a/[b-c]')); assert(mm.isMatch('a/b', '[a-z]/[a-z]')); assert(mm.isMatch('a/z', '[a-z]/[a-z]')); assert(mm.isMatch('z/z', '[a-z]/[a-z]')); assert(!mm.isMatch('a/x/y', 'a/[a-z]')); assert(mm.isMatch('a.a', '[a-b].[a-b]')); assert(mm.isMatch('a.b', '[a-b].[a-b]')); assert(!mm.isMatch('a.a.a', '[a-b].[a-b]')); assert(!mm.isMatch('c.a', '[a-b].[a-b]')); assert(!mm.isMatch('d.a.d', '[a-b].[a-b]')); assert(!mm.isMatch('a.bb', '[a-b].[a-b]')); assert(!mm.isMatch('a.ccc', '[a-b].[a-b]')); assert(mm.isMatch('a.a', '[a-d].[a-b]')); assert(mm.isMatch('a.b', '[a-d].[a-b]')); assert(!mm.isMatch('a.a.a', '[a-d].[a-b]')); assert(mm.isMatch('c.a', '[a-d].[a-b]')); assert(!mm.isMatch('d.a.d', '[a-d].[a-b]')); assert(!mm.isMatch('a.bb', '[a-d].[a-b]')); assert(!mm.isMatch('a.ccc', '[a-d].[a-b]')); assert(mm.isMatch('a.a', '[a-d]*.[a-b]')); assert(mm.isMatch('a.b', '[a-d]*.[a-b]')); assert(mm.isMatch('a.a.a', '[a-d]*.[a-b]')); assert(mm.isMatch('c.a', '[a-d]*.[a-b]')); assert(!mm.isMatch('d.a.d', '[a-d]*.[a-b]')); assert(!mm.isMatch('a.bb', '[a-d]*.[a-b]')); assert(!mm.isMatch('a.ccc', '[a-d]*.[a-b]')); }); it('should support valid regex ranges with glob negation patterns', () => { assert(!mm.isMatch('a.a', '!*.[a-b]')); assert(!mm.isMatch('a.b', '!*.[a-b]')); assert(!mm.isMatch('a.a.a', '!*.[a-b]')); assert(!mm.isMatch('c.a', '!*.[a-b]')); assert(mm.isMatch('d.a.d', '!*.[a-b]')); assert(mm.isMatch('a.bb', '!*.[a-b]')); assert(mm.isMatch('a.ccc', '!*.[a-b]')); assert(!mm.isMatch('a.a', '!*.[a-b]*')); assert(!mm.isMatch('a.b', '!*.[a-b]*')); assert(!mm.isMatch('a.a.a', '!*.[a-b]*')); assert(!mm.isMatch('c.a', '!*.[a-b]*')); assert(!mm.isMatch('d.a.d', '!*.[a-b]*')); assert(!mm.isMatch('a.bb', '!*.[a-b]*')); assert(mm.isMatch('a.ccc', '!*.[a-b]*')); assert(!mm.isMatch('a.a', '![a-b].[a-b]')); assert(!mm.isMatch('a.b', '![a-b].[a-b]')); assert(mm.isMatch('a.a.a', '![a-b].[a-b]')); assert(mm.isMatch('c.a', '![a-b].[a-b]')); assert(mm.isMatch('d.a.d', '![a-b].[a-b]')); assert(mm.isMatch('a.bb', '![a-b].[a-b]')); assert(mm.isMatch('a.ccc', '![a-b].[a-b]')); assert(!mm.isMatch('a.a', '![a-b]+.[a-b]+')); assert(!mm.isMatch('a.b', '![a-b]+.[a-b]+')); assert(mm.isMatch('a.a.a', '![a-b]+.[a-b]+')); assert(mm.isMatch('c.a', '![a-b]+.[a-b]+')); assert(mm.isMatch('d.a.d', '![a-b]+.[a-b]+')); assert(!mm.isMatch('a.bb', '![a-b]+.[a-b]+')); assert(mm.isMatch('a.ccc', '![a-b]+.[a-b]+')); }); it('should support valid regex ranges in negated character classes', () => { assert(!mm.isMatch('a.a', '*.[^a-b]')); assert(!mm.isMatch('a.b', '*.[^a-b]')); assert(!mm.isMatch('a.a.a', '*.[^a-b]')); assert(!mm.isMatch('c.a', '*.[^a-b]')); assert(mm.isMatch('d.a.d', '*.[^a-b]')); assert(!mm.isMatch('a.bb', '*.[^a-b]')); assert(!mm.isMatch('a.ccc', '*.[^a-b]')); assert(!mm.isMatch('a.a', 'a.[^a-b]*')); assert(!mm.isMatch('a.b', 'a.[^a-b]*')); assert(!mm.isMatch('a.a.a', 'a.[^a-b]*')); assert(!mm.isMatch('c.a', 'a.[^a-b]*')); assert(!mm.isMatch('d.a.d', 'a.[^a-b]*')); assert(!mm.isMatch('a.bb', 'a.[^a-b]*')); assert(mm.isMatch('a.ccc', 'a.[^a-b]*')); }); }); describe('capture groups', () => { it('should support regex capture groups', () => { assert(mm.isMatch('a/bb/c/dd/e.md', 'a/??/?/(dd)/e.md')); assert(mm.isMatch('a/b/c/d/e.md', 'a/?/c/?/(e|f).md')); assert(mm.isMatch('a/b/c/d/f.md', 'a/?/c/?/(e|f).md')); }); it('should support regex capture groups with slashes', () => { assert(!mm.isMatch('a/a', '(a/b)')); assert(mm.isMatch('a/b', '(a/b)')); assert(!mm.isMatch('a/c', '(a/b)')); assert(!mm.isMatch('b/a', '(a/b)')); assert(!mm.isMatch('b/b', '(a/b)')); assert(!mm.isMatch('b/c', '(a/b)')); }); it('should support regex non-capture groups', () => { assert(mm.isMatch('a/bb/c/dd/e.md', 'a/**/(?:dd)/e.md')); assert(mm.isMatch('a/b/c/d/e.md', 'a/?/c/?/(?:e|f).md')); assert(mm.isMatch('a/b/c/d/f.md', 'a/?/c/?/(?:e|f).md')); }); }); describe('lookarounds', () => { it('should support regex lookbehinds', () => { if (parseInt(version.slice(1), 10) >= 10) { assert(mm.isMatch('foo/cbaz', 'foo/*(? { Reflect.defineProperty(process, 'version', { value: 'v6.0.0' }); assert.throws(() => mm.isMatch('foo/cbaz', 'foo/*(? process.platform === 'win32' || path.sep === '\\'; const mm = require('..'); const { isMatch, makeRe } = mm; if (!process.env.ORIGINAL_PATH_SEP) { process.env.ORIGINAL_PATH_SEP = path.sep; } describe('special characters', () => { // See micromatch#127 describe('unicode', () => { it('should match Japanese characters', () => { assert(isMatch('フォルダ/aaa.js', 'フ*/**/*')); assert(isMatch('フォルダ/aaa.js', 'フォ*/**/*')); assert(isMatch('フォルダ/aaa.js', 'フォル*/**/*')); assert(isMatch('フォルダ/aaa.js', 'フ*ル*/**/*')); assert(isMatch('フォルダ/aaa.js', 'フォルダ/**/*')); }); }); describe('regex', () => { it('should match common regex characters', () => { let fixtures = ['a c', 'a1c', 'a123c', 'a.c', 'a.xy.zc', 'a.zc', 'abbbbc', 'abbbc', 'abbc', 'abc', 'abq', 'axy zc', 'axy', 'axy.zc', 'axyzc', '^abc$']; assert.deepEqual(mm(fixtures, 'ab?bc'), ['abbbc']); assert.deepEqual(mm(fixtures, 'ab*c'), ['abbbbc', 'abbbc', 'abbc', 'abc']); assert.deepEqual(mm(fixtures, '^abc$'), ['^abc$']); assert.deepEqual(mm(fixtures, 'a.c'), ['a.c']); assert.deepEqual(mm(fixtures, 'a.*c'), ['a.c', 'a.xy.zc', 'a.zc']); assert.deepEqual(mm(fixtures, 'a*c'), ['a c', 'a1c', 'a123c', 'a.c', 'a.xy.zc', 'a.zc', 'abbbbc', 'abbbc', 'abbc', 'abc', 'axy zc', 'axy.zc', 'axyzc']); assert.deepEqual(mm(fixtures, 'a(\\w)+c'), ['a1c', 'a123c', 'abbbbc', 'abbbc', 'abbc', 'abc', 'axyzc'], 'Should match word characters'); assert.deepEqual(mm(fixtures, 'a(\\W)+c'), ['a c', 'a.c'], 'Should match non-word characters'); assert.deepEqual(mm(fixtures, 'a(\\d)+c'), ['a1c', 'a123c'], 'Should match numbers'); assert.deepEqual(mm(['foo@#$%123ASD #$$%^&', 'foo!@#$asdfl;', '123'], '(\\d)+'), ['123']); assert.deepEqual(mm(['a123c', 'abbbc'], 'a(\\D)+c'), ['abbbc'], 'Should match non-numbers'); assert.deepEqual(mm(['foo', ' foo '], '(f|o)+\\b'), ['foo'], 'Should match word boundaries'); }); }); describe('slashes', () => { it('should match forward slashes', () => { assert(mm.isMatch('/', '/')); }); it('should match backslashes', () => { assert(mm.isMatch('\\', '[\\\\/]')); assert(mm.isMatch('\\', '[\\\\/]+')); assert(mm.isMatch('\\\\', '[\\\\/]+')); assert(mm.isMatch('\\\\\\', '[\\\\/]+')); if (isWindows()) { mm(['\\'], '[\\\\/]', ['/']); mm(['\\', '\\\\', '\\\\\\'], '[\\\\/]+', ['/']); } else { mm(['\\'], '[\\\\/]', ['\\']); mm(['\\', '\\\\', '\\\\\\'], '[\\\\/]+', ['\\', '\\\\', '\\\\\\']); } path.sep = '\\'; assert(mm.isMatch('\\', '[\\\\/]')); assert(mm.isMatch('\\', '[\\\\/]+')); assert(mm.isMatch('\\\\', '[\\\\/]+')); assert(mm.isMatch('\\\\\\', '[\\\\/]+')); mm(['\\'], '[\\\\/]', ['/']); mm(['\\', '\\\\', '\\\\\\'], '[\\\\/]+', ['/']); path.sep = process.env.ORIGINAL_PATH_SEP; }); }); describe('colons and drive letters', () => { it('should treat common URL characters as literals', () => { assert(mm.isMatch(':', ':')); assert(mm.isMatch(':/foo', ':/*')); assert(mm.isMatch('D://foo', 'D://*')); assert(mm.isMatch('D://foo', 'D:\\/\\/*')); }); }); describe('[ab] - brackets:', () => { it('should support regex character classes:', () => { assert.deepEqual(mm(['a/b.md', 'a/c.md', 'a/d.md', 'a/E.md'], 'a/[A-Z].md'), ['a/E.md']); assert.deepEqual(mm(['a/b.md', 'a/c.md', 'a/d.md'], 'a/[bd].md'), ['a/b.md', 'a/d.md']); assert.deepEqual(mm(['a-1.md', 'a-2.md', 'a-3.md', 'a-4.md', 'a-5.md'], 'a-[2-4].md'), ['a-2.md', 'a-3.md', 'a-4.md']); assert.deepEqual(mm(['a/b.md', 'b/b.md', 'c/b.md', 'b/c.md', 'a/d.md'], '[bc]/[bd].md'), ['b/b.md', 'c/b.md']); }); it('should handle brackets', () => { assert.deepEqual(mm(['ab', 'ac', 'ad', 'a*', '*'], '[a*]*', { regex: true }), ['a*', '*']); assert.deepEqual(mm(['ab', 'ac', 'ad', 'a*', '*'], '[a*]*'), ['ab', 'ac', 'ad', 'a*', '*']); }); it('should handle unclosed brackets', () => { assert.deepEqual(mm(['[!ab', '[ab'], '[!a*'), ['[!ab']); }); }); describe('(a|b) - logical OR:', () => { it('should support regex logical OR:', () => { assert.deepEqual(mm(['a/a', 'a/b', 'a/c', 'b/a', 'b/b'], '(a|b)/b'), ['a/b', 'b/b']); assert.deepEqual(mm(['a/a', 'a/b', 'a/c', 'b/a', 'b/b', 'c/b'], '((a|b)|c)/b'), ['a/b', 'b/b', 'c/b']); assert.deepEqual(mm(['a/b.md', 'a/c.md', 'a/d.md'], 'a/(b|d).md'), ['a/b.md', 'a/d.md']); assert.deepEqual(mm(['a-1.md', 'a-2.md', 'a-3.md', 'a-4.md', 'a-5.md'], 'a-(2|3|4).md'), ['a-2.md', 'a-3.md', 'a-4.md']); assert.deepEqual(mm(['a/b.md', 'b/b.md', 'c/b.md', 'b/c.md', 'a/d.md'], '(b|c)/(b|d).md'), ['b/b.md', 'c/b.md']); }); }); describe('dollar $', () => { it('should match dollar signs', () => { assert(!isMatch('$', '!($)')); assert(!isMatch('$', '!$')); assert(isMatch('$$', '!$')); assert(isMatch('$$', '!($)')); assert(isMatch('$$$', '!($)')); assert(isMatch('^', '!($)')); assert(isMatch('$', '!($$)')); assert(!isMatch('$$', '!($$)')); assert(isMatch('$$$', '!($$)')); assert(isMatch('^', '!($$)')); assert(!isMatch('$', '!($*)')); assert(!isMatch('$$', '!($*)')); assert(!isMatch('$$$', '!($*)')); assert(isMatch('^', '!($*)')); assert(isMatch('$', '*')); assert(isMatch('$$', '*')); assert(isMatch('$$$', '*')); assert(isMatch('^', '*')); assert(isMatch('$', '$*')); assert(isMatch('$$', '$*')); assert(isMatch('$$$', '$*')); assert(!isMatch('^', '$*')); assert(isMatch('$', '*$*')); assert(isMatch('$$', '*$*')); assert(isMatch('$$$', '*$*')); assert(!isMatch('^', '*$*')); assert(isMatch('$', '*$')); assert(isMatch('$$', '*$')); assert(isMatch('$$$', '*$')); assert(!isMatch('^', '*$')); assert(!isMatch('$', '?$')); assert(isMatch('$$', '?$')); assert(!isMatch('$$$', '?$')); assert(!isMatch('^', '?$')); }); }); describe('caret ^', () => { it('should match carets', () => { assert(isMatch('^', '^')); assert(isMatch('^/foo', '^/*')); assert(isMatch('^/foo', '^/*')); assert(isMatch('foo^', '*^')); assert(isMatch('^foo/foo', '^foo/*')); assert(isMatch('foo^/foo', 'foo^/*')); assert(!isMatch('^', '!(^)')); assert(isMatch('^^', '!(^)')); assert(isMatch('^^^', '!(^)')); assert(isMatch('&', '!(^)')); assert(isMatch('^', '!(^^)')); assert(!isMatch('^^', '!(^^)')); assert(isMatch('^^^', '!(^^)')); assert(isMatch('&', '!(^^)')); assert(!isMatch('^', '!(^*)')); assert(!isMatch('^^', '!(^*)')); assert(!isMatch('^^^', '!(^*)')); assert(isMatch('&', '!(^*)')); assert(isMatch('^', '*')); assert(isMatch('^^', '*')); assert(isMatch('^^^', '*')); assert(isMatch('&', '*')); assert(isMatch('^', '^*')); assert(isMatch('^^', '^*')); assert(isMatch('^^^', '^*')); assert(!isMatch('&', '^*')); assert(isMatch('^', '*^*')); assert(isMatch('^^', '*^*')); assert(isMatch('^^^', '*^*')); assert(!isMatch('&', '*^*')); assert(isMatch('^', '*^')); assert(isMatch('^^', '*^')); assert(isMatch('^^^', '*^')); assert(!isMatch('&', '*^')); assert(!isMatch('^', '?^')); assert(isMatch('^^', '?^')); assert(!isMatch('^^^', '?^')); assert(!isMatch('&', '?^')); }); }); }); micromatch-4.0.5/test/stars.js000066400000000000000000000331551421714312500163260ustar00rootroot00000000000000'use strict'; require('mocha'); const assert = require('assert'); const { isMatch } = require('..'); describe('stars', () => { describe('single stars', () => { it('should match using one consecutive star', () => { assert(!isMatch('a/b/c/z.js', '*.js')); assert(!isMatch('a/b/z.js', '*.js')); assert(!isMatch('a/z.js', '*.js')); assert(isMatch('a/z.js', '*/z*.js')); assert(isMatch('a/z.js', 'a/z*.js')); assert(isMatch('ab', '*')); assert(isMatch('abc', '*')); assert(isMatch('abc', '*c')); assert(isMatch('abc', 'a*')); assert(isMatch('abc', 'a*c')); assert(isMatch('abc', 'abc')); assert(isMatch('one abc two', '*abc*')); assert(isMatch('oneabctwo', '*abc*')); assert(isMatch('z.js', '*.js')); assert(isMatch('z.js', 'z*.js')); }); it('should support multiple non-consecutive stars in a path segment', () => { assert(!isMatch('a-b.c-d', '*-bc-*')); assert(isMatch('a-b.c-d', '*-*.*-*')); assert(isMatch('a-b.c-d', '*-b*c-*')); assert(isMatch('a-b.c-d', '*-b.c-*')); assert(isMatch('a-b.c-d', '*.*')); assert(isMatch('a-b.c-d', '*.*-*')); assert(isMatch('a-b.c-d', '*.*-d')); assert(isMatch('a-b.c-d', '*.c-*')); assert(isMatch('a-b.c-d', '*b.*d')); assert(isMatch('a-b.c-d', 'a*.c*')); assert(isMatch('a-b.c-d', 'a-*.*-d')); assert(isMatch('a.b', '*.*')); assert(isMatch('a.b', '*.b')); assert(isMatch('a.b', 'a.*')); assert(isMatch('a.b', 'a.b')); }); it('should support stars following brackets', () => { assert(isMatch('a', '[a]*')); assert(isMatch('aa', '[a]*')); assert(isMatch('aaa', '[a]*')); assert(isMatch('az', '[a-z]*')); assert(isMatch('zzz', '[a-z]*')); }); it('should support stars following parens', () => { assert(isMatch('a', '(a)*')); assert(isMatch('ab', '(a|b)*')); assert(isMatch('aa', '(a)*')); assert(isMatch('aaab', '(a|b)*')); assert(isMatch('aaabbb', '(a|b)*')); }); it('should not match slashes with single stars', () => { assert(!isMatch('a/b', '(a)*')); assert(!isMatch('a/b', '[a]*')); assert(!isMatch('a/b', 'a*')); assert(!isMatch('a/b', '(a|b)*')); }); it('should return true when one of the given patterns matches the string', () => { assert(isMatch('/ab', '*/*')); assert(isMatch('.', '.')); assert(!isMatch('a/.b', 'a/')); assert(isMatch('/ab', '/*')); assert(isMatch('/ab', '/??')); assert(isMatch('/ab', '/?b')); assert(isMatch('/cd', '/*')); assert(isMatch('a', 'a')); assert(isMatch('a/.b', 'a/.*')); assert(isMatch('a/b', '?/?')); assert(isMatch('a/b/c/d/e/j/n/p/o/z/c.md', 'a/**/j/**/z/*.md')); assert(isMatch('a/b/c/d/e/z/c.md', 'a/**/z/*.md')); assert(isMatch('a/b/c/xyz.md', 'a/b/c/*.md')); assert(isMatch('a/b/c/xyz.md', 'a/b/c/*.md')); assert(isMatch('a/b/z/.a', 'a/*/z/.a')); assert(!isMatch('a/b/z/.a', 'bz')); assert(isMatch('a/bb.bb/aa/b.b/aa/c/xyz.md', 'a/**/c/*.md')); assert(isMatch('a/bb.bb/aa/bb/aa/c/xyz.md', 'a/**/c/*.md')); assert(isMatch('a/bb.bb/c/xyz.md', 'a/*/c/*.md')); assert(isMatch('a/bb/c/xyz.md', 'a/*/c/*.md')); assert(isMatch('a/bbbb/c/xyz.md', 'a/*/c/*.md')); assert(isMatch('aaa', '*')); assert(isMatch('ab', '*')); assert(isMatch('ab', './*')); assert(isMatch('ab', 'ab')); assert(isMatch('ab/', './*/')); }); it('should return false when the path does not match the pattern', () => { assert(!isMatch('/ab', ['*/'])); assert(!isMatch('/ab', ['*/a'])); assert(!isMatch('/ab', ['/'])); assert(!isMatch('/ab', ['/?'])); assert(!isMatch('/ab', ['/a'])); assert(!isMatch('/ab', ['?/?'])); assert(!isMatch('/ab', ['a/*'])); assert(!isMatch('a/.b', ['a/'])); assert(!isMatch('a/b/c', ['a/*'])); assert(!isMatch('a/b/c', ['a/b'])); assert(!isMatch('a/b/c/d/e/z/c.md', ['b/c/d/e'])); assert(!isMatch('a/b/z/.a', ['b/z'])); assert(!isMatch('ab', ['*/*'])); assert(!isMatch('ab', ['/a'])); assert(!isMatch('ab', ['a'])); assert(!isMatch('ab', ['b'])); assert(!isMatch('ab', ['c'])); assert(!isMatch('abcd', ['ab'])); assert(!isMatch('abcd', ['bc'])); assert(!isMatch('abcd', ['c'])); assert(!isMatch('abcd', ['cd'])); assert(!isMatch('abcd', ['d'])); assert(!isMatch('abcd', ['f'])); assert(!isMatch('ef', ['/*'])); }); it('should match a path segment for each single star', () => { assert(!isMatch('aaa', '*/*/*')); assert(!isMatch('aaa/bb/aa/rr', '*/*/*')); assert(!isMatch('aaa/bba/ccc', 'aaa*')); assert(!isMatch('aaa/bba/ccc', 'aaa**')); assert(!isMatch('aaa/bba/ccc', 'aaa/*')); assert(!isMatch('aaa/bba/ccc', 'aaa/*ccc')); assert(!isMatch('aaa/bba/ccc', 'aaa/*z')); assert(!isMatch('aaa/bbb', '*/*/*')); assert(!isMatch('ab/zzz/ejkl/hi', '*/*jk*/*i')); assert(isMatch('aaa/bba/ccc', '*/*/*')); assert(isMatch('aaa/bba/ccc', 'aaa/**')); assert(isMatch('aaa/bbb', 'aaa/*')); assert(isMatch('ab/zzz/ejkl/hi', '*/*z*/*/*i')); assert(isMatch('abzzzejklhi', '*j*i')); }); it('should match any character besides "/" with a single "*"', () => { assert(isMatch('foo', 'f*')); assert(!isMatch('foo', 'b*')); assert(!isMatch('bar', 'f*')); assert(isMatch('bar', 'b*')); }); it('should support single globs (*)', () => { assert(isMatch('a', '*')); assert(isMatch('b', '*')); assert(!isMatch('a/a', '*')); assert(!isMatch('a/a/a', '*')); assert(!isMatch('a/a/b', '*')); assert(!isMatch('a/a/a/a', '*')); assert(!isMatch('a/a/a/a/a', '*')); assert(!isMatch('a', '*/*')); assert(isMatch('a/a', '*/*')); assert(!isMatch('a/a/a', '*/*')); assert(!isMatch('a', '*/*/*')); assert(!isMatch('a/a', '*/*/*')); assert(isMatch('a/a/a', '*/*/*')); assert(!isMatch('a/a/a/a', '*/*/*')); assert(!isMatch('a', '*/*/*/*')); assert(!isMatch('a/a', '*/*/*/*')); assert(!isMatch('a/a/a', '*/*/*/*')); assert(isMatch('a/a/a/a', '*/*/*/*')); assert(!isMatch('a/a/a/a/a', '*/*/*/*')); assert(!isMatch('a', '*/*/*/*/*')); assert(!isMatch('a/a', '*/*/*/*/*')); assert(!isMatch('a/a/a', '*/*/*/*/*')); assert(!isMatch('a/a/b', '*/*/*/*/*')); assert(!isMatch('a/a/a/a', '*/*/*/*/*')); assert(isMatch('a/a/a/a/a', '*/*/*/*/*')); assert(!isMatch('a/a/a/a/a/a', '*/*/*/*/*')); assert(!isMatch('a', 'a/*')); assert(isMatch('a/a', 'a/*')); assert(!isMatch('a/a/a', 'a/*')); assert(!isMatch('a/a/a/a', 'a/*')); assert(!isMatch('a/a/a/a/a', 'a/*')); assert(!isMatch('a', 'a/*/*')); assert(!isMatch('a/a', 'a/*/*')); assert(isMatch('a/a/a', 'a/*/*')); assert(!isMatch('b/a/a', 'a/*/*')); assert(!isMatch('a/a/a/a', 'a/*/*')); assert(!isMatch('a/a/a/a/a', 'a/*/*')); assert(!isMatch('a', 'a/*/*/*')); assert(!isMatch('a/a', 'a/*/*/*')); assert(!isMatch('a/a/a', 'a/*/*/*')); assert(isMatch('a/a/a/a', 'a/*/*/*')); assert(!isMatch('a/a/a/a/a', 'a/*/*/*')); assert(!isMatch('a', 'a/*/*/*/*')); assert(!isMatch('a/a', 'a/*/*/*/*')); assert(!isMatch('a/a/a', 'a/*/*/*/*')); assert(!isMatch('a/a/b', 'a/*/*/*/*')); assert(!isMatch('a/a/a/a', 'a/*/*/*/*')); assert(isMatch('a/a/a/a/a', 'a/*/*/*/*')); assert(!isMatch('a', 'a/*/a')); assert(!isMatch('a/a', 'a/*/a')); assert(isMatch('a/a/a', 'a/*/a')); assert(!isMatch('a/a/b', 'a/*/a')); assert(!isMatch('a/a/a/a', 'a/*/a')); assert(!isMatch('a/a/a/a/a', 'a/*/a')); assert(!isMatch('a', 'a/*/b')); assert(!isMatch('a/a', 'a/*/b')); assert(!isMatch('a/a/a', 'a/*/b')); assert(isMatch('a/a/b', 'a/*/b')); assert(!isMatch('a/a/a/a', 'a/*/b')); assert(!isMatch('a/a/a/a/a', 'a/*/b')); }); it('should only match a single folder per star when globstars are used', () => { assert(!isMatch('a', '*/**/a')); assert(!isMatch('a/a/b', '*/**/a')); assert(isMatch('a/a', '*/**/a')); assert(isMatch('a/a/a', '*/**/a')); assert(isMatch('a/a/a/a', '*/**/a')); assert(isMatch('a/a/a/a/a', '*/**/a')); }); it('should optionally match a trailing slash when single star is last char', () => { assert(isMatch('a', '*')); assert(isMatch('a/', '*{,/}')); assert(!isMatch('a/a', '*')); assert(!isMatch('a/b', '*')); assert(!isMatch('a/c', '*')); assert(!isMatch('a/x', '*')); assert(!isMatch('a/x/y', '*')); assert(!isMatch('a/x/y/z', '*')); assert(!isMatch('a', '*/')); assert(isMatch('a/', '*/')); assert(!isMatch('a/a', '*/')); assert(!isMatch('a/b', '*/')); assert(!isMatch('a/c', '*/')); assert(!isMatch('a/x', '*/')); assert(!isMatch('a/x/y', '*/')); assert(!isMatch('a/x/y/z', '*/')); assert(!isMatch('a', '*/*')); assert(!isMatch('a/', '*/*')); assert(isMatch('a/a', '*/*')); assert(isMatch('a/b', '*/*')); assert(isMatch('a/c', '*/*')); assert(isMatch('a/x', '*/*')); assert(!isMatch('a/x/y', '*/*')); assert(!isMatch('a/x/y/z', '*/*')); assert(!isMatch('a', 'a/*')); assert(!isMatch('a/', 'a/*')); assert(isMatch('a/a', 'a/*')); assert(isMatch('a/b', 'a/*')); assert(isMatch('a/c', 'a/*')); assert(isMatch('a/x', 'a/*')); assert(!isMatch('a/x/y', 'a/*')); assert(!isMatch('a/x/y/z', 'a/*')); }); it('should support globstars (**)', () => { assert(isMatch('a', '**')); assert(isMatch('a/', '**')); assert(isMatch('a/a', '**')); assert(isMatch('a/b', '**')); assert(isMatch('a/c', '**')); assert(isMatch('a/x', '**')); assert(isMatch('a/x/y', '**')); assert(isMatch('a/x/y/z', '**')); assert(!isMatch('a/', '**/a')); assert(!isMatch('a/b', '**/a')); assert(!isMatch('a/c', '**/a')); assert(!isMatch('a/x', '**/a')); assert(!isMatch('a/x/y', '**/a')); assert(!isMatch('a/x/y/z', '**/a')); assert(isMatch('a', '**/a')); assert(isMatch('a/a', '**/a')); assert(isMatch('a', 'a/**')); assert(isMatch('a/', 'a/**')); assert(isMatch('a/a', 'a/**')); assert(isMatch('a/b', 'a/**')); assert(isMatch('a/c', 'a/**')); assert(isMatch('a/x', 'a/**')); assert(isMatch('a/x/y', 'a/**')); assert(isMatch('a/x/y/z', 'a/**')); assert(!isMatch('a', 'a/**/*')); assert(!isMatch('a/', 'a/**/*')); assert(isMatch('a/a', 'a/**/*')); assert(isMatch('a/b', 'a/**/*')); assert(isMatch('a/c', 'a/**/*')); assert(isMatch('a/x', 'a/**/*')); assert(isMatch('a/x/y', 'a/**/*')); assert(isMatch('a/x/y/z', 'a/**/*')); assert(!isMatch('a', 'a/**/**/*')); assert(!isMatch('a/', 'a/**/**/*')); assert(isMatch('a/a', 'a/**/**/*')); assert(isMatch('a/b', 'a/**/**/*')); assert(isMatch('a/c', 'a/**/**/*')); assert(isMatch('a/x', 'a/**/**/*')); assert(isMatch('a/x/y', 'a/**/**/*')); assert(isMatch('a/x/y/z', 'a/**/**/*')); assert(!isMatch('a', 'a/**/**/**/*')); assert(!isMatch('a/', 'a/**/**/**/*')); assert(isMatch('a/a', 'a/**/**/**/*')); assert(isMatch('a/b', 'a/**/**/**/*')); assert(isMatch('a/c', 'a/**/**/**/*')); assert(isMatch('a/x', 'a/**/**/**/*')); assert(isMatch('a/x/y', 'a/**/**/**/*')); assert(isMatch('a/x/y/z', 'a/**/**/**/*')); assert(isMatch('a/b/foo/bar/baz.qux', 'a/b/**/bar/**/*.*')); assert(isMatch('a/b/bar/baz.qux', 'a/b/**/bar/**/*.*')); }); it('should work with file extensions', () => { assert(!isMatch('a.txt', 'a/**/*.txt')); assert(isMatch('a/b.txt', 'a/**/*.txt')); assert(isMatch('a/x/y.txt', 'a/**/*.txt')); assert(!isMatch('a/x/y/z', 'a/**/*.txt')); assert(!isMatch('a.txt', 'a/*.txt')); assert(isMatch('a/b.txt', 'a/*.txt')); assert(!isMatch('a/x/y.txt', 'a/*.txt')); assert(!isMatch('a/x/y/z', 'a/*.txt')); assert(isMatch('a.txt', 'a*.txt')); assert(!isMatch('a/b.txt', 'a*.txt')); assert(!isMatch('a/x/y.txt', 'a*.txt')); assert(!isMatch('a/x/y/z', 'a*.txt')); assert(isMatch('a.txt', '*.txt')); assert(!isMatch('a/b.txt', '*.txt')); assert(!isMatch('a/x/y.txt', '*.txt')); assert(!isMatch('a/x/y/z', '*.txt')); }); it('should correctly match slashes', () => { assert(!isMatch('a/a/bb', 'a/**/b')); assert(!isMatch('a/bb', 'a/**/b')); assert(!isMatch('foo', '*/**')); assert(!isMatch('foo/bar', '**/')); assert(!isMatch('foo/bar', '**/*/')); assert(!isMatch('foo/bar', '*/*/')); assert(!isMatch('foo/bar/', '**/*', { strictSlashes: true })); assert(isMatch('/home/foo/..', '**/..')); assert(isMatch('a/a', '*/**/a')); assert(isMatch('foo/', '*/**')); assert(isMatch('foo/bar', '**/*')); assert(isMatch('foo/bar', '*/*')); assert(isMatch('foo/bar', '*/**')); assert(isMatch('foo/bar/', '**/')); assert(isMatch('foo/bar/', '**/*')); assert(isMatch('foo/bar/', '**/*/')); assert(isMatch('foo/bar/', '*/**')); assert(isMatch('foo/bar/', '*/*/')); }); it('should optionally match trailing slashes with braces', () => { assert(isMatch('foo', '**/*')); assert(isMatch('foo', '**/*{,/}')); assert(isMatch('foo/', '**/*{,/}')); assert(isMatch('foo/bar', '**/*{,/}')); assert(isMatch('foo/bar/', '**/*{,/}')); }); }); });