Commit 01303ad1 authored by Xavier Guimard's avatar Xavier Guimard

New upstream version 3.0.3+~2.0.7

parent 4b48c6f3
# 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
[{**/{actual,fixtures,expected,templates}/**,*.md}]
trim_trailing_whitespace = false
insert_final_newline = false
{
"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": 0,
"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"]
}
}
package-lock=false
This diff is collapsed.
# 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).
<details>
<summary><strong>Guiding Principles</strong></summary>
- 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.
</details>
<details>
<summary><strong>Types of changes</strong></summary>
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.
</details>
## [2.0.4] - 2019-04-10
### Fixed
- Readme link [fixed](https://github.com/micromatch/picomatch/pull/13/commits/a96ab3aa2b11b6861c23289964613d85563b05df) by @danez.
- `options.capture` now works as expected when fastpaths are enabled. See https://github.com/micromatch/picomatch/pull/12/commits/26aefd71f1cfaf95c37f1c1fcab68a693b037304. Thanks to @DrPizza.
## [2.0.0] - 2019-04-10
### Added
- Adds support for `options.onIgnore`. See the readme for details
- Adds support for `options.onResult`. See the readme for details
### Breaking changes
- The unixify option was renamed to `windows`
- caching and all related options and methods have been removed
## [1.0.0] - 2018-11-05
- adds `.onMatch` option
- improvements to `.scan` method
- numerous improvements and optimizations for matching and parsing
- better windows path handling
## 0.1.0 - 2017-04-13
First release.
[2.0.4]: https://github.com/jonschlinkert/micromatch/compare/2.0.0...2.0.4
[2.0.0]: https://github.com/jonschlinkert/micromatch/compare/1.0.0...2.0.0
[1.0.0]: https://github.com/jonschlinkert/micromatch/compare/0.1.0...1.0.0
[keep-a-changelog]: https://github.com/olivierlacan/keep-a-changelog
\ No newline at end of file
The MIT License (MIT)
Copyright (c) 2017-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.
This diff is collapsed.
package-lock=false
console.time('minimatch');
console.log(require('minimatch').makeRe('**/*').test('foo/bar/baz/qux.js'));
console.timeEnd('minimatch');
console.time('picomatch');
console.log(require('..').makeRe('**/*').test('foo/bar/baz/qux.js'));
console.timeEnd('picomatch');
'use strict';
const { Suite } = require('benchmark');
const { cyan, red, green } = require('ansi-colors');
const argv = require('minimist')(process.argv.slice(2));
const parent = require('glob-parent');
const scan = require('../lib/scan');
/**
* Setup
*/
const cycle = (e, newline) => {
process.stdout.write(`\u001b[G ${e.target}${newline ? `\n` : ''}`);
};
function 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 && name !== argv.run) {
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(red('foo/*.js'))
.add(' picomatch', () => scan('foo/*.js'))
.add('glob-parent', () => parent('foo/*.js'))
.run();
bench(red('foo/{a,b}/*.js'))
.add(' picomatch', () => scan('foo/{a,b}/*.js'))
.add('glob-parent', () => parent('foo/{a,b}/*.js'))
.run();
'use strict';
const { Suite } = require('benchmark');
const { cyan, red, green } = require('ansi-colors');
const argv = require('minimist')(process.argv.slice(2));
const mm = require('../node_modules/minimatch');
const pm = 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(red('.makeRe') + ' star')
.add('picomatch', () => pm.makeRe('*'))
.add('minimatch', () => mm.makeRe('*'))
.run();
bench(red('.makeRe') + ' star; dot=true')
.add('picomatch', () => pm.makeRe('*', { dot: true }))
.add('minimatch', () => mm.makeRe('*', { dot: true }))
.run();
bench(red('.makeRe') + ' globstar')
.add('picomatch', () => pm.makeRe('**'))
.add('minimatch', () => mm.makeRe('**'))
.run();
bench(red('.makeRe') + ' globstars')
.add('picomatch', () => pm.makeRe('**/**/**'))
.add('minimatch', () => mm.makeRe('**/**/**'))
.run();
bench(red('.makeRe') + ' with leading star')
.add('picomatch', () => pm.makeRe('*.txt'))
.add('minimatch', () => mm.makeRe('*.txt'))
.run();
bench(red('.makeRe') + ' - basic braces')
.add('picomatch', () => pm.makeRe('{a,b,c}*.txt'))
.add('minimatch', () => mm.makeRe('{a,b,c}*.txt'))
.run();
console.log('# Load time');
console.time('picomatch');
exports.pm = require('..');
console.timeEnd('picomatch');
console.time('minimatch');
exports.mm = require('minimatch');
console.timeEnd('minimatch');
console.log();
{
"name": "picomatch-benchmarks",
"version": "0.0.0",
"private": true,
"main": "index.js",
"dependencies": {
"ansi-colors": "^3.0.3",
"benchmark": "^2.1.4",
"minimist": "^1.2.0"
},
"devDependencies": {
"glob-parent": "^3.1.0",
"minimatch": "^3.0.4"
},
"lintDeps": {
"devDependencies": {
"files": {
"patterns": [
"*.js"
]
}
}
}
}
const pm = require('..');
console.log(pm.makeRe('(a|b|c)'));
console.log(pm.makeRe('!(a|b|c)'));
console.log(pm.makeRe('*(a|b|c)'));
console.log(pm.makeRe('+(a|b|c)'));
console.log(pm.makeRe('?(a|b|c)'));
console.log(pm.makeRe('@(a|b|c)'));
console.log('---');
console.log();
console.log(pm.makeRe('(a|b|c)', { noext: true }));
console.log(pm.makeRe('!(a|b|c)', { noext: true }));
console.log(pm.makeRe('*(a|b|c)', { noext: true }));
console.log(pm.makeRe('+(a|b|c)', { noext: true }));
console.log(pm.makeRe('?(a|b|c)', { noext: true }));
console.log(pm.makeRe('@(a|b|c)', { noext: true }));
console.log('---');
console.log();
'use strict';
const pm = require('..');
console.log(pm.makeRe('*'));
// /^(?:(?!\.)(?=.)[^\\\/]*?\/?)$/
console.log(pm.makeRe('*', { dot: true }));
// /^(?:(?!\.{1,2}(?:\/|$))(?=.)[^\\\/]*?\/?)$/
'use strict';
const path = require('path');
const assert = require('assert');
const pm = require('..');
/**
* Example function for matching an array of strings
*/
const match = (list, pattern, options = {}) => {
let normalize = false;
if (pattern.startsWith('./')) {
pattern = pattern.slice(2);
normalize = true;
}
let isMatch = pm(pattern, options);
let matches = new Set();
for (let ele of list) {
if (normalize === true || options.normalize === true) {
ele = path.posix.normalize(ele);
}
if (isMatch(ele)) {
matches.add(options.onMatch ? options.onMatch(ele) : ele);
}
}
return [...matches];
};
let fixtures = ['a.md', 'a/b.md', './a.md', './a/b.md', 'a/b/c.md', './a/b/c.md', '.\\a\\b\\c.md', 'a\\b\\c.md'];
console.log(path.posix.normalize('./{a,b,c}/*.md'));
console.log(match(fixtures, './**/*.md'));
// assert.deepEqual(match(fixtures, '**/*.md'), ['a.md', 'a/b.md', 'a/b/c.md', 'a\\b\\c.md']);
// assert.deepEqual(match(fixtures, '**/*.md', { normalize: true, unixify: false }), ['a.md', 'a/b.md', 'a/b/c.md', 'a\\b\\c.md']);
// assert.deepEqual(match(fixtures, '*.md'), ['a.md']);
// assert.deepEqual(match(fixtures, '*.md', { normalize: true, unixify: false }), ['a.md']);
// assert.deepEqual(match(fixtures, '*.md'), ['a.md']);
// assert.deepEqual(match(fixtures, '*/*.md', { normalize: true, unixify: false }), ['a/b.md']);
// assert.deepEqual(match(fixtures, '*/*.md'), ['a/b.md']);
// assert.deepEqual(match(fixtures, './**/*.md', { normalize: true, unixify: false }), ['a.md', 'a/b.md', 'a/b/c.md', 'a\\b\\c.md', './a.md', './a/b.md', '.\\a\\b\\c.md', 'a\\b\\c.md']);
// assert.deepEqual(match(fixtures, './**/*.md'), ['a.md', 'a/b.md', 'a/b/c.md']);
// assert.deepEqual(match(fixtures, './*.md', { normalize: true, unixify: false }), ['a.md', './a.md']);
// assert.deepEqual(match(fixtures, './*.md'), ['a.md']);
// assert.deepEqual(match(fixtures, './*/*.md', { normalize: true, unixify: false }), ['a/b.md', './a/b.md']);
// assert.deepEqual(match(fixtures, './*/*.md'), ['a/b.md']);
// assert.deepEqual(match(['./a'], 'a'), ['./a'], { normalize: true, unixify: false });
// assert.deepEqual(match(['./a'], 'a'), ['a']);
'use strict';
const fill = require('fill-range');
const pm = require('..');
const regex = pm.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
'use strict';
const pm = require('..');
const isMatch = pm.matcher('*', { ignore: 'f*' });
console.log(isMatch('foo')); //=> false
console.log(isMatch('bar')); //=> true
console.log(isMatch('baz')); //=> true
'use strict';
const pm = require('..');
const onIgnore = ({ glob, regex, input, output }) => {
console.log({ glob, regex, input, output });
// { glob: '*', regex: /^(?:(?!\.)(?=.)[^\/]*?\/?)$/, input: 'foo', output: 'foo' }
};
const isMatch = pm.matcher('*', { onIgnore, ignore: 'f*' });
isMatch('foo');
isMatch('bar');
isMatch('baz');
'use strict';
const pm = 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 = pm.matcher('**', { onMatch, posixSlashes: true });
isMatch('some\\path');
isMatch('some\\path');
isMatch('some\\path');
'use strict';
const pm = require('..');
const onResult = ({ glob, regex, input, output }) => {
console.log({ input, output });
};
const isMatch = pm.matcher('*', { onResult, ignore: 'f*' });
isMatch('foo');
isMatch('bar');
isMatch('baz');
'use strict';
const pm = require('..');
console.log(pm.scan('foo/bar/*/*/*.js'));
console.log(pm.scan('foo/(*|**a).js'));
console.log(pm.scan('foo/**/(*|a).js'));
console.log(pm.scan('foo/**/(**|a).js'));
console.log(pm.scan('foo/**/{**/*,}.js'));
console.log(pm.scan('foo/{**/*,}.js'));
console.log(pm.scan('/{**/*,}.js'));
console.log(pm.scan('/[*/].js'));
console.log(pm.scan('/(**/*|*).js'));
console.log(pm.scan('foo/**/*.js'));
console.log(pm.scan('foo/bar/*.js'));
console.log(pm.scan('foo/*.js'));
console.log(pm.scan('/foo'));
'use strict';
const pm = require('..');
console.log(pm.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
// { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
'use strict';
const path = require('path');
const pm = require('..');
const sep = path.sep;
console.log();
console.log('======= POSIX =======');
console.log();
console.log(pm.makeRe('*\\*'));
console.log(pm.makeRe('*\\*').test('foo/bar'));
console.log(pm.makeRe('*\\*').test('foo\\bar'));
console.log(pm.makeRe('*\\\\*'));
console.log(pm.makeRe('*\\\\*').test('foo/bar'));
console.log(pm.makeRe('*\\\\*').test('foo\\bar'));
console.log(pm.makeRe('*/*'));
console.log(pm.makeRe('*/*').test('foo/bar'));
console.log(pm.makeRe('*/*').test('foo\\bar'));
console.log();
console.log('======= WINDOWS =======');
console.log();
path.sep = '\\';
console.log(pm.makeRe('*\\*'));
console.log(pm.makeRe('*\\*').test('foo/bar'));
console.log(pm.makeRe('*\\*').test('foo\\bar'));
console.log(pm.makeRe('*\\\\*'));
console.log(pm.makeRe('*\\\\*').test('foo/bar'));
console.log(pm.makeRe('*\\\\*').test('foo\\bar'));
console.log(pm.makeRe('*/*'));
console.log(pm.makeRe('*/*').test('foo/bar'));
console.log(pm.makeRe('*/*').test('foo\\bar'));
path.sep = sep;
'use strict';
module.exports = require('./lib/picomatch');
'use strict';
const path = require('path');
const WIN_SLASH = '\\\\/';
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
/**
* Posix glob regex
*/
const DOT_LITERAL = '\\.';
const PLUS_LITERAL = '\\+';
const QMARK_LITERAL = '\\?';
const SLASH_LITERAL = '\\/';
const ONE_CHAR = '(?=.)';
const QMARK = '[^/]';
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
const NO_DOT = `(?!${DOT_LITERAL})`;
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
const STAR = `${QMARK}*?`;
const POSIX_CHARS = {
DOT_LITERAL,
PLUS_LITERAL,
QMARK_LITERAL,
SLASH_LITERAL,
ONE_CHAR,
QMARK,
END_ANCHOR,
DOTS_SLASH,
NO_DOT,
NO_DOTS,
NO_DOT_SLASH,
NO_DOTS_SLASH,
QMARK_NO_DOT,
STAR,
START_ANCHOR