pax_global_header 0000666 0000000 0000000 00000000064 13100363611 0014504 g ustar 00root root 0000000 0000000 52 comment=7374475242822d7b928af9b444968ea1edb14961
bash-match-1.0.2/ 0000775 0000000 0000000 00000000000 13100363611 0013513 5 ustar 00root root 0000000 0000000 bash-match-1.0.2/.editorconfig 0000664 0000000 0000000 00000000405 13100363611 0016167 0 ustar 00root root 0000000 0000000 root = true
[*]
indent_style = space
end_of_line = lf
charset = utf-8
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
[{**/{actual,fixtures,expected,templates}/**,*.md}]
trim_trailing_whitespace = false
insert_final_newline = false bash-match-1.0.2/.eslintrc.json 0000664 0000000 0000000 00000007125 13100363611 0016314 0 ustar 00root root 0000000 0000000 {
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true
},
"env": {
"browser": false,
"es6": true,
"node": true,
"mocha": 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"]
}
}
bash-match-1.0.2/.gitattributes 0000664 0000000 0000000 00000000200 13100363611 0016376 0 ustar 00root root 0000000 0000000 # Enforce Unix newlines
* text eol=lf
# binaries
*.ai binary
*.psd binary
*.jpg binary
*.gif binary
*.png binary
*.jpeg binary
bash-match-1.0.2/.github/ 0000775 0000000 0000000 00000000000 13100363611 0015053 5 ustar 00root root 0000000 0000000 bash-match-1.0.2/.github/contributing.md 0000664 0000000 0000000 00000006271 13100363611 0020112 0 ustar 00root root 0000000 0000000 # Contributing to bash-match
First and foremost, thank you! We appreciate that you want to contribute to bash-match, your time is valuable, and your contributions mean a lot to us.
**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 bash-match**
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 bash-match:
- star the [project](https://github.com/jonschlinkert/bash-match)
- tweet your support for bash-match
## Issues
### 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
- **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 bash-match 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/)
## Above and beyond
Here are some tips for creating idiomatic issues. Taking just a little bit extra time will make your issue easier to read, easier to resolve, more likely to be found by others who have the same or similar issue in the future.
- read the [Guide to Idiomatic Contributing](https://github.com/jonschlinkert/idiomatic-contributing)
- take some time to learn basic markdown. This [markdown cheatsheet](https://gist.github.com/jonschlinkert/5854601) is super helpful, as is the GitHub guide to [basic markdown](https://help.github.com/articles/markdown-basics/).
- 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/).
- use backticks to wrap code. This ensures that code will retain its format, making it much more readable to others
- use syntax highlighting by adding the correct language name after the first "code fence"
[node-glob]: https://github.com/isaacs/node-glob
[micromatch]: https://github.com/jonschlinkert/micromatch
[so]: http://stackoverflow.com/questions/tagged/bash-match bash-match-1.0.2/.gitignore 0000664 0000000 0000000 00000000417 13100363611 0015505 0 ustar 00root root 0000000 0000000 # always ignore files
*.DS_Store
*.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
bash-match-1.0.2/.travis.yml 0000664 0000000 0000000 00000000146 13100363611 0015625 0 ustar 00root root 0000000 0000000 sudo: false
os:
- linux
- osx
language: node_js
node_js:
- node
- '7'
- '6'
- '5'
- '4'
bash-match-1.0.2/.verb.md 0000664 0000000 0000000 00000000141 13100363611 0015045 0 ustar 00root root 0000000 0000000 ## Usage
```js
var {%= alias %} = require('{%= name %}');
```
## API
{%= apidocs("index.js") %}
bash-match-1.0.2/LICENSE 0000664 0000000 0000000 00000002077 13100363611 0014526 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2016-2017, 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.
bash-match-1.0.2/README.md 0000664 0000000 0000000 00000012167 13100363611 0015001 0 ustar 00root root 0000000 0000000 # bash-match [](https://www.npmjs.com/package/bash-match) [](https://npmjs.org/package/bash-match) [](https://npmjs.org/package/bash-match) [](https://travis-ci.org/micromatch/bash-match)
> Match strings using bash. Does not work on windows, and does not read from the file system. This library requires that Bash 4.3 or higher is installed and is mostly used for checking parity in unit tests.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save bash-match
```
Install with [yarn](https://yarnpkg.com):
```sh
$ yarn add bash-match
```
## Usage
```js
var readme = require('bash-match');
```
## API
### [bash](index.js#L30)
Returns true if `str` matches the given `pattern`.
**Params**
* `str` **{String}**
* `pattern` **{String}**
* `options` **{Options}**: Set `strictErrors` to true to throw when bash throws an error. Otherwise it just returns false.
* `returns` **{Boolean}**
**Example**
```js
var bash = require('bash-match');
console.log(bash('foo', 'f*'));
//=> true
console.log(bash('foo', 'b*'));
//=> false
```
.isMatch
### [.isMatch](index.js#L74)
Returns true if `str` matches the given `pattern`. Alias for the [main export](#bash).
**Params**
* `str` **{String}**
* `pattern` **{String}**
* `options` **{Options}**: Set `strictErrors` to true to throw when bash throws an error. Otherwise it just returns false.
* `returns` **{Boolean}**
**Example**
```js
var bash = require('bash-match');
console.log(bash.isMatch('foo', 'f*'));
//=> true
console.log(bash.isMatch('foo', 'b*'));
//=> false
```
.match
### [.match](index.js#L95)
Takes a `list` of strings and a glob `pattern`, and returns an array of strings that match the pattern.
**Params**
* `array` **{Array}**: List of strings to match
* `pattern` **{String}**: Glob pattern
* `options` **{Options}**: Set `strictErrors` to true to throw when bash throws an error. Otherwise it just returns false.
* `returns` **{Boolean}**
**Example**
```js
var bash = require('bash-match');
console.log(bash.match(['foo', 'bar'], 'b*'));
//=> ['bar']
```
## About
### Related projects
* [bash-glob](https://www.npmjs.com/package/bash-glob): Bash-powered globbing for node.js | [homepage](https://github.com/jonschlinkert/bash-glob "Bash-powered globbing for node.js")
* [braces](https://www.npmjs.com/package/braces): Fast, comprehensive, bash-like brace expansion implemented in JavaScript. Complete support for the Bash 4.3 braces… [more](https://github.com/micromatch/braces) | [homepage](https://github.com/micromatch/braces "Fast, comprehensive, bash-like brace expansion implemented in JavaScript. Complete support for the Bash 4.3 braces specification, without sacrificing speed.")
* [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/jonschlinkert/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.")
* [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/jonschlinkert/nanomatch) | [homepage](https://github.com/jonschlinkert/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)")
### 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.
### 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
```
### 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
```
### Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
### License
Copyright © 2017, [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.6.0, on April 27, 2017._ bash-match-1.0.2/index.js 0000664 0000000 0000000 00000010322 13100363611 0015156 0 ustar 00root root 0000000 0000000 'use strict';
var fs = require('fs');
var spawn = require('cross-spawn');
var extend = require('extend-shallow');
var isWindows = require('is-windows');
var isExtglob = require('is-extglob');
var bashPath;
/**
* Returns true if `str` matches the given `pattern`.
*
* ```js
* var bash = require('bash-match');
* console.log(bash('foo', 'f*'));
* //=> true
*
* console.log(bash('foo', 'b*'));
* //=> false
* ```
*
* @param {String} `str`
* @param {String} `pattern`
* @param {Options} `options` Set `strictErrors` to true to throw when bash throws an error. Otherwise it just returns false.
* @return {Boolean}
* @details false
* @api public
*/
function bash(str, pattern, options) {
if (typeof str !== 'string') {
throw new TypeError('expected a string');
}
if (typeof pattern !== 'string') {
throw new TypeError('expected a string');
}
if (isWindows()) {
throw new Error('bash-match does not work on windows');
}
try {
var opts = createOptions(pattern, options);
var res = spawn.sync(getBashPath(), cmd(str, pattern, opts), opts);
var err = toString(res.stderr);
if (err) {
return handleError(err, opts);
}
return !!toString(res.stdout);
} catch (err) {
return handleError(err, opts);
}
}
/**
* Returns true if `str` matches the given `pattern`. Alias for the [main export](#bash).
*
* ```js
* var bash = require('bash-match');
* console.log(bash.isMatch('foo', 'f*'));
* //=> true
*
* console.log(bash.isMatch('foo', 'b*'));
* //=> false
* ```
*
* @param {String} `str`
* @param {String} `pattern`
* @param {Options} `options` Set `strictErrors` to true to throw when bash throws an error. Otherwise it just returns false.
* @return {Boolean}
* @api public
*/
bash.isMatch = function(fixture, pattern, options) {
return bash(fixture, pattern, options);
};
/**
* Takes a `list` of strings and a glob `pattern`, and returns an array
* of strings that match the pattern.
*
* ```js
* var bash = require('bash-match');
* console.log(bash.match(['foo', 'bar'], 'b*'));
* //=> ['bar']
* ```
*
* @param {Array} `array` List of strings to match
* @param {String} `pattern` Glob pattern
* @param {Options} `options` Set `strictErrors` to true to throw when bash throws an error. Otherwise it just returns false.
* @return {Boolean}
* @api public
*/
bash.match = function(list, pattern, options) {
list = Array.isArray(list) ? list : [list];
var matches = [];
var len = list.length;
var idx = -1;
while (++idx < len) {
var fixture = list[idx];
if (bash.isMatch(fixture, pattern, options)) {
matches.push(fixture);
}
}
return matches;
};
/**
* Create the command to use
*/
function cmd(str, pattern, options) {
var valid = ['dotglob', 'extglob', 'failglob', 'globstar', 'nocaseglob', 'nullglob'];
var args = [];
for (var key in options) {
if (options.hasOwnProperty(key) && valid.indexOf(key) !== -1) {
args.push('-O', key);
}
}
args.push('-c', 'IFS=$"\n"; if [[ "' + str + '" = ' + pattern + ' ]]; then echo true; fi');
return args;
}
/**
* Stringify `buf`
*/
function toString(buf) {
return (buf && buf.toString() || '').trim();
}
/**
* Handle errors
*/
function handleError(err, options) {
if (options && options.strictErrors === true) {
throw err;
}
return false;
}
/**
* Shallow clone and create options
*/
function createOptions(pattern, options) {
if (options && options.normalized === true) return options;
var opts = extend({cwd: process.cwd()}, options);
if (opts.nocase === true) opts.nocaseglob = true;
if (opts.nonull === true) opts.nullglob = true;
if (opts.dot === true) opts.dotglob = true;
if (!opts.hasOwnProperty('globstar') && pattern.indexOf('**') !== -1) {
opts.globstar = true;
}
if (!opts.hasOwnProperty('extglob') && isExtglob(pattern)) {
opts.extglob = true;
}
opts.normalized = true;
return opts;
}
/**
* Get bash path
*/
function getBashPath() {
if (bashPath) return bashPath;
if (fs.existsSync('/usr/local/bin/bash')) {
bashPath = '/usr/local/bin/bash';
} else if (fs.existsSync('/bin/bash')) {
bashPath = '/bin/bash';
} else {
bashPath = 'bash';
}
return bashPath;
}
/**
* Expose `bash`
*/
module.exports = bash;
bash-match-1.0.2/package.json 0000664 0000000 0000000 00000002364 13100363611 0016006 0 ustar 00root root 0000000 0000000 {
"name": "bash-match",
"description": "Match strings using bash. Does not work on windows, and does not read from the file system. This library requires that Bash 4.3 or higher is installed and is mostly used for checking parity in unit tests.",
"version": "1.0.2",
"homepage": "https://github.com/micromatch/bash-match",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"repository": "micromatch/bash-match",
"bugs": {
"url": "https://github.com/micromatch/bash-match/issues"
},
"license": "MIT",
"files": [
"index.js"
],
"main": "index.js",
"engines": {
"node": ">=4.0"
},
"scripts": {
"test": "mocha"
},
"dependencies": {
"cross-spawn": "^5.1.0",
"extend-shallow": "^2.0.1",
"is-extglob": "^2.1.1",
"is-windows": "^1.0.0"
},
"devDependencies": {
"gulp-format-md": "^0.1.12",
"mocha": "^3.3.0"
},
"keywords": [
"bash",
"glob",
"match"
],
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"related": {
"list": [
"bash-glob",
"braces",
"micromatch",
"nanomatch"
]
},
"lint": {
"reflinks": true
}
}
}
bash-match-1.0.2/test.js 0000664 0000000 0000000 00000023744 13100363611 0015042 0 ustar 00root root 0000000 0000000 'use strict';
require('mocha');
var assert = require('assert');
var bash = require('./');
describe('running extglob against minimatch tests', function() {
var tests = [
['a/b/c', '**/c', true],
['a/b/c', '**/', false],
['a/b/c/', '**/', true],
['.a', '.*', true],
['*(a|b[)', '*(a|b\\[)', false],
['a', '*(a|b\\[)', true],
['b[', '*(a|b\\[)', true],
['123abc', 'ab*d+(e|f)', false],
['123abc', 'ab?*(e|f)', false],
['a', '!(a)', false],
['a', '@(a)', true],
['a', '@(b)', false],
['a', '*(a)', true],
['a', '+(a)', true],
['a', '?', true],
['a', '?(a|b)', true],
['a', '??', false],
['a', 'a?(a|b)', true],
['a', 'a?(x)', true],
['a', 'a??b', false],
['a', 'b?(a|b)', false],
['a.', '!(*.a|*.b|*.c)', true],
['a.', '*!(.a|.b|.c)', true],
['a.', '*.!(a)', true],
['a.', '*.!(a|b|c)', true],
['a.', '*.+(b|d)', false],
['a.a', '!(*.[a-b]*)', false],
['a.a', '!(*.a|*.b|*.c)', false],
['a.a', '!(*[a-b].[a-b]*)', false],
['a.a', '!*.(a|b)', false],
['a.a', '!*.(a|b)*', false],
['a.a', '@(a|d).(a|b)*', false],
['a.a', '*!(.a|.b|.c)', true],
['a.a', '*.!(a)', false],
['a.a', '*.+(b|d)', false],
['a.a.a', '!(*.[a-b]*)', false],
['a.a.a', '!(*[a-b].[a-b]*)', false],
['a.a.a', '!*.(a|b)', false],
['a.a.a', '!*.(a|b)*', false],
['a.a.a', '*.!(a)', true],
['a.a.a', '*.+(b|d)', false],
['a.abcd', '!(*.a|*.b|*.c)', true],
['a.abcd', '!(*.a|*.b|*.c)*', true],
['a.abcd', '*!(*.a|*.b|*.c)*', true],
['a.abcd', '*!(.a|.b|.c)', true],
['a.abcd', '*.!(a|b|c)', true],
['a.abcd', '*.!(a|b|c)*', true],
['a.b', '!(*.*)', false],
['a.b', '!(*.[a-b]*)', false],
['a.b', '!(*[a-b].[a-b]*)', false],
['a.b', '!*.(a|b)', false],
['a.b', '!*.(a|b)*', false],
['a.b', '@(a|d).(a|b)*', false],
['a.b', '*!(.a|.b|.c)', true],
['a.b', '*.!(a)', true],
['a.b', '*.+(b|d)', true],
['a.bb', '!(*.[a-b]*)', false],
['a.bb', '!(*[a-b].[a-b]*)', false],
['a.bb', '!*.(a|b)', false],
['a.bb', '!*.(a|b)*', false],
['a.bb', '@(a|d).(a|b)*', false],
['a.bb', '*.+(b|d)', true],
['a.c', '*!(.a|.b|.c)', true],
['a.c.d', '!(*.a|*.b|*.c)', true],
['a.c.d', '*!(.a|.b|.c)', true],
['a.c.d', '*.!(a|b|c)', true],
['a.ccc', '!(*.[a-b]*)', true],
['a.ccc', '!(*[a-b].[a-b]*)', true],
['a.ccc', '!*.(a|b)', false],
['a.ccc', '!*.(a|b)*', false],
['a.ccc', '*.+(b|d)', false],
['a.js', '!(*.js)', false],
['a.js', '*!(.js)', true],
['a.js', '*.!(js)', false],
['a.js.js', '!(*.js)', false],
['a.js.js', '*!(.js)', true],
['a.js.js', '*.!(js)', true],
['a.md', '!(*.js)', true],
['a.md', '*!(.js)', true],
['a.md', '*.!(js)', true],
['aa', '!(a)', true],
['aa', '?', false],
['aa', '@(a)b', false],
['aa', 'a??b', false],
['aaac', '*(@(a))a@(c)', true],
['aab', '?', false],
['aab', '??', false],
['aab', '@(c)b', false],
['aab', 'a??b', false],
['aaab', 'a??b', true],
['aac', '*(@(a))a@(c)', true],
['ab', '!(*.*)', true],
['ab', '@(a+|b)+', false],
['ab', 'a!(@(b|B))', false],
['aB', 'a!(@(b|B))', false],
['ab', 'ab**(e|f)', true],
['ab', 'ab**(e|f)g', false],
['ab', 'ab*+(e|f)', false],
['ab', 'ab*d+(e|f)', false],
['ab', 'ab?*(e|f)', false],
['ab]', 'a!(@(b|B))', true],
['abab', 'ab**(e|f)', true],
['abb', '!(*.*)', true],
['abbcd', '@(ab|a*(b))*(c)d', true],
['aBc', 'a!(@(b|B))', true],
['abcd', '?@(a|b)*@(c)d', true],
['abcd', '@(ab|a*@(b))*(c)d', true],
['abcdef', '@(a+|b)*', false],
['abcdef', '@(a+|b)+', false],
['abcdef', 'ab**(e|f)', true],
['abcdef', 'ab**(e|f)g', false],
['abcdef', 'ab*+(e|f)', true],
['abcdef', 'ab*d+(e|f)', true],
['abcdef', 'ab?*(e|f)', false],
['abcfef', '@(a+|b)*', false],
['abcfef', '@(a+|b)+', false],
['abcfef', 'ab**(e|f)', true],
['abcfef', 'ab**(e|f)g', false],
['abcfef', 'ab*+(e|f)', true],
['abcfef', 'ab*d+(e|f)', false],
['abcfef', 'ab?*(e|f)', true],
['abcfefg', '@(a+|b)*', false],
['abcfefg', '@(a+|b)+', false],
['abcfefg', 'ab**(e|f)', true],
['abcfefg', 'ab*d+(e|f)', false],
['abcfefg', 'ab?*(e|f)', false],
['abd', '@(a+|b)*', false],
['abd', '@(a+|b)+', false],
['abd', 'a!(@(b|B))', true],
['abd', 'a!(@(b|B))d', false],
['abd', 'ab**(e|f)', true],
['abd', 'ab*d+(e|f)', false],
['abd', 'ab?*(e|f)', true],
['abef', '@(a+|b)*', false],
['abef', '@(a+|b)+', false],
['abef', '*(a+|b)', false],
['abef', 'ab**(e|f)', true],
['abef', 'ab**(e|f)g', false],
['abef', 'ab*+(e|f)', true],
['abef', 'ab*d+(e|f)', false],
['abef', 'ab?*(e|f)', true],
['ac', '*(@(a))a@(c)', true],
['ac', 'a!(@(b|B))', true],
['acd', '@(a+|b)*', false],
['acd', '@(a+|b)+', false],
['acd', '@(ab|a*(b))*(c)d', true],
['acd', 'a!(@(b|B))', true],
['acd', 'a!(@(b|B))d', true],
['acd', 'ab*d+(e|f)', false],
['acd', 'ab?*(e|f)', false],
['ax', '?(a*|b)', true],
['ax', 'a?(b*)', false],
['b', '@(a+|b)*', true],
['b/a', '@(b/a)', true],
['b/b', '@(b/a)', false],
['b/c', '@(b/a)', false],
['ba', 'b?(a|b)', true],
['baaac', '*(@(a))a@(c)', false],
['bar', '@(foo)*', false],
['bar', '@(foo)b*', false],
['baz', '@(foo)*', false],
['baz', '@(foo)b*', false],
['bb', 'a?(a|b)', false],
['c', '*(@(a))a@(c)', false],
['c.a', '!(*.[a-b]*)', false],
['c.a', '!(*[a-b].[a-b]*)', true],
['c.a', '!*.(a|b)', false],
['c.a', '!*.(a|b)*', false],
['c.a', '*.!(a)', false],
['c.a', '*.+(b|d)', false],
['c.c', '*!(.a|.b|.c)', true],
['c.ccc', '!(*.[a-b]*)', true],
['c.ccc', '!(*[a-b].[a-b]*)', true],
['c.js', '!(*.js)', false],
['c.js', '*!(.js)', true],
['c.js', '*.!(js)', false],
['cow', '.!(*.*)', false],
['d.a.d', '!(*.[a-b]*)', false],
['d.a.d', '!(*[a-b].[a-b]*)', true],
['d.a.d', '!*.(a|b)', false],
['d.a.d', '!*.(a|b)*', false],
['d.a.d', '*.!(a)', true],
['d.a.d', '*.+(b|d)', true],
['d.d', '!(*.a|*.b|*.c)', true],
['d.d', '*!(.a|.b|.c)', true],
['d.d', '*.!(a|b|c)', true],
['d.js.d', '!(*.js)', true],
['d.js.d', '*!(.js)', true],
['d.js.d', '*.!(js)', true],
['e.e', '!(*.a|*.b|*.c)', true],
['e.e', '*!(.a|.b|.c)', true],
['e.e', '*.!(a|b|c)', true],
['effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', true],
['efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', true],
['egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', true],
['egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))', false],
['egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', true],
['f', '!(f)', false],
['f', '*(!(f))', false],
['f', '+(!(f))', false],
['f.a', '!(*.a|*.b|*.c)', false],
['f.a', '*!(.a|.b|.c)', true],
['f.a', '*.!(a|b|c)', false],
['f.f', '!(*.a|*.b|*.c)', true],
['f.f', '*!(.a|.b|.c)', true],
['f.f', '*.!(a|b|c)', true],
['fff', '!(f)', true],
['fff', '*(!(f))', true],
['fff', '+(!(f))', true],
['fffooofoooooffoofffooofff', '*(*(f)*(o))', true],
['ffo', '*(f*(o))', true],
['fofo', '*(f*(o))', true],
['fofoofoofofoo', '*(fo|foo)', true],
['foo', '!(f)', true],
['foo', '!(foo)', false],
['foo', '!(foo)*', true],
['foo', '!(foo)+', false],
['foo', '!(foo)b*', false],
['foo', '!(x)', true],
['foo', '!(x)*', true],
['foo', '*(!(f))', true],
['foo', '*(!(foo))', true],
['foo', '+(!(f))', true],
['foo.js.js', '*.!(js)', true],
['foo.js.js', '*.!(js)*', true],
['foo.js.js', '*.!(js)*.!(js)', false],
['foo.js.js', '*.!(js)+', false],
['foob', '!(foo)b*', false],
['foobar', '!(foo)', true],
['foobar', '!(foo)*', true],
['foobar', '!(foo)b*', false],
['foobb', '!(foo)b*', true],
['foofoofo', '@(foo|f|fo)*(f|of+(o))', true],
['fooofoofofooo', '*(f*(o))', true],
['foooofo', '*(f*(o))', true],
['foooofof', '*(f*(o))', true],
['foooofof', '*(f+(o))', false],
['foooofofx', '*(f*(o))', false],
['foooxfooxfoxfooox', '*(f*(o)x)', true],
['foooxfooxfxfooox', '*(f*(o)x)', true],
['foooxfooxofoxfooox', '*(f*(o)x)', false],
['foot', '@(!(z*)|*x)', true],
['foox', '@(!(z*)|*x)', true],
['mad.moo.cow', '!(*.*).!(*.*)', false],
['mad.moo.cow', '.!(*.*)', false],
['Makefile', '!(*.c|*.h|Makefile.in|config*|README)', true],
['Makefile.in', '!(*.c|*.h|Makefile.in|config*|README)', false],
['moo', '.!(*.*)', false],
['moo.cow', '!(*.*).!(*.*)', true],
['moo.cow', '.!(*.*)', false],
['mucca.pazza', 'mu!(*(c))?.pa!(*(z))?', false],
['ofoofo', '*(of+(o))', true],
['ofoofo', '*(of+(o)|f)', true],
['ofooofoofofooo', '*(f*(o))', false],
['ofoooxoofxo', '*(*(of*(o)x)o)', true],
['ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', true],
['ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', false],
['ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', true],
['ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', true],
['ofxoofxo', '*(*(of*(o)x)o)', true],
['oofooofo', '*(of|oof+(o))', true],
['ooo', '!(f)', true],
['ooo', '*(!(f))', true],
['ooo', '+(!(f))', true],
['oxfoxfox', '*(oxf+(ox))', false],
['oxfoxoxfox', '*(oxf+(ox))', true],
['parse.y', '!(*.c|*.h|Makefile.in|config*|README)', true],
['shell.c', '!(*.c|*.h|Makefile.in|config*|README)', false],
['xfoooofof', '*(f*(o))', false],
['zoot', '@(!(z*)|*x)', false],
['zoox', '@(!(z*)|*x)', true],
['zz', '@(a+|b)*', false],
];
tests.forEach(function(test) {
var fixture = test[0];
var pattern = test[1];
// if (pattern !== '*(a|b\\[)') return;
var expected = test[2];
var msg = 'should ' + (expected ? '' : 'not ')
+ 'match "' + fixture + '" with "' + pattern + '"';
it(msg, function(cb) {
try {
var match = bash.isMatch(fixture, pattern);
} catch (err) {
cb(err);
return;
}
assert.equal(match, expected, msg);
cb();
});
});
});