Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: micromatch/extglob
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b00d865652d844b80164ea544323a36c838b3e58
Choose a base ref
...
head repository: micromatch/extglob
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0daa3ed65a05fd73a9fd44714350e6c79c22f780
Choose a head ref
  • 7 commits
  • 16 files changed
  • 2 contributors

Commits on Apr 9, 2018

  1. Update snapdragon to 0.11

    danez committed Apr 9, 2018
    Copy the full SHA
    ed10fb2 View commit details

Commits on Apr 30, 2018

  1. Update dependencies

    danez committed Apr 30, 2018
    Copy the full SHA
    841c540 View commit details
  2. Drop support for node <4

    danez committed Apr 30, 2018
    Copy the full SHA
    8fdd4e2 View commit details
  3. Fix linting

    danez committed Apr 30, 2018
    Copy the full SHA
    ff338f9 View commit details
  4. Use let/const

    danez committed Apr 30, 2018
    Copy the full SHA
    e90b000 View commit details
  5. Merge pull request #12 from micromatch/snap-11

    Update snapdragon to 0.12
    danez authored Apr 30, 2018
    Copy the full SHA
    dedd109 View commit details
  6. 3.0.0

    danez committed Apr 30, 2018
    2
    Copy the full SHA
    0daa3ed View commit details
Showing with 220 additions and 241 deletions.
  1. +1 −6 .travis.yml
  2. +1 −1 LICENSE
  3. +73 −88 README.md
  4. +2 −4 appveyor.yml
  5. +15 −15 benchmark/stats.md
  6. +8 −0 changelog.md
  7. +5 −5 gulpfile.js
  8. +33 −34 index.js
  9. +16 −16 lib/compilers.js
  10. +11 −10 lib/extglob.js
  11. +33 −41 lib/parsers.js
  12. +9 −9 lib/utils.js
  13. +8 −7 package.json
  14. +3 −3 test/_negations.js
  15. +1 −1 test/bash.extglob2.js
  16. +1 −1 test/reference.js
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -4,12 +4,7 @@ os:
- osx
language: node_js
node_js:
- node
- '9'
- '10'
- '8'
- '7'
- '6'
- '5'
- '4'
- '0.12'
- '0.10'
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-2017, Jon Schlinkert.
Copyright (c) 2015-2018, 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
161 changes: 73 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# extglob [![NPM version](https://img.shields.io/npm/v/extglob.svg?style=flat)](https://www.npmjs.com/package/extglob) [![NPM monthly downloads](https://img.shields.io/npm/dm/extglob.svg?style=flat)](https://npmjs.org/package/extglob) [![NPM total downloads](https://img.shields.io/npm/dt/extglob.svg?style=flat)](https://npmjs.org/package/extglob) [![Linux Build Status](https://img.shields.io/travis/micromatch/extglob.svg?style=flat&label=Travis)](https://travis-ci.org/micromatch/extglob) [![Windows Build Status](https://img.shields.io/appveyor/ci/micromatch/extglob.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/micromatch/extglob)
# extglob [![NPM version](https://img.shields.io/npm/v/extglob.svg?style=flat)](https://www.npmjs.com/package/extglob) [![NPM monthly downloads](https://img.shields.io/npm/dm/extglob.svg?style=flat)](https://npmjs.org/package/extglob) [![NPM total downloads](https://img.shields.io/npm/dt/extglob.svg?style=flat)](https://npmjs.org/package/extglob) [![Linux Build Status](https://img.shields.io/travis/micromatch/extglob.svg?style=flat&label=Travis)](https://travis-ci.org/micromatch/extglob) [![Windows Build Status](https://img.shields.io/appveyor/ci/micromatch/extglob.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/micromatch/extglob)

> Extended glob support for JavaScript. Adds (almost) the expressive power of regular expressions to glob patterns.
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.

## Install

Install with [npm](https://www.npmjs.com/):
@@ -12,6 +10,12 @@ Install with [npm](https://www.npmjs.com/):
$ npm install --save extglob
```

Install with [yarn](https://yarnpkg.com):

```sh
$ yarn add extglob
```

* Convert an extglob string to a regex-compatible string.
* More complete (and correct) support than [minimatch](https://github.com/isaacs/minimatch) (minimatch fails a large percentage of the extglob tests)
* Handles [negation patterns](#extglob-patterns)
@@ -34,17 +38,17 @@ console.log(extglob('!(xyz)*.js'));

Extended globbing patterns can be defined as follows (as described by the [bash man page](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html)):

| **pattern** | **regex equivalent** | **description** |
| **pattern** | **regex equivalent** | **description** |
| --- | --- | --- |
| `?(pattern-list)` | `(...|...)?` | Matches zero or one occurrence of the given pattern(s) |
| `*(pattern-list)` | `(...|...)*` | Matches zero or more occurrences of the given pattern(s) |
| `+(pattern-list)` | `(...|...)+` | Matches one or more occurrences of the given pattern(s) |
| `@(pattern-list)` | `(...|...)` <sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup> | Matches one of the given pattern(s) |
| `!(pattern-list)` | N/A | Matches anything except one of the given pattern(s) |
| `?(pattern-list)` | `(...\|...)?` | Matches zero or one occurrence of the given pattern(s) |
| `*(pattern-list)` | `(...\|...)*` | Matches zero or more occurrences of the given pattern(s) |
| `+(pattern-list)` | `(...\|...)+` | Matches one or more occurrences of the given pattern(s) |
| `@(pattern-list)` | `(...\|...)` [^1] | Matches one of the given pattern(s) |
| `!(pattern-list)` | N/A | Matches anything except one of the given pattern(s) |

## API

### [extglob](index.js#L36)
### [extglob](index.js#L35)

Convert the given `extglob` pattern into a regex-compatible string. Returns an object with the compiled result and the parsed AST.

@@ -57,12 +61,12 @@ Convert the given `extglob` pattern into a regex-compatible string. Returns an o
**Example**

```js
var extglob = require('extglob');
const extglob = require('extglob');
console.log(extglob('*.!(*a)'));
//=> '(?!\\.)[^/]*?\\.(?!(?!\\.)[^/]*?a\\b).*?'
```

### [.match](index.js#L56)
### [.match](index.js#L55)

Takes an array of strings and an extglob pattern and returns a new array that contains only the strings that match the pattern.

@@ -76,12 +80,12 @@ Takes an array of strings and an extglob pattern and returns a new array that co
**Example**

```js
var extglob = require('extglob');
const extglob = require('extglob');
console.log(extglob.match(['a.a', 'a.b', 'a.c'], '*.!(*a)'));
//=> ['a.b', 'a.c']
```

### [.isMatch](index.js#L111)
### [.isMatch](index.js#L110)

Returns true if the specified `string` matches the given extglob `pattern`.

@@ -95,15 +99,15 @@ Returns true if the specified `string` matches the given extglob `pattern`.
**Example**

```js
var extglob = require('extglob');
const extglob = require('extglob');

console.log(extglob.isMatch('a.a', '*.!(*a)'));
//=> false
console.log(extglob.isMatch('a.b', '*.!(*a)'));
//=> true
```

### [.contains](index.js#L150)
### [.contains](index.js#L149)

Returns true if the given `string` contains the given pattern. Similar to `.isMatch` but the pattern can match any part of the string.

@@ -117,14 +121,14 @@ Returns true if the given `string` contains the given pattern. Similar to `.isMa
**Example**

```js
var extglob = require('extglob');
const extglob = require('extglob');
console.log(extglob.contains('aa/bb/cc', '*b'));
//=> true
console.log(extglob.contains('aa/bb/cc', '*d'));
//=> false
```

### [.matcher](index.js#L184)
### [.matcher](index.js#L183)

Takes an extglob pattern and returns a matcher function. The returned function takes the string to match as its only argument.

@@ -137,16 +141,16 @@ Takes an extglob pattern and returns a matcher function. The returned function t
**Example**

```js
var extglob = require('extglob');
var isMatch = extglob.matcher('*.!(*a)');
const extglob = require('extglob');
const isMatch = extglob.matcher('*.!(*a)');

console.log(isMatch('a.a'));
//=> false
console.log(isMatch('a.b'));
//=> true
```

### [.create](index.js#L214)
### [.create](index.js#L213)

Convert the given `extglob` pattern into a regex-compatible string. Returns an object with the compiled result and the parsed AST.

@@ -159,12 +163,12 @@ Convert the given `extglob` pattern into a regex-compatible string. Returns an o
**Example**

```js
var extglob = require('extglob');
const extglob = require('extglob');
console.log(extglob.create('*.!(*a)').output);
//=> '(?!\\.)[^/]*?\\.(?!(?!\\.)[^/]*?a\\b).*?'
```

### [.capture](index.js#L248)
### [.capture](index.js#L247)

Returns an array of matches captured by `pattern` in `string`, or `null` if the pattern did not match.

@@ -178,7 +182,7 @@ Returns an array of matches captured by `pattern` in `string`, or `null` if the
**Example**

```js
var extglob = require('extglob');
const extglob = require('extglob');
extglob.capture(pattern, string[, options]);

console.log(extglob.capture('test/*.js', 'test/foo.js'));
@@ -187,7 +191,7 @@ console.log(extglob.capture('test/*.js', 'foo/bar.css'));
//=> null
```

### [.makeRe](index.js#L281)
### [.makeRe](index.js#L280)

Create a regular expression from the given `pattern` and `options`.

@@ -200,8 +204,8 @@ Create a regular expression from the given `pattern` and `options`.
**Example**

```js
var extglob = require('extglob');
var re = extglob.makeRe('*.!(*a)');
const extglob = require('extglob');
const re = extglob.makeRe('*.!(*a)');
console.log(re);
//=> /^[^\/]*?\.(?![^\/]*?a)[^\/]*?$/
```
@@ -240,38 +244,38 @@ Throw an error is no matches are found.

## Benchmarks

Last run on December 21, 2017
Last run on April 30, 2018

```sh
# negation-nested (49 bytes)
extglob x 2,228,255 ops/sec ±0.98% (89 runs sampled)
minimatch x 207,875 ops/sec ±0.61% (91 runs sampled)
extglob x 1,380,148 ops/sec ±3.35% (62 runs sampled)
minimatch x 156,800 ops/sec ±4.13% (76 runs sampled)

fastest is extglob (by 1072% avg)
fastest is extglob (by 880% avg)

# negation-simple (43 bytes)
extglob x 2,205,668 ops/sec ±1.00% (91 runs sampled)
minimatch x 311,923 ops/sec ±1.25% (91 runs sampled)
extglob x 1,821,746 ops/sec ±1.61% (76 runs sampled)
minimatch x 365,618 ops/sec ±1.87% (84 runs sampled)

fastest is extglob (by 707% avg)
fastest is extglob (by 498% avg)

# range-false (57 bytes)
extglob x 2,263,877 ops/sec ±0.40% (94 runs sampled)
minimatch x 271,372 ops/sec ±1.02% (91 runs sampled)
extglob x 2,038,592 ops/sec ±3.39% (85 runs sampled)
minimatch x 310,897 ops/sec ±12.62% (87 runs sampled)

fastest is extglob (by 834% avg)
fastest is extglob (by 656% avg)

# range-true (56 bytes)
extglob x 2,161,891 ops/sec ±0.41% (92 runs sampled)
minimatch x 268,265 ops/sec ±1.17% (91 runs sampled)
extglob x 2,105,081 ops/sec ±0.69% (91 runs sampled)
minimatch x 332,188 ops/sec ±0.45% (91 runs sampled)

fastest is extglob (by 806% avg)
fastest is extglob (by 634% avg)

# star-simple (46 bytes)
extglob x 2,211,081 ops/sec ±0.49% (92 runs sampled)
minimatch x 343,319 ops/sec ±0.59% (91 runs sampled)
extglob x 2,154,184 ops/sec ±0.99% (89 runs sampled)
minimatch x 452,812 ops/sec ±0.51% (88 runs sampled)

fastest is extglob (by 644% avg)
fastest is extglob (by 476% avg)

```

@@ -284,25 +288,31 @@ This library has complete parity with Bash 4.3 with only a couple of minor diffe

## About

<details>
<summary><strong>Contributing</strong></summary>
### Related projects

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
* [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.")
* [expand-range](https://www.npmjs.com/package/expand-range): Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. Used… [more](https://github.com/jonschlinkert/expand-range) | [homepage](https://github.com/jonschlinkert/expand-range "Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. Used by [micromatch].")
* [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`")
* [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/micromatch/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.")

</details>
### Contributing

<details>
<summary><strong>Running Tests</strong></summary>
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

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:
### Contributors

```sh
$ npm install && npm test
```
| **Commits** | **Contributor** |
| --- | --- |
| 54 | [jonschlinkert](https://github.com/jonschlinkert) |
| 6 | [danez](https://github.com/danez) |
| 2 | [isiahmeadows](https://github.com/isiahmeadows) |
| 1 | [doowb](https://github.com/doowb) |
| 1 | [devongovett](https://github.com/devongovett) |
| 1 | [mjbvz](https://github.com/mjbvz) |
| 1 | [shinnn](https://github.com/shinnn) |

</details>
<details>
<summary><strong>Building docs</strong></summary>
### 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.)_

@@ -312,51 +322,26 @@ To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```

</details>

### 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/jonschlinkert/expand-brackets "Expand POSIX bracket expressions (character classes) in glob patterns.")
* [expand-range](https://www.npmjs.com/package/expand-range): Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. Used… [more](https://github.com/jonschlinkert/expand-range) | [homepage](https://github.com/jonschlinkert/expand-range "Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. Used by [micromatch].")
* [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`")
* [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/micromatch/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.")
### Running tests

### Contributors
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:

| **Commits** | **Contributor** |
| --- | --- |
| 49 | [jonschlinkert](https://github.com/jonschlinkert) |
| 2 | [isiahmeadows](https://github.com/isiahmeadows) |
| 1 | [doowb](https://github.com/doowb) |
| 1 | [devongovett](https://github.com/devongovett) |
| 1 | [mjbvz](https://github.com/mjbvz) |
| 1 | [shinnn](https://github.com/shinnn) |
```sh
$ npm install && npm test
```

### Author

**Jon Schlinkert**

* [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert)
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)

### License

Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Copyright © 2018, [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 December 21, 2017._

<hr class="footnotes-sep">
<section class="footnotes">
<ol class="footnotes-list">
<li id="fn1" class="footnote-item">`@` isn "'t a RegEx character." <a href="#fnref1" class="footnote-backref">↩</a>

</li>
</ol>
</section>
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on April 30, 2018._
6 changes: 2 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -2,12 +2,10 @@
environment:
matrix:
# node.js
- nodejs_version: "10.0"
- nodejs_version: "8.0"
- nodejs_version: "7.0"
- nodejs_version: "6.0"
- nodejs_version: "5.0"
- nodejs_version: "0.12"
- nodejs_version: "0.10"
- nodejs_version: "4.0"

# Install scripts. (runs after repo cloning)
install:
Loading