[Pkg-javascript-commits] [node-bash-match] 01/05: Import Upstream version 0.2.0

Sruthi Chandran srud-guest at moszumanska.debian.org
Mon Nov 7 07:38:31 UTC 2016


This is an automated email from the git hooks/post-receive script.

srud-guest pushed a commit to branch master
in repository node-bash-match.

commit 8635b30306d11df3baec9b6ee3708f8a0d7b754f
Author: Sruthi <srud at disroot.org>
Date:   Mon Nov 7 12:19:36 2016 +0530

    Import Upstream version 0.2.0
---
 .editorconfig           |  13 +++
 .eslintrc.json          | 122 +++++++++++++++++++
 .gitattributes          |  10 ++
 .github/contributing.md |  57 +++++++++
 .gitignore              |  21 ++++
 .travis.yml             |   5 +
 .verb.md                |   7 ++
 LICENSE                 |  21 ++++
 README.md               | 124 ++++++++++++++++++++
 index.js                | 184 +++++++++++++++++++++++++++++
 package.json            |  55 +++++++++
 test.js                 | 302 ++++++++++++++++++++++++++++++++++++++++++++++++
 12 files changed, 921 insertions(+)

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..818e072
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,13 @@
+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
\ No newline at end of file
diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 0000000..948dbdb
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,122 @@
+{
+  "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"]
+  }
+}
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..660957e
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,10 @@
+# Enforce Unix newlines
+* text eol=lf
+
+# binaries
+*.ai binary
+*.psd binary
+*.jpg binary
+*.gif binary
+*.png binary
+*.jpeg binary
diff --git a/.github/contributing.md b/.github/contributing.md
new file mode 100644
index 0000000..5d28a09
--- /dev/null
+++ b/.github/contributing.md
@@ -0,0 +1,57 @@
+# 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
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7988154
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,21 @@
+# always ignore files
+*.DS_Store
+*.sublime-*
+
+# test related, or directories generated by tests
+test/actual
+actual
+coverage
+
+# npm
+node_modules
+npm-debug.log
+
+# misc
+_gh_pages
+benchmark
+bower_components
+vendor
+temp
+tmp
+TODO.md
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..bf96649
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,5 @@
+sudo: false
+language: node_js
+node_js:
+  - node
+  - '6'
diff --git a/.verb.md b/.verb.md
new file mode 100644
index 0000000..28ac067
--- /dev/null
+++ b/.verb.md
@@ -0,0 +1,7 @@
+## Usage
+
+```js
+var {%= alias %} = require('{%= name %}');
+```
+## API
+{%= apidocs("index.js") %}
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..66ae69c
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 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.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..14c06b4
--- /dev/null
+++ b/README.md
@@ -0,0 +1,124 @@
+# bash-match [![NPM version](https://img.shields.io/npm/v/bash-match.svg?style=flat)](https://www.npmjs.com/package/bash-match) [![NPM downloads](https://img.shields.io/npm/dm/bash-match.svg?style=flat)](https://npmjs.org/package/bash-match) [![Build Status](https://img.shields.io/travis/jonschlinkert/bash-match.svg?style=flat)](https://travis-ci.org/jonschlinkert/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
+```
+
+## Usage
+
+```js
+var bash-match = require('bash-match');
+```
+
+## API
+
+### [bash](index.js#L27)
+
+Returns true if `str` matches the given `pattern`.
+
+**Example**
+
+```js
+var bash = require('bash-match');
+console.log(bash('foo', 'f*'));
+//=> true
+
+console.log(bash('foo', 'b*'));
+//=> false
+```
+
+**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}**
+
+### [.isMatch](index.js#L75)
+
+Returns true if `str` matches the given `pattern`. Alias for the [main export](#bash).
+
+**Example**
+
+```js
+var bash = require('bash-match');
+console.log(bash.isMatch('foo', 'f*'));
+//=> true
+
+console.log(bash.isMatch('foo', 'b*'));
+//=> false
+```
+
+**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}**
+
+### [.match](index.js#L96)
+
+Takes a `list` of strings and a glob `pattern`, and returns an array of strings that match the pattern.
+
+**Example**
+
+```js
+var bash = require('bash-match');
+console.log(bash.match(['foo', 'bar'], 'b*'));
+//=> ['bar']
+```
+
+**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}**
+
+## 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 avice on opening issues, pull requests, and coding standards.
+
+### Building docs
+
+_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
+
+To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
+
+```sh
+$ npm install -g verb verb-generate-readme && verb
+```
+
+### Running tests
+
+Install dev dependencies:
+
+```sh
+$ npm install -d && npm test
+```
+
+### Author
+
+**Jon Schlinkert**
+
+* [github/jonschlinkert](https://github.com/jonschlinkert)
+* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
+
+### License
+
+Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
+Released under the [MIT license](https://github.com/jonschlinkert/bash-match/blob/master/LICENSE).
+
+***
+
+_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.31, on October 17, 2016._
\ No newline at end of file
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..295980c
--- /dev/null
+++ b/index.js
@@ -0,0 +1,184 @@
+'use strict';
+
+var spawn = require('cross-spawn');
+var exists = require('fs-exists-sync');
+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}
+ * @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 (exists('/usr/local/bin/bash')) {
+    bashPath = '/usr/local/bin/bash';
+  } else if (exists('/bin/bash')) {
+    bashPath = '/bin/bash';
+  } else {
+    bashPath = 'bash';
+  }
+  return bashPath;
+}
+
+/**
+ * Expose `bash`
+ */
+
+module.exports = bash;
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..7a6c68a
--- /dev/null
+++ b/package.json
@@ -0,0 +1,55 @@
+{
+  "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": "0.2.0",
+  "homepage": "https://github.com/jonschlinkert/bash-match",
+  "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
+  "repository": "jonschlinkert/bash-match",
+  "bugs": {
+    "url": "https://github.com/jonschlinkert/bash-match/issues"
+  },
+  "license": "MIT",
+  "files": [
+    "index.js"
+  ],
+  "main": "index.js",
+  "engines": {
+    "node": ">=0.10.0"
+  },
+  "scripts": {
+    "test": "mocha"
+  },
+  "dependencies": {
+    "cross-spawn": "^4.0.2",
+    "extend-shallow": "^2.0.1",
+    "fs-exists-sync": "^0.1.0",
+    "is-extglob": "^2.1.0",
+    "is-windows": "^0.2.0"
+  },
+  "devDependencies": {
+    "gulp-format-md": "^0.1.11",
+    "mocha": "^3.1.2"
+  },
+  "keywords": [
+    "bash",
+    "generategenerator",
+    "match"
+  ],
+  "verb": {
+    "toc": false,
+    "layout": "default",
+    "tasks": [
+      "readme"
+    ],
+    "plugins": [
+      "gulp-format-md"
+    ],
+    "reflinks": [
+      "verb",
+      "verb-generate-readme"
+    ],
+    "lint": {
+      "reflinks": true
+    }
+  }
+}
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..a4a5ec7
--- /dev/null
+++ b/test.js
@@ -0,0 +1,302 @@
+'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();
+    });
+  });
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-bash-match.git



More information about the Pkg-javascript-commits mailing list