From 02b2d38f351fc35bff7b32944ed0b772f99b5495 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Wed, 18 Mar 2026 19:46:45 +0100 Subject: [PATCH 1/6] chore: use prettier, update eslint, add node 24 and 25 to ci --- .eslintrc.json | 124 --- .github/workflows/test.yml | 2 +- .prettierrc.json | 5 + bench/glob-parent.js | 8 +- eslint.config.mjs | 47 ++ examples/match.js | 11 +- examples/option-onMatch.js | 2 +- examples/option-onResult.js | 2 +- lib/constants.js | 86 +- lib/parse.js | 207 +++-- lib/picomatch.js | 34 +- lib/scan.js | 55 +- lib/utils.js | 4 +- package.json | 9 +- test/api.picomatch.js | 19 +- test/api.scan.js | 282 +++++-- test/bash.js | 2 +- test/braces.js | 40 +- test/dotfiles.js | 138 +++- test/dots-invalid.js | 1523 +++++++++++++++++++++++++++-------- test/extglobs-bash.js | 454 +++++++++-- test/extglobs-minimatch.js | 126 ++- test/extglobs-temp.js | 440 +++++++--- test/extglobs.js | 111 ++- test/globstars.js | 150 +++- test/issue-related.js | 8 +- test/malicious.js | 25 +- test/minimatch.js | 8 +- test/negation.js | 16 +- test/options.expandRange.js | 20 +- test/options.format.js | 59 +- test/options.ignore.js | 110 ++- test/options.js | 489 +++++++++-- test/options.onMatch.js | 66 +- test/posix-classes.js | 102 ++- test/qmarks.js | 165 +++- test/slashes-posix.js | 61 +- test/slashes-windows.js | 6 +- test/special-characters.js | 15 +- test/wildmat.js | 39 +- 40 files changed, 3921 insertions(+), 1149 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 .prettierrc.json create mode 100644 eslint.config.mjs diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index ba84ad66..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,124 +0,0 @@ -{ - "extends": [ - "eslint:recommended" - ], - - "env": { - "es6": true, - "node": true - }, - - "parserOptions": { - "ecmaVersion": 2018 - }, - - "rules": { - "accessor-pairs": 2, - "arrow-parens": [2, "as-needed"], - "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-implicit-coercion": 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-lonely-if": 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": 2, - "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": 2, - "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": 2, - "no-undef": 2, - "no-undef-init": 2, - "no-unexpected-multiline": 2, - "no-unneeded-ternary": [2, { "defaultAssignment": false }], - "no-unreachable": 2, - "no-unused-expressions": 2, - "no-unused-vars": [2, { "vars": "all", "args": "none" }], - "no-useless-call": 2, - "no-with": 2, - "object-curly-spacing": ["error", "always", { "objectsInObjects": true }], - "one-var": [2, { "initialized": "never" }], - "operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }], - "padded-blocks": [0, "never"], - "prefer-const": [2, { "destructuring": "all", "ignoreReadBeforeAssign": false }], - "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, { "anonymous": "never", "named": "never", "asyncArrow": "always" }], - "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", "!", ","] }], - "strict": 2, - "use-isnan": 2, - "valid-typeof": 2, - "wrap-iife": [2, "any"], - "yoda": [2, "never"] - } -} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ffbdcb3d..d3b0ca48 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - node: [12, 14, 16, 18, 20, 22, 23] + node: [12, 14, 16, 18, 20, 22, 24, 25] os: [ubuntu-latest, windows-latest, macos-latest] exclude: - os: macos-latest diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 00000000..4b5afdb2 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "arrowParens": "avoid", + "trailingComma": "none" +} diff --git a/bench/glob-parent.js b/bench/glob-parent.js index 2790415a..279b444d 100644 --- a/bench/glob-parent.js +++ b/bench/glob-parent.js @@ -68,7 +68,9 @@ bench('*.js { parts: true, tokens: true }') .run(); bench('foo/bar/baz { parts: true, tokens: true }') - .add('picomatch.scan', () => scan('foo/bar/baz', { parts: true, tokens: true })) + .add('picomatch.scan', () => + scan('foo/bar/baz', { parts: true, tokens: true }) + ) .add(' glob-parent', () => parent('foo/bar/baz')) .run(); @@ -78,6 +80,8 @@ bench('foo/*.js { parts: true, tokens: true }') .run(); bench('foo/{a,b}/*.js { parts: true, tokens: true }') - .add('picomatch.scan', () => scan('foo/{a,b}/*.js', { parts: true, tokens: true })) + .add('picomatch.scan', () => + scan('foo/{a,b}/*.js', { parts: true, tokens: true }) + ) .add(' glob-parent', () => parent('foo/{a,b}/*.js')) .run(); diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..4ef3ac94 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,47 @@ +import { globalIgnores, defineConfig } from 'eslint/config'; +import globals from 'globals'; +import js from '@eslint/js'; +import prettierRecommended from 'eslint-plugin-prettier/recommended'; + +export default defineConfig([ + globalIgnores(['**/coverage', '**/node_modules']), + js.configs.recommended, + { + files: ['**/*.js', '**/*.cjs'], + languageOptions: { + globals: { + ...globals.node + }, + + ecmaVersion: 2018, + sourceType: 'script' + }, + + rules: { + 'prefer-const': 'error', + strict: ['error', 'global'] + } + }, + { + files: ['test/**/*.js', 'test/**/*.cjs'], + languageOptions: { + globals: { + ...globals.node, + ...globals.mocha + } + } + }, + { + files: ['**/*.mjs'], + + languageOptions: { + globals: { + ...globals.node + }, + + ecmaVersion: 2018, + sourceType: 'module' + } + }, + prettierRecommended +]); diff --git a/examples/match.js b/examples/match.js index aca9f949..d40411b4 100644 --- a/examples/match.js +++ b/examples/match.js @@ -28,7 +28,16 @@ const match = (list, pattern, options = {}) => { return [...matches]; }; -const 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']; +const 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')); diff --git a/examples/option-onMatch.js b/examples/option-onMatch.js index 3ceb2a85..a803fd33 100644 --- a/examples/option-onMatch.js +++ b/examples/option-onMatch.js @@ -2,7 +2,7 @@ const pm = require('..'); -const onMatch = ({ glob, regex, input, output }) => { +const onMatch = ({ input, output }) => { console.log({ input, output }); // { input: 'some\\path', output: 'some/path' } // { input: 'some\\path', output: 'some/path' } diff --git a/examples/option-onResult.js b/examples/option-onResult.js index 2c5aa453..659ce56d 100644 --- a/examples/option-onResult.js +++ b/examples/option-onResult.js @@ -2,7 +2,7 @@ const pm = require('..'); -const onResult = ({ glob, regex, input, output }) => { +const onResult = ({ input, output }) => { console.log({ input, output }); }; diff --git a/lib/constants.js b/lib/constants.js index 3f7ef7e5..c562cfed 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -106,55 +106,55 @@ module.exports = { }, // Digits - CHAR_0: 48, /* 0 */ - CHAR_9: 57, /* 9 */ + CHAR_0: 48 /* 0 */, + CHAR_9: 57 /* 9 */, // Alphabet chars. - CHAR_UPPERCASE_A: 65, /* A */ - CHAR_LOWERCASE_A: 97, /* a */ - CHAR_UPPERCASE_Z: 90, /* Z */ - CHAR_LOWERCASE_Z: 122, /* z */ + CHAR_UPPERCASE_A: 65 /* A */, + CHAR_LOWERCASE_A: 97 /* a */, + CHAR_UPPERCASE_Z: 90 /* Z */, + CHAR_LOWERCASE_Z: 122 /* z */, - CHAR_LEFT_PARENTHESES: 40, /* ( */ - CHAR_RIGHT_PARENTHESES: 41, /* ) */ + CHAR_LEFT_PARENTHESES: 40 /* ( */, + CHAR_RIGHT_PARENTHESES: 41 /* ) */, - CHAR_ASTERISK: 42, /* * */ + CHAR_ASTERISK: 42 /* * */, // Non-alphabetic chars. - CHAR_AMPERSAND: 38, /* & */ - CHAR_AT: 64, /* @ */ - CHAR_BACKWARD_SLASH: 92, /* \ */ - CHAR_CARRIAGE_RETURN: 13, /* \r */ - CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */ - CHAR_COLON: 58, /* : */ - CHAR_COMMA: 44, /* , */ - CHAR_DOT: 46, /* . */ - CHAR_DOUBLE_QUOTE: 34, /* " */ - CHAR_EQUAL: 61, /* = */ - CHAR_EXCLAMATION_MARK: 33, /* ! */ - CHAR_FORM_FEED: 12, /* \f */ - CHAR_FORWARD_SLASH: 47, /* / */ - CHAR_GRAVE_ACCENT: 96, /* ` */ - CHAR_HASH: 35, /* # */ - CHAR_HYPHEN_MINUS: 45, /* - */ - CHAR_LEFT_ANGLE_BRACKET: 60, /* < */ - CHAR_LEFT_CURLY_BRACE: 123, /* { */ - CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */ - CHAR_LINE_FEED: 10, /* \n */ - CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */ - CHAR_PERCENT: 37, /* % */ - CHAR_PLUS: 43, /* + */ - CHAR_QUESTION_MARK: 63, /* ? */ - CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */ - CHAR_RIGHT_CURLY_BRACE: 125, /* } */ - CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */ - CHAR_SEMICOLON: 59, /* ; */ - CHAR_SINGLE_QUOTE: 39, /* ' */ - CHAR_SPACE: 32, /* */ - CHAR_TAB: 9, /* \t */ - CHAR_UNDERSCORE: 95, /* _ */ - CHAR_VERTICAL_LINE: 124, /* | */ - CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */ + CHAR_AMPERSAND: 38 /* & */, + CHAR_AT: 64 /* @ */, + CHAR_BACKWARD_SLASH: 92 /* \ */, + CHAR_CARRIAGE_RETURN: 13 /* \r */, + CHAR_CIRCUMFLEX_ACCENT: 94 /* ^ */, + CHAR_COLON: 58 /* : */, + CHAR_COMMA: 44 /* , */, + CHAR_DOT: 46 /* . */, + CHAR_DOUBLE_QUOTE: 34 /* " */, + CHAR_EQUAL: 61 /* = */, + CHAR_EXCLAMATION_MARK: 33 /* ! */, + CHAR_FORM_FEED: 12 /* \f */, + CHAR_FORWARD_SLASH: 47 /* / */, + CHAR_GRAVE_ACCENT: 96 /* ` */, + CHAR_HASH: 35 /* # */, + CHAR_HYPHEN_MINUS: 45 /* - */, + CHAR_LEFT_ANGLE_BRACKET: 60 /* < */, + CHAR_LEFT_CURLY_BRACE: 123 /* { */, + CHAR_LEFT_SQUARE_BRACKET: 91 /* [ */, + CHAR_LINE_FEED: 10 /* \n */, + CHAR_NO_BREAK_SPACE: 160 /* \u00A0 */, + CHAR_PERCENT: 37 /* % */, + CHAR_PLUS: 43 /* + */, + CHAR_QUESTION_MARK: 63 /* ? */, + CHAR_RIGHT_ANGLE_BRACKET: 62 /* > */, + CHAR_RIGHT_CURLY_BRACE: 125 /* } */, + CHAR_RIGHT_SQUARE_BRACKET: 93 /* ] */, + CHAR_SEMICOLON: 59 /* ; */, + CHAR_SINGLE_QUOTE: 39 /* ' */, + CHAR_SPACE: 32 /* */, + CHAR_TAB: 9 /* \t */, + CHAR_UNDERSCORE: 95 /* _ */, + CHAR_VERTICAL_LINE: 124 /* | */, + CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279 /* \uFEFF */, /** * Create EXTGLOB_CHARS diff --git a/lib/parse.js b/lib/parse.js index 8fd8ff49..177dc283 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -28,8 +28,8 @@ const expandRange = (args, options) => { const value = `[${args.join('-')}]`; try { - /* eslint-disable-next-line no-new */ new RegExp(value); + // eslint-disable-next-line no-unused-vars } catch (ex) { return args.map(v => utils.escapeRegex(v)).join('..'); } @@ -60,11 +60,16 @@ const parse = (input, options) => { input = REPLACEMENTS[input] || input; const opts = { ...options }; - const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH; + const max = + typeof opts.maxLength === 'number' + ? Math.min(MAX_LENGTH, opts.maxLength) + : MAX_LENGTH; let len = input.length; if (len > max) { - throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); + throw new SyntaxError( + `Input length: ${len}, exceeds maximum allowed length: ${max}` + ); } const bos = { type: 'bos', value: '', output: opts.prepend || '' }; @@ -140,8 +145,8 @@ const parse = (input, options) => { */ const eos = () => state.index === len - 1; - const peek = state.peek = (n = 1) => input[state.index + n]; - const advance = state.advance = () => input[++state.index] || ''; + const peek = (state.peek = (n = 1) => input[state.index + n]); + const advance = (state.advance = () => input[++state.index] || ''); const remaining = () => input.slice(state.index + 1); const consume = (value = '', num = 0) => { state.consumed += value; @@ -191,10 +196,18 @@ const parse = (input, options) => { const push = tok => { if (prev.type === 'globstar') { - const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace'); - const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren')); - - if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) { + const isBrace = + state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace'); + const isExtglob = + tok.extglob === true || + (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren')); + + if ( + tok.type !== 'slash' && + tok.type !== 'paren' && + !isBrace && + !isExtglob + ) { state.output = state.output.slice(0, -prev.output.length); prev.type = 'star'; prev.value = '*'; @@ -248,7 +261,11 @@ const parse = (input, options) => { output = token.close = `)$))${extglobStar}`; } - if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) { + if ( + token.inner.includes('*') && + (rest = remaining()) && + /^\.[^\\/.]+$/.test(rest) + ) { // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis. // In this case, we need to parse the string and use it in the output of the original pattern. // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`. @@ -275,41 +292,44 @@ const parse = (input, options) => { if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) { let backslashes = false; - let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => { - if (first === '\\') { - backslashes = true; - return m; - } - - if (first === '?') { - if (esc) { - return esc + first + (rest ? QMARK.repeat(rest.length) : ''); + let output = input.replace( + REGEX_SPECIAL_CHARS_BACKREF, + (m, esc, chars, first, rest, index) => { + if (first === '\\') { + backslashes = true; + return m; } - if (index === 0) { - return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : ''); + + if (first === '?') { + if (esc) { + return esc + first + (rest ? QMARK.repeat(rest.length) : ''); + } + if (index === 0) { + return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : ''); + } + return QMARK.repeat(chars.length); } - return QMARK.repeat(chars.length); - } - if (first === '.') { - return DOT_LITERAL.repeat(chars.length); - } + if (first === '.') { + return DOT_LITERAL.repeat(chars.length); + } - if (first === '*') { - if (esc) { - return esc + first + (rest ? star : ''); + if (first === '*') { + if (esc) { + return esc + first + (rest ? star : ''); + } + return star; } - return star; + return esc ? m : `\\${m}`; } - return esc ? m : `\\${m}`; - }); + ); if (backslashes === true) { if (opts.unescape === true) { output = output.replace(/\\/g, ''); } else { output = output.replace(/\\+/g, m => { - return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : ''); + return m.length % 2 === 0 ? '\\\\' : m ? '\\' : ''; }); } } @@ -357,10 +377,9 @@ const parse = (input, options) => { // collapse slashes to reduce potential for exploits const match = /^\\+/.exec(remaining()); - let slashes = 0; if (match && match[0].length > 2) { - slashes = match[0].length; + const slashes = match[0].length; state.index += slashes; if (slashes % 2 !== 0) { value += '\\'; @@ -384,7 +403,10 @@ const parse = (input, options) => { * until we reach the closing bracket. */ - if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) { + if ( + state.brackets > 0 && + (value !== ']' || prev.value === '[' || prev.value === '[^') + ) { if (opts.posix !== false && value === ':') { const inner = prev.value.slice(1); if (inner.includes('[')) { @@ -409,7 +431,10 @@ const parse = (input, options) => { } } - if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) { + if ( + (value === '[' && peek() !== ':') || + (value === '-' && peek() === ']') + ) { value = `\\${value}`; } @@ -496,7 +521,10 @@ const parse = (input, options) => { } if (value === ']') { - if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) { + if ( + opts.nobracket === true || + (prev && prev.type === 'bracket' && prev.value.length === 1) + ) { push({ type: 'text', value, output: `\\${value}` }); continue; } @@ -513,7 +541,11 @@ const parse = (input, options) => { decrement('brackets'); const prevValue = prev.value.slice(1); - if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) { + if ( + prev.posix !== true && + prevValue[0] === '^' && + !prevValue.includes('/') + ) { value = `/${value}`; } @@ -598,7 +630,7 @@ const parse = (input, options) => { value = output = '\\}'; state.output = out; for (const t of toks) { - state.output += (t.output || t.value); + state.output += t.output || t.value; } } @@ -674,7 +706,11 @@ const parse = (input, options) => { continue; } - if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') { + if ( + state.braces + state.parens === 0 && + prev.type !== 'bos' && + prev.type !== 'slash' + ) { push({ type: 'text', value, output: DOT_LITERAL }); continue; } @@ -689,7 +725,12 @@ const parse = (input, options) => { if (value === '?') { const isGroup = prev && prev.value === '('; - if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { + if ( + !isGroup && + opts.noextglob !== true && + peek() === '(' && + peek(2) !== '?' + ) { extglobOpen('qmark', value); continue; } @@ -698,7 +739,10 @@ const parse = (input, options) => { const next = peek(); let output = value; - if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) { + if ( + (prev.value === '(' && !/[!=<:]/.test(next)) || + (next === '<' && !/<([!=]|\w+>)/.test(remaining())) + ) { output = `\\${value}`; } @@ -748,7 +792,13 @@ const parse = (input, options) => { continue; } - if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) { + if ( + (prev && + (prev.type === 'bracket' || + prev.type === 'paren' || + prev.type === 'brace')) || + state.parens > 0 + ) { push({ type: 'plus', value }); continue; } @@ -820,15 +870,18 @@ const parse = (input, options) => { const prior = prev.prev; const before = prior.prev; const isStart = prior.type === 'slash' || prior.type === 'bos'; - const afterStar = before && (before.type === 'star' || before.type === 'globstar'); + const afterStar = + before && (before.type === 'star' || before.type === 'globstar'); if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) { push({ type: 'star', value, output: '' }); continue; } - const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace'); - const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren'); + const isBrace = + state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace'); + const isExtglob = + extglobs.length && (prior.type === 'pipe' || prior.type === 'paren'); if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) { push({ type: 'star', value, output: '' }); continue; @@ -854,8 +907,16 @@ const parse = (input, options) => { continue; } - if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { - state.output = state.output.slice(0, -(prior.output + prev.output).length); + if ( + prior.type === 'slash' && + prior.prev.type !== 'bos' && + !afterStar && + eos() + ) { + state.output = state.output.slice( + 0, + -(prior.output + prev.output).length + ); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; @@ -867,10 +928,17 @@ const parse = (input, options) => { continue; } - if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') { + if ( + prior.type === 'slash' && + prior.prev.type !== 'bos' && + rest[0] === '/' + ) { const end = rest[1] !== void 0 ? '|$' : ''; - state.output = state.output.slice(0, -(prior.output + prev.output).length); + state.output = state.output.slice( + 0, + -(prior.output + prev.output).length + ); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; @@ -923,21 +991,27 @@ const parse = (input, options) => { continue; } - if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { + if ( + prev && + (prev.type === 'bracket' || prev.type === 'paren') && + opts.regex === true + ) { token.output = value; push(token); continue; } - if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { + if ( + state.index === state.start || + prev.type === 'slash' || + prev.type === 'dot' + ) { if (prev.type === 'dot') { state.output += NO_DOT_SLASH; prev.output += NO_DOT_SLASH; - } else if (opts.dot === true) { state.output += NO_DOTS_SLASH; prev.output += NO_DOTS_SLASH; - } else { state.output += nodot; prev.output += nodot; @@ -953,24 +1027,30 @@ const parse = (input, options) => { } while (state.brackets > 0) { - if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); + if (opts.strictBrackets === true) + throw new SyntaxError(syntaxError('closing', ']')); state.output = utils.escapeLast(state.output, '['); decrement('brackets'); } while (state.parens > 0) { - if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); + if (opts.strictBrackets === true) + throw new SyntaxError(syntaxError('closing', ')')); state.output = utils.escapeLast(state.output, '('); decrement('parens'); } while (state.braces > 0) { - if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); + if (opts.strictBrackets === true) + throw new SyntaxError(syntaxError('closing', '}')); state.output = utils.escapeLast(state.output, '{'); decrement('braces'); } - if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { + if ( + opts.strictSlashes !== true && + (prev.type === 'star' || prev.type === 'bracket') + ) { push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); } @@ -998,10 +1078,15 @@ const parse = (input, options) => { parse.fastpaths = (input, options) => { const opts = { ...options }; - const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH; + const max = + typeof opts.maxLength === 'number' + ? Math.min(MAX_LENGTH, opts.maxLength) + : MAX_LENGTH; const len = input.length; if (len > max) { - throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); + throw new SyntaxError( + `Input length: ${len}, exceeds maximum allowed length: ${max}` + ); } input = REPLACEMENTS[input] || input; diff --git a/lib/picomatch.js b/lib/picomatch.js index d0ebd9f1..5c077578 100644 --- a/lib/picomatch.js +++ b/lib/picomatch.js @@ -58,12 +58,20 @@ const picomatch = (glob, options, returnState = false) => { let isIgnored = () => false; if (opts.ignore) { - const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null }; + const ignoreOpts = { + ...options, + ignore: null, + onMatch: null, + onResult: null + }; isIgnored = picomatch(opts.ignore, ignoreOpts, returnState); } const matcher = (input, returnObject = false) => { - const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix }); + const { isMatch, match, output } = picomatch.test(input, regex, options, { + glob, + posix + }); const result = { glob, state, regex, posix, input, output, match, isMatch }; if (typeof opts.onResult === 'function') { @@ -125,7 +133,7 @@ picomatch.test = (input, regex, options, { glob, posix } = {}) => { const opts = options || {}; const format = opts.format || (posix ? utils.toPosixSlashes : null); let match = input === glob; - let output = (match && format) ? format(input) : input; + let output = match && format ? format(input) : input; if (match === false) { output = format ? format(input) : input; @@ -179,7 +187,8 @@ picomatch.matchBase = (input, glob, options) => { * @api public */ -picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str); +picomatch.isMatch = (str, patterns, options) => + picomatch(patterns, options)(str); /** * Parse a glob pattern to create the source string for a regular @@ -196,7 +205,8 @@ picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str */ picomatch.parse = (pattern, options) => { - if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options)); + if (Array.isArray(pattern)) + return pattern.map(p => picomatch.parse(p, options)); return parse(pattern, { ...options, fastpaths: false }); }; @@ -241,7 +251,12 @@ picomatch.scan = (input, options) => scan(input, options); * @api public */ -picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => { +picomatch.compileRe = ( + state, + options, + returnOutput = false, + returnState = false +) => { if (returnOutput === true) { return state.output; } @@ -282,7 +297,12 @@ picomatch.compileRe = (state, options, returnOutput = false, returnState = false * @api public */ -picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => { +picomatch.makeRe = ( + input, + options = {}, + returnOutput = false, + returnState = false +) => { if (!input || typeof input !== 'string') { throw new TypeError('Expected a non-empty string'); } diff --git a/lib/scan.js b/lib/scan.js index e59cd7a1..23c63c0f 100644 --- a/lib/scan.js +++ b/lib/scan.js @@ -2,21 +2,21 @@ const utils = require('./utils'); const { - CHAR_ASTERISK, /* * */ - CHAR_AT, /* @ */ - CHAR_BACKWARD_SLASH, /* \ */ - CHAR_COMMA, /* , */ - CHAR_DOT, /* . */ - CHAR_EXCLAMATION_MARK, /* ! */ - CHAR_FORWARD_SLASH, /* / */ - CHAR_LEFT_CURLY_BRACE, /* { */ - CHAR_LEFT_PARENTHESES, /* ( */ - CHAR_LEFT_SQUARE_BRACKET, /* [ */ - CHAR_PLUS, /* + */ - CHAR_QUESTION_MARK, /* ? */ - CHAR_RIGHT_CURLY_BRACE, /* } */ - CHAR_RIGHT_PARENTHESES, /* ) */ - CHAR_RIGHT_SQUARE_BRACKET /* ] */ + CHAR_ASTERISK /* * */, + CHAR_AT /* @ */, + CHAR_BACKWARD_SLASH /* \ */, + CHAR_COMMA /* , */, + CHAR_DOT /* . */, + CHAR_EXCLAMATION_MARK /* ! */, + CHAR_FORWARD_SLASH /* / */, + CHAR_LEFT_CURLY_BRACE /* { */, + CHAR_LEFT_PARENTHESES /* ( */, + CHAR_LEFT_SQUARE_BRACKET /* [ */, + CHAR_PLUS /* + */, + CHAR_QUESTION_MARK /* ? */, + CHAR_RIGHT_CURLY_BRACE /* } */, + CHAR_RIGHT_PARENTHESES /* ) */, + CHAR_RIGHT_SQUARE_BRACKET /* ] */ } = require('./constants'); const isPathSeparator = code => { @@ -110,7 +110,11 @@ const scan = (input, options) => { continue; } - if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) { + if ( + braceEscaped !== true && + code === CHAR_DOT && + (code = advance()) === CHAR_DOT + ) { isBrace = token.isBrace = true; isGlob = token.isGlob = true; finished = true; @@ -159,7 +163,7 @@ const scan = (input, options) => { token = { value: '', depth: 0, isGlob: false }; if (finished === true) continue; - if (prev === CHAR_DOT && index === (start + 1)) { + if (prev === CHAR_DOT && index === start + 1) { start += 2; continue; } @@ -169,11 +173,12 @@ const scan = (input, options) => { } if (opts.noext !== true) { - const isExtglobChar = code === CHAR_PLUS - || code === CHAR_AT - || code === CHAR_ASTERISK - || code === CHAR_QUESTION_MARK - || code === CHAR_EXCLAMATION_MARK; + const isExtglobChar = + code === CHAR_PLUS || + code === CHAR_AT || + code === CHAR_ASTERISK || + code === CHAR_QUESTION_MARK || + code === CHAR_EXCLAMATION_MARK; if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) { isGlob = token.isGlob = true; @@ -247,7 +252,11 @@ const scan = (input, options) => { break; } - if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) { + if ( + opts.nonegate !== true && + code === CHAR_EXCLAMATION_MARK && + index === start + ) { negated = token.negated = true; start++; continue; diff --git a/lib/utils.js b/lib/utils.js index 9c97cae2..606760ba 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,4 +1,3 @@ -/*global navigator*/ 'use strict'; const { @@ -8,7 +7,8 @@ const { REGEX_SPECIAL_CHARS_GLOBAL } = require('./constants'); -exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val); +exports.isObject = val => + val !== null && typeof val === 'object' && !Array.isArray(val); exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str); exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str); exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1'); diff --git a/package.json b/package.json index 372e27e0..2c109de4 100644 --- a/package.json +++ b/package.json @@ -21,18 +21,23 @@ "node": ">=12" }, "scripts": { - "lint": "eslint --cache --cache-location node_modules/.cache/.eslintcache --report-unused-disable-directives --ignore-path .gitignore .", + "lint": "eslint --cache --cache-location node_modules/.cache/.eslintcache --report-unused-disable-directives .", "mocha": "mocha --reporter dot", "test": "npm run lint && npm run mocha", "test:ci": "npm run test:cover", "test:cover": "nyc npm run mocha" }, "devDependencies": { - "eslint": "^8.57.0", + "@eslint/js": "^10.0.1", + "eslint": "^10.0.3", + "eslint-config-prettier": "^10.1.8", + "eslint-plugin-prettier": "^5.5.5", "fill-range": "^7.0.1", + "globals": "^17.4.0", "gulp-format-md": "^2.0.0", "mocha": "^10.4.0", "nyc": "^15.1.0", + "prettier": "^3.8.1", "time-require": "github:jonschlinkert/time-require" }, "keywords": [ diff --git a/test/api.picomatch.js b/test/api.picomatch.js index 2fe67cff..fc8815f4 100644 --- a/test/api.picomatch.js +++ b/test/api.picomatch.js @@ -12,8 +12,14 @@ const assertTokens = (actual, expected) => { describe('picomatch', () => { describe('validation', () => { it('should throw an error when invalid arguments are given', () => { - assert.throws(() => isMatch('foo', ''), /Expected pattern to be a non-empty string/); - assert.throws(() => isMatch('foo', null), /Expected pattern to be a non-empty string/); + assert.throws( + () => isMatch('foo', ''), + /Expected pattern to be a non-empty string/ + ); + assert.throws( + () => isMatch('foo', null), + /Expected pattern to be a non-empty string/ + ); }); }); @@ -246,7 +252,9 @@ describe('picomatch', () => { assert(!isMatch('foo/baz/bar', 'foo**bar')); assert(!isMatch('foo/baz/bar', 'foo*bar')); assert(!isMatch('deep/foo/bar/baz', '**/bar/*/')); - assert(!isMatch('deep/foo/bar/baz/', '**/bar/*', { strictSlashes: true })); + assert( + !isMatch('deep/foo/bar/baz/', '**/bar/*', { strictSlashes: true }) + ); assert(isMatch('deep/foo/bar/baz/', '**/bar/*')); assert(isMatch('deep/foo/bar/baz', '**/bar/*')); assert(isMatch('foo', 'foo/**')); @@ -358,7 +366,10 @@ describe('picomatch', () => { ['text', { output: undefined, value: 'js' }] ]; - const keyValuePairs = tokens.map(token => [token.type, { output: token.output, value: token.value }]); + const keyValuePairs = tokens.map(token => [ + token.type, + { output: token.output, value: token.value } + ]); assert.deepStrictEqual(keyValuePairs, expected); }); }); diff --git a/test/api.scan.js b/test/api.scan.js index b1e63db1..7f974045 100644 --- a/test/api.scan.js +++ b/test/api.scan.js @@ -253,8 +253,16 @@ describe('picomatch', () => { assert.strictEqual(base('path/**/subdir/foo.*'), 'path'); assert.strictEqual(base('path/*/foo'), 'path'); assert.strictEqual(base('path/*/foo/'), 'path'); - assert.strictEqual(base('path/+/foo'), 'path/+/foo', 'plus sign must be escaped'); - assert.strictEqual(base('path/+/foo/'), 'path/+/foo/', 'plus sign must be escaped'); + assert.strictEqual( + base('path/+/foo'), + 'path/+/foo', + 'plus sign must be escaped' + ); + assert.strictEqual( + base('path/+/foo/'), + 'path/+/foo/', + 'plus sign must be escaped' + ); assert.strictEqual(base('path/?/foo'), 'path', 'qmarks must be escaped'); assert.strictEqual(base('path/?/foo/'), 'path', 'qmarks must be escaped'); assert.strictEqual(base('path/@/foo'), 'path/@/foo'); @@ -265,9 +273,18 @@ describe('picomatch', () => { }); it('should respect escaped characters', () => { - assert.strictEqual(base('path/\\*\\*/subdir/foo.*'), 'path/\\*\\*/subdir'); - assert.strictEqual(base('path/\\[\\*\\]/subdir/foo.*'), 'path/\\[\\*\\]/subdir'); - assert.strictEqual(base('path/\\[foo bar\\]/subdir/foo.*'), 'path/\\[foo bar\\]/subdir'); + assert.strictEqual( + base('path/\\*\\*/subdir/foo.*'), + 'path/\\*\\*/subdir' + ); + assert.strictEqual( + base('path/\\[\\*\\]/subdir/foo.*'), + 'path/\\[\\*\\]/subdir' + ); + assert.strictEqual( + base('path/\\[foo bar\\]/subdir/foo.*'), + 'path/\\[foo bar\\]/subdir' + ); assert.strictEqual(base('path/\\[bar]/'), 'path/\\[bar]/'); assert.strictEqual(base('path/\\[bar]'), 'path/\\[bar]'); assert.strictEqual(base('[bar]'), ''); @@ -368,7 +385,17 @@ describe('picomatch', () => { assertParts('a/**@(/x|/z)/*.md', ['a', '**@(/x|/z)', '*.md']); assertParts('foo/(bar|baz)/*.js', ['foo', '(bar|baz)', '*.js']); - assertParts('XXX/*/*/12/*/*/m/*/*', ['XXX', '*', '*', '12', '*', '*', 'm', '*', '*']); + assertParts('XXX/*/*/12/*/*/m/*/*', [ + 'XXX', + '*', + '*', + '12', + '*', + '*', + 'm', + '*', + '*' + ]); assertParts('foo/\\"**\\"/bar', ['foo', '\\"**\\"', 'bar']); assertParts('[0-9]/[0-9]', ['[0-9]', '[0-9]']); @@ -409,21 +436,45 @@ describe('picomatch', () => { assert.strictEqual(base('a/(b c)', { noparen: true }), 'a/(b c)'); assert.strictEqual(base('a/(b c)/', { noparen: true }), 'a/(b c)/'); assert.strictEqual(base('a/(b c)/d', { noparen: true }), 'a/(b c)/d'); - assert.strictEqual(base('foo/(b c)/baz', { noparen: true }), 'foo/(b c)/baz'); - assert.strictEqual(base('path/(foo bar)/subdir/foo.*', { noparen: true }), 'path/(foo bar)/subdir'); - assert.strictEqual(base('a/\\(b c)'), 'a/\\(b c)', 'parens must be escaped'); - assert.strictEqual(base('a/\\+\\(b c)/foo'), 'a/\\+\\(b c)/foo', 'parens must be escaped'); + assert.strictEqual( + base('foo/(b c)/baz', { noparen: true }), + 'foo/(b c)/baz' + ); + assert.strictEqual( + base('path/(foo bar)/subdir/foo.*', { noparen: true }), + 'path/(foo bar)/subdir' + ); + assert.strictEqual( + base('a/\\(b c)'), + 'a/\\(b c)', + 'parens must be escaped' + ); + assert.strictEqual( + base('a/\\+\\(b c)/foo'), + 'a/\\+\\(b c)/foo', + 'parens must be escaped' + ); assert.strictEqual(base('js/t(wo|est)/*.js'), 'js'); assert.strictEqual(base('js/t/(wo|est)/*.js'), 'js/t'); - assert.strictEqual(base('path/(foo bar)/subdir/foo.*'), 'path', 'parens must be escaped'); + assert.strictEqual( + base('path/(foo bar)/subdir/foo.*'), + 'path', + 'parens must be escaped' + ); assert.strictEqual(base('path/(foo/bar|baz)'), 'path'); assert.strictEqual(base('path/(foo/bar|baz)/'), 'path'); assert.strictEqual(base('path/(to|from)'), 'path'); - assert.strictEqual(base('path/\\(foo/bar|baz)/'), 'path/\\(foo/bar|baz)/'); + assert.strictEqual( + base('path/\\(foo/bar|baz)/'), + 'path/\\(foo/bar|baz)/' + ); assert.strictEqual(base('path/\\*(a|b)'), 'path'); assert.strictEqual(base('path/\\*(a|b)/subdir/foo.*'), 'path'); assert.strictEqual(base('path/\\*/(a|b)/subdir/foo.*'), 'path/\\*'); - assert.strictEqual(base('path/\\*\\(a\\|b\\)/subdir/foo.*'), 'path/\\*\\(a\\|b\\)/subdir'); + assert.strictEqual( + base('path/\\*\\(a\\|b\\)/subdir/foo.*'), + 'path/\\*\\(a\\|b\\)/subdir' + ); }); }); @@ -458,13 +509,22 @@ describe('picomatch', () => { assert.deepStrictEqual(both('*'), ['', '*']); assert.deepStrictEqual(both('a/**/j/**/z/*.md'), ['a', '**/j/**/z/*.md']); assert.deepStrictEqual(both('a/**/z/*.md'), ['a', '**/z/*.md']); - assert.deepStrictEqual(both('node_modules/*-glob/**/*.js'), ['node_modules', '*-glob/**/*.js']); - assert.deepStrictEqual(both('{a/b/{c,/foo.js}/e.f.g}'), ['', '{a/b/{c,/foo.js}/e.f.g}']); + assert.deepStrictEqual(both('node_modules/*-glob/**/*.js'), [ + 'node_modules', + '*-glob/**/*.js' + ]); + assert.deepStrictEqual(both('{a/b/{c,/foo.js}/e.f.g}'), [ + '', + '{a/b/{c,/foo.js}/e.f.g}' + ]); assert.deepStrictEqual(both('.a*'), ['', '.a*']); assert.deepStrictEqual(both('.b*'), ['', '.b*']); assert.deepStrictEqual(both('/*'), ['/', '*']); assert.deepStrictEqual(both('a/***'), ['a', '***']); - assert.deepStrictEqual(both('a/**/b/*.{foo,bar}'), ['a', '**/b/*.{foo,bar}']); + assert.deepStrictEqual(both('a/**/b/*.{foo,bar}'), [ + 'a', + '**/b/*.{foo,bar}' + ]); assert.deepStrictEqual(both('a/**/c/*'), ['a', '**/c/*']); assert.deepStrictEqual(both('a/**/c/*.md'), ['a', '**/c/*.md']); assert.deepStrictEqual(both('a/**/e'), ['a', '**/e']); @@ -474,7 +534,10 @@ describe('picomatch', () => { assert.deepStrictEqual(both('a/**c/*'), ['a', '**c/*']); assert.deepStrictEqual(both('a/*/*/e'), ['a', '*/*/e']); assert.deepStrictEqual(both('a/*/c/*.md'), ['a', '*/c/*.md']); - assert.deepStrictEqual(both('a/b/**/c{d,e}/**/xyz.md'), ['a/b', '**/c{d,e}/**/xyz.md']); + assert.deepStrictEqual(both('a/b/**/c{d,e}/**/xyz.md'), [ + 'a/b', + '**/c{d,e}/**/xyz.md' + ]); assert.deepStrictEqual(both('a/b/**/e'), ['a/b', '**/e']); assert.deepStrictEqual(both('a/b/*.{foo,bar}'), ['a/b', '*.{foo,bar}']); assert.deepStrictEqual(both('a/b/*/e'), ['a/b', '*/e']); @@ -482,11 +545,20 @@ describe('picomatch', () => { assert.deepStrictEqual(both('a/b/.git/**'), ['a/b/.git', '**']); assert.deepStrictEqual(both('a/b/.{foo,bar}'), ['a/b', '.{foo,bar}']); assert.deepStrictEqual(both('a/b/c/*'), ['a/b/c', '*']); - assert.deepStrictEqual(both('a/b/c/**/*.min.js'), ['a/b/c', '**/*.min.js']); + assert.deepStrictEqual(both('a/b/c/**/*.min.js'), [ + 'a/b/c', + '**/*.min.js' + ]); assert.deepStrictEqual(both('a/b/c/*.md'), ['a/b/c', '*.md']); assert.deepStrictEqual(both('a/b/c/.*.md'), ['a/b/c', '.*.md']); - assert.deepStrictEqual(both('a/b/{c,.gitignore,{a,b}}/{a,b}/abc.foo.js'), ['a/b', '{c,.gitignore,{a,b}}/{a,b}/abc.foo.js']); - assert.deepStrictEqual(both('a/b/{c,/.gitignore}'), ['a/b', '{c,/.gitignore}']); + assert.deepStrictEqual( + both('a/b/{c,.gitignore,{a,b}}/{a,b}/abc.foo.js'), + ['a/b', '{c,.gitignore,{a,b}}/{a,b}/abc.foo.js'] + ); + assert.deepStrictEqual(both('a/b/{c,/.gitignore}'), [ + 'a/b', + '{c,/.gitignore}' + ]); assert.deepStrictEqual(both('a/b/{c,d}/'), ['a/b', '{c,d}/']); assert.deepStrictEqual(both('a/b/{c,d}/e/f.g'), ['a/b', '{c,d}/e/f.g']); assert.deepStrictEqual(both('b/*/*/*'), ['b', '*/*/*']); @@ -500,15 +572,30 @@ describe('picomatch', () => { assert.deepStrictEqual(both('!*.min.js'), ['', '*.min.js']); assert.deepStrictEqual(both('!foo'), ['foo', '']); assert.deepStrictEqual(both('!foo/*.js'), ['foo', '*.js']); - assert.deepStrictEqual(both('!foo/(a|b).min.js'), ['foo', '(a|b).min.js']); - assert.deepStrictEqual(both('!foo/[a-b].min.js'), ['foo', '[a-b].min.js']); - assert.deepStrictEqual(both('!foo/{a,b}.min.js'), ['foo', '{a,b}.min.js']); + assert.deepStrictEqual(both('!foo/(a|b).min.js'), [ + 'foo', + '(a|b).min.js' + ]); + assert.deepStrictEqual(both('!foo/[a-b].min.js'), [ + 'foo', + '[a-b].min.js' + ]); + assert.deepStrictEqual(both('!foo/{a,b}.min.js'), [ + 'foo', + '{a,b}.min.js' + ]); assert.deepStrictEqual(both('a/b/c/!foo'), ['a/b/c/!foo', '']); }); it('should support extglobs', () => { - assert.deepStrictEqual(both('/a/b/!(a|b)/e.f.g/'), ['/a/b', '!(a|b)/e.f.g/']); - assert.deepStrictEqual(both('/a/b/@(a|b)/e.f.g/'), ['/a/b', '@(a|b)/e.f.g/']); + assert.deepStrictEqual(both('/a/b/!(a|b)/e.f.g/'), [ + '/a/b', + '!(a|b)/e.f.g/' + ]); + assert.deepStrictEqual(both('/a/b/@(a|b)/e.f.g/'), [ + '/a/b', + '@(a|b)/e.f.g/' + ]); assert.deepStrictEqual(both('@(a|b)/e.f.g/'), ['', '@(a|b)/e.f.g/']); assert.strictEqual(base('path/!(to|from)'), 'path'); assert.strictEqual(base('path/*(to|from)'), 'path'); @@ -569,7 +656,10 @@ describe('picomatch', () => { assert.deepStrictEqual(both('a/.x.md'), ['a/.x.md', '']); assert.deepStrictEqual(both('a/b/.gitignore'), ['a/b/.gitignore', '']); assert.deepStrictEqual(both('a/b/c/d.md'), ['a/b/c/d.md', '']); - assert.deepStrictEqual(both('a/b/c/d.e.f/g.min.js'), ['a/b/c/d.e.f/g.min.js', '']); + assert.deepStrictEqual(both('a/b/c/d.e.f/g.min.js'), [ + 'a/b/c/d.e.f/g.min.js', + '' + ]); assert.deepStrictEqual(both('a/b/.git'), ['a/b/.git', '']); assert.deepStrictEqual(both('a/b/.git/'), ['a/b/.git/', '']); assert.deepStrictEqual(both('a/b/c'), ['a/b/c', '']); @@ -602,23 +692,56 @@ describe('picomatch', () => { it('should respect brace enclosures with embedded separators', () => { const opts = { unescape: true }; assert.strictEqual(base('path/{,/,bar/baz,qux}/', opts), 'path'); - assert.strictEqual(base('path/\\{,/,bar/baz,qux}/', opts), 'path/{,/,bar/baz,qux}/'); - assert.strictEqual(base('path/\\{,/,bar/baz,qux\\}/', opts), 'path/{,/,bar/baz,qux}/'); + assert.strictEqual( + base('path/\\{,/,bar/baz,qux}/', opts), + 'path/{,/,bar/baz,qux}/' + ); + assert.strictEqual( + base('path/\\{,/,bar/baz,qux\\}/', opts), + 'path/{,/,bar/baz,qux}/' + ); assert.strictEqual(base('/{,/,bar/baz,qux}/', opts), '/'); - assert.strictEqual(base('/\\{,/,bar/baz,qux}/', opts), '/{,/,bar/baz,qux}/'); + assert.strictEqual( + base('/\\{,/,bar/baz,qux}/', opts), + '/{,/,bar/baz,qux}/' + ); assert.strictEqual(base('{,/,bar/baz,qux}', opts), ''); - assert.strictEqual(base('\\{,/,bar/baz,qux\\}', opts), '{,/,bar/baz,qux}'); - assert.strictEqual(base('\\{,/,bar/baz,qux}/', opts), '{,/,bar/baz,qux}/'); + assert.strictEqual( + base('\\{,/,bar/baz,qux\\}', opts), + '{,/,bar/baz,qux}' + ); + assert.strictEqual( + base('\\{,/,bar/baz,qux}/', opts), + '{,/,bar/baz,qux}/' + ); }); it('should handle escaped nested braces', () => { const opts = { unescape: true }; - assert.strictEqual(base('\\{../,./,\\{bar,/baz},qux}', opts), '{../,./,{bar,/baz},qux}'); - assert.strictEqual(base('\\{../,./,\\{bar,/baz},qux}/', opts), '{../,./,{bar,/baz},qux}/'); - assert.strictEqual(base('path/\\{,/,bar/{baz,qux}}/', opts), 'path/{,/,bar/{baz,qux}}/'); - assert.strictEqual(base('path/\\{../,./,\\{bar,/baz},qux}/', opts), 'path/{../,./,{bar,/baz},qux}/'); - assert.strictEqual(base('path/\\{../,./,\\{bar,/baz},qux}/', opts), 'path/{../,./,{bar,/baz},qux}/'); - assert.strictEqual(base('path/\\{../,./,{bar,/baz},qux}/', opts), 'path/{../,./,{bar,/baz},qux}/'); + assert.strictEqual( + base('\\{../,./,\\{bar,/baz},qux}', opts), + '{../,./,{bar,/baz},qux}' + ); + assert.strictEqual( + base('\\{../,./,\\{bar,/baz},qux}/', opts), + '{../,./,{bar,/baz},qux}/' + ); + assert.strictEqual( + base('path/\\{,/,bar/{baz,qux}}/', opts), + 'path/{,/,bar/{baz,qux}}/' + ); + assert.strictEqual( + base('path/\\{../,./,\\{bar,/baz},qux}/', opts), + 'path/{../,./,{bar,/baz},qux}/' + ); + assert.strictEqual( + base('path/\\{../,./,\\{bar,/baz},qux}/', opts), + 'path/{../,./,{bar,/baz},qux}/' + ); + assert.strictEqual( + base('path/\\{../,./,{bar,/baz},qux}/', opts), + 'path/{../,./,{bar,/baz},qux}/' + ); assert.strictEqual(base('path/{,/,bar/\\{baz,qux}}/', opts), 'path'); }); @@ -637,39 +760,90 @@ describe('picomatch', () => { }); it('should support braces: no path', () => { - assert.deepStrictEqual(both('/a/b/{c,/foo.js}/e.f.g/'), ['/a/b', '{c,/foo.js}/e.f.g/']); - assert.deepStrictEqual(both('{a/b/c.js,/a/b/{c,/foo.js}/e.f.g/}'), ['', '{a/b/c.js,/a/b/{c,/foo.js}/e.f.g/}']); + assert.deepStrictEqual(both('/a/b/{c,/foo.js}/e.f.g/'), [ + '/a/b', + '{c,/foo.js}/e.f.g/' + ]); + assert.deepStrictEqual(both('{a/b/c.js,/a/b/{c,/foo.js}/e.f.g/}'), [ + '', + '{a/b/c.js,/a/b/{c,/foo.js}/e.f.g/}' + ]); assert.deepStrictEqual(both('/a/b/{c,d}/'), ['/a/b', '{c,d}/']); assert.deepStrictEqual(both('/a/b/{c,d}/*.js'), ['/a/b', '{c,d}/*.js']); - assert.deepStrictEqual(both('/a/b/{c,d}/*.min.js'), ['/a/b', '{c,d}/*.min.js']); - assert.deepStrictEqual(both('/a/b/{c,d}/e.f.g/'), ['/a/b', '{c,d}/e.f.g/']); + assert.deepStrictEqual(both('/a/b/{c,d}/*.min.js'), [ + '/a/b', + '{c,d}/*.min.js' + ]); + assert.deepStrictEqual(both('/a/b/{c,d}/e.f.g/'), [ + '/a/b', + '{c,d}/e.f.g/' + ]); assert.deepStrictEqual(both('{.,*}'), ['', '{.,*}']); }); it('should support braces in filename', () => { - assert.deepStrictEqual(both('a/b/.{c,.gitignore}'), ['a/b', '.{c,.gitignore}']); - assert.deepStrictEqual(both('a/b/.{c,/.gitignore}'), ['a/b', '.{c,/.gitignore}']); + assert.deepStrictEqual(both('a/b/.{c,.gitignore}'), [ + 'a/b', + '.{c,.gitignore}' + ]); + assert.deepStrictEqual(both('a/b/.{c,/.gitignore}'), [ + 'a/b', + '.{c,/.gitignore}' + ]); assert.deepStrictEqual(both('a/b/.{foo,bar}'), ['a/b', '.{foo,bar}']); - assert.deepStrictEqual(both('a/b/{c,.gitignore}'), ['a/b', '{c,.gitignore}']); - assert.deepStrictEqual(both('a/b/{c,/.gitignore}'), ['a/b', '{c,/.gitignore}']); - assert.deepStrictEqual(both('a/b/{c,/gitignore}'), ['a/b', '{c,/gitignore}']); + assert.deepStrictEqual(both('a/b/{c,.gitignore}'), [ + 'a/b', + '{c,.gitignore}' + ]); + assert.deepStrictEqual(both('a/b/{c,/.gitignore}'), [ + 'a/b', + '{c,/.gitignore}' + ]); + assert.deepStrictEqual(both('a/b/{c,/gitignore}'), [ + 'a/b', + '{c,/gitignore}' + ]); assert.deepStrictEqual(both('a/b/{c,d}'), ['a/b', '{c,d}']); }); it('should support braces in dirname', () => { - assert.deepStrictEqual(both('a/b/{c,./d}/e/f.g'), ['a/b', '{c,./d}/e/f.g']); - assert.deepStrictEqual(both('a/b/{c,./d}/e/f.min.g'), ['a/b', '{c,./d}/e/f.min.g']); - assert.deepStrictEqual(both('a/b/{c,.gitignore,{a,./b}}/{a,b}/abc.foo.js'), ['a/b', '{c,.gitignore,{a,./b}}/{a,b}/abc.foo.js']); - assert.deepStrictEqual(both('a/b/{c,.gitignore,{a,b}}/{a,b}/*.foo.js'), ['a/b', '{c,.gitignore,{a,b}}/{a,b}/*.foo.js']); - assert.deepStrictEqual(both('a/b/{c,.gitignore,{a,b}}/{a,b}/abc.foo.js'), ['a/b', '{c,.gitignore,{a,b}}/{a,b}/abc.foo.js']); + assert.deepStrictEqual(both('a/b/{c,./d}/e/f.g'), [ + 'a/b', + '{c,./d}/e/f.g' + ]); + assert.deepStrictEqual(both('a/b/{c,./d}/e/f.min.g'), [ + 'a/b', + '{c,./d}/e/f.min.g' + ]); + assert.deepStrictEqual( + both('a/b/{c,.gitignore,{a,./b}}/{a,b}/abc.foo.js'), + ['a/b', '{c,.gitignore,{a,./b}}/{a,b}/abc.foo.js'] + ); + assert.deepStrictEqual(both('a/b/{c,.gitignore,{a,b}}/{a,b}/*.foo.js'), [ + 'a/b', + '{c,.gitignore,{a,b}}/{a,b}/*.foo.js' + ]); + assert.deepStrictEqual( + both('a/b/{c,.gitignore,{a,b}}/{a,b}/abc.foo.js'), + ['a/b', '{c,.gitignore,{a,b}}/{a,b}/abc.foo.js'] + ); assert.deepStrictEqual(both('a/b/{c,/d}/e/f.g'), ['a/b', '{c,/d}/e/f.g']); - assert.deepStrictEqual(both('a/b/{c,/d}/e/f.min.g'), ['a/b', '{c,/d}/e/f.min.g']); + assert.deepStrictEqual(both('a/b/{c,/d}/e/f.min.g'), [ + 'a/b', + '{c,/d}/e/f.min.g' + ]); assert.deepStrictEqual(both('a/b/{c,d}/'), ['a/b', '{c,d}/']); assert.deepStrictEqual(both('a/b/{c,d}/*.js'), ['a/b', '{c,d}/*.js']); - assert.deepStrictEqual(both('a/b/{c,d}/*.min.js'), ['a/b', '{c,d}/*.min.js']); + assert.deepStrictEqual(both('a/b/{c,d}/*.min.js'), [ + 'a/b', + '{c,d}/*.min.js' + ]); assert.deepStrictEqual(both('a/b/{c,d}/e.f.g/'), ['a/b', '{c,d}/e.f.g/']); assert.deepStrictEqual(both('a/b/{c,d}/e/f.g'), ['a/b', '{c,d}/e/f.g']); - assert.deepStrictEqual(both('a/b/{c,d}/e/f.min.g'), ['a/b', '{c,d}/e/f.min.g']); + assert.deepStrictEqual(both('a/b/{c,d}/e/f.min.g'), [ + 'a/b', + '{c,d}/e/f.min.g' + ]); assert.deepStrictEqual(both('foo/{a,b}.min.js'), ['foo', '{a,b}.min.js']); }); }); diff --git a/test/bash.js b/test/bash.js index 2ef4bb1a..73eec859 100644 --- a/test/bash.js +++ b/test/bash.js @@ -208,7 +208,7 @@ describe('from the Bash 4.3 spec/unit tests', () => { assert(!isMatch('d', "'***'")); assert(!isMatch('dd', "'***'")); assert(!isMatch('de', "'***'")); - assert(isMatch('\'***\'', "'***'")); + assert(isMatch("'***'", "'***'")); assert(!isMatch('*', '"***"')); assert(!isMatch('**', '"***"')); diff --git a/test/braces.js b/test/braces.js index a343c316..574e5664 100644 --- a/test/braces.js +++ b/test/braces.js @@ -7,9 +7,19 @@ const { isMatch } = require('..'); describe('braces', () => { it('should not match with brace patterns when disabled', () => { - assert.deepStrictEqual(match(['a', 'b', 'c'], '{a,b,c,d}'), ['a', 'b', 'c']); - assert.deepStrictEqual(match(['a', 'b', 'c'], '{a,b,c,d}', { nobrace: true }), []); - assert.deepStrictEqual(match(['1', '2', '3'], '{1..2}', { nobrace: true }), []); + assert.deepStrictEqual(match(['a', 'b', 'c'], '{a,b,c,d}'), [ + 'a', + 'b', + 'c' + ]); + assert.deepStrictEqual( + match(['a', 'b', 'c'], '{a,b,c,d}', { nobrace: true }), + [] + ); + assert.deepStrictEqual( + match(['1', '2', '3'], '{1..2}', { nobrace: true }), + [] + ); assert(!isMatch('a/a', 'a/{a,b}', { nobrace: true })); assert(!isMatch('a/b', 'a/{a,b}', { nobrace: true })); assert(!isMatch('a/c', 'a/{a,b}', { nobrace: true })); @@ -193,21 +203,35 @@ describe('braces', () => { const expandRange = (a, b) => `(${fill(a, b, { toRegex: true })})`; assert(!isMatch('foo/bar - 1', '*/* {4..10}', { expandRange })); - assert(!isMatch('foo/bar - copy (1)', '*/* - * \\({4..10}\\)', { expandRange })); + assert( + !isMatch('foo/bar - copy (1)', '*/* - * \\({4..10}\\)', { expandRange }) + ); assert(!isMatch('foo/bar (1)', '*/* \\({4..10}\\)', { expandRange })); assert(isMatch('foo/bar (4)', '*/* \\({4..10}\\)', { expandRange })); assert(isMatch('foo/bar (7)', '*/* \\({4..10}\\)', { expandRange })); assert(!isMatch('foo/bar (42)', '*/* \\({4..10}\\)', { expandRange })); assert(isMatch('foo/bar (42)', '*/* \\({4..43}\\)', { expandRange })); assert(isMatch('foo/bar - copy [1]', '*/* \\[{0..5}\\]', { expandRange })); - assert(isMatch('foo/bar - foo + bar - copy [1]', '*/* \\[{0..5}\\]', { expandRange })); + assert( + isMatch('foo/bar - foo + bar - copy [1]', '*/* \\[{0..5}\\]', { + expandRange + }) + ); assert(!isMatch('foo/bar - 1', '*/* \\({4..10}\\)', { expandRange })); - assert(!isMatch('foo/bar - copy (1)', '*/* \\({4..10}\\)', { expandRange })); + assert( + !isMatch('foo/bar - copy (1)', '*/* \\({4..10}\\)', { expandRange }) + ); assert(!isMatch('foo/bar (1)', '*/* \\({4..10}\\)', { expandRange })); assert(isMatch('foo/bar (4)', '*/* \\({4..10}\\)', { expandRange })); assert(isMatch('foo/bar (7)', '*/* \\({4..10}\\)', { expandRange })); assert(!isMatch('foo/bar (42)', '*/* \\({4..10}\\)', { expandRange })); - assert(!isMatch('foo/bar - copy [1]', '*/* \\({4..10}\\)', { expandRange })); - assert(!isMatch('foo/bar - foo + bar - copy [1]', '*/* \\({4..10}\\)', { expandRange })); + assert( + !isMatch('foo/bar - copy [1]', '*/* \\({4..10}\\)', { expandRange }) + ); + assert( + !isMatch('foo/bar - foo + bar - copy [1]', '*/* \\({4..10}\\)', { + expandRange + }) + ); }); }); diff --git a/test/dotfiles.js b/test/dotfiles.js index f90abb88..973d9d1f 100644 --- a/test/dotfiles.js +++ b/test/dotfiles.js @@ -10,74 +10,154 @@ describe('dotfiles', () => { assert.deepStrictEqual(match(['.dotfile'], '*'), []); assert.deepStrictEqual(match(['.dotfile'], '**'), []); assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '*.md'), []); - assert.deepStrictEqual(match(['a/b', 'a/.b', '.a/b', '.a/.b'], '**'), ['a/b']); + assert.deepStrictEqual(match(['a/b', 'a/.b', '.a/b', '.a/.b'], '**'), [ + 'a/b' + ]); assert.deepStrictEqual(match(['a/b/c/.dotfile'], '*.*'), []); }); }); describe('leading dot', () => { it('should match dotfiles when a leading dot is defined in the path:', () => { - assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '**/.*'), ['a/b/c/.dotfile.md']); - assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '**/.*.md'), ['a/b/c/.dotfile.md']); + assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '**/.*'), [ + 'a/b/c/.dotfile.md' + ]); + assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '**/.*.md'), [ + 'a/b/c/.dotfile.md' + ]); }); it('should use negation patterns on dotfiles:', () => { - assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!.*'), ['c', 'c.md']); - assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!.b'), ['.a', 'c', 'c.md']); + assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!.*'), [ + 'c', + 'c.md' + ]); + assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!.b'), [ + '.a', + 'c', + 'c.md' + ]); }); it('should match dotfiles when there is a leading dot:', () => { const opts = { dot: true }; assert.deepStrictEqual(match(['.dotfile'], '*', opts), ['.dotfile']); assert.deepStrictEqual(match(['.dotfile'], '**', opts), ['.dotfile']); - assert.deepStrictEqual(match(['a/b', 'a/.b', '.a/b', '.a/.b'], '**', opts), ['a/b', 'a/.b', '.a/b', '.a/.b']); - assert.deepStrictEqual(match(['a/b', 'a/.b', 'a/.b', '.a/.b'], 'a/{.*,**}', opts), ['a/b', 'a/.b']); - assert.deepStrictEqual(match(['a/b', 'a/.b', 'a/.b', '.a/.b'], '{.*,**}', {}), ['a/b']); - assert.deepStrictEqual(match(['a/b', 'a/.b', 'a/.b', '.a/.b'], '{.*,**}', opts), ['a/b', 'a/.b', '.a/.b']); - assert.deepStrictEqual(match(['.dotfile'], '.dotfile', opts), ['.dotfile']); - assert.deepStrictEqual(match(['.dotfile.md'], '.*.md', opts), ['.dotfile.md']); + assert.deepStrictEqual( + match(['a/b', 'a/.b', '.a/b', '.a/.b'], '**', opts), + ['a/b', 'a/.b', '.a/b', '.a/.b'] + ); + assert.deepStrictEqual( + match(['a/b', 'a/.b', 'a/.b', '.a/.b'], 'a/{.*,**}', opts), + ['a/b', 'a/.b'] + ); + assert.deepStrictEqual( + match(['a/b', 'a/.b', 'a/.b', '.a/.b'], '{.*,**}', {}), + ['a/b'] + ); + assert.deepStrictEqual( + match(['a/b', 'a/.b', 'a/.b', '.a/.b'], '{.*,**}', opts), + ['a/b', 'a/.b', '.a/.b'] + ); + assert.deepStrictEqual(match(['.dotfile'], '.dotfile', opts), [ + '.dotfile' + ]); + assert.deepStrictEqual(match(['.dotfile.md'], '.*.md', opts), [ + '.dotfile.md' + ]); }); it('should match dotfiles when there is not a leading dot:', () => { const opts = { dot: true }; assert.deepStrictEqual(match(['.dotfile'], '*.*', opts), ['.dotfile']); - assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '*.*', opts), ['.a', '.b', 'c.md']); + assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '*.*', opts), [ + '.a', + '.b', + 'c.md' + ]); assert.deepStrictEqual(match(['.dotfile'], '*.md', opts), []); assert.deepStrictEqual(match(['.verb.txt'], '*.md', opts), []); assert.deepStrictEqual(match(['a/b/c/.dotfile'], '*.md', opts), []); assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '*.md', opts), []); - assert.deepStrictEqual(match(['a/b/c/.verb.md'], '**/*.md', opts), ['a/b/c/.verb.md']); + assert.deepStrictEqual(match(['a/b/c/.verb.md'], '**/*.md', opts), [ + 'a/b/c/.verb.md' + ]); assert.deepStrictEqual(match(['foo.md'], '*.md', opts), ['foo.md']); }); it('should use negation patterns on dotfiles:', () => { - assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!.*'), ['c', 'c.md']); - assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!(.*)'), ['c', 'c.md']); - assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!(.*)*'), ['c', 'c.md']); - assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!*.*'), ['.a', '.b', 'c']); + assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!.*'), [ + 'c', + 'c.md' + ]); + assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!(.*)'), [ + 'c', + 'c.md' + ]); + assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!(.*)*'), [ + 'c', + 'c.md' + ]); + assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!*.*'), [ + '.a', + '.b', + 'c' + ]); }); }); describe('options.dot', () => { it('should match dotfiles when `options.dot` is true:', () => { const fixtures = ['a/./b', 'a/../b', 'a/c/b', 'a/.d/b']; - assert.deepStrictEqual(match(['.dotfile'], '*.*', { dot: true }), ['.dotfile']); + assert.deepStrictEqual(match(['.dotfile'], '*.*', { dot: true }), [ + '.dotfile' + ]); assert.deepStrictEqual(match(['.dotfile'], '*.md', { dot: true }), []); - assert.deepStrictEqual(match(['.dotfile'], '.dotfile', { dot: true }), ['.dotfile']); - assert.deepStrictEqual(match(['.dotfile.md'], '.*.md', { dot: true }), ['.dotfile.md']); + assert.deepStrictEqual(match(['.dotfile'], '.dotfile', { dot: true }), [ + '.dotfile' + ]); + assert.deepStrictEqual(match(['.dotfile.md'], '.*.md', { dot: true }), [ + '.dotfile.md' + ]); assert.deepStrictEqual(match(['.verb.txt'], '*.md', { dot: true }), []); assert.deepStrictEqual(match(['.verb.txt'], '*.md', { dot: true }), []); - assert.deepStrictEqual(match(['a/b/c/.dotfile'], '*.md', { dot: true }), []); - assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '**/*.md', { dot: true }), ['a/b/c/.dotfile.md']); - assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '**/.*', { dot: false }), ['a/b/c/.dotfile.md']); - assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '**/.*.md', { dot: false }), ['a/b/c/.dotfile.md']); - assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '*.md', { dot: false }), []); - assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '*.md', { dot: true }), []); - assert.deepStrictEqual(match(['a/b/c/.verb.md'], '**/*.md', { dot: true }), ['a/b/c/.verb.md']); + assert.deepStrictEqual( + match(['a/b/c/.dotfile'], '*.md', { dot: true }), + [] + ); + assert.deepStrictEqual( + match(['a/b/c/.dotfile.md'], '**/*.md', { dot: true }), + ['a/b/c/.dotfile.md'] + ); + assert.deepStrictEqual( + match(['a/b/c/.dotfile.md'], '**/.*', { dot: false }), + ['a/b/c/.dotfile.md'] + ); + assert.deepStrictEqual( + match(['a/b/c/.dotfile.md'], '**/.*.md', { dot: false }), + ['a/b/c/.dotfile.md'] + ); + assert.deepStrictEqual( + match(['a/b/c/.dotfile.md'], '*.md', { dot: false }), + [] + ); + assert.deepStrictEqual( + match(['a/b/c/.dotfile.md'], '*.md', { dot: true }), + [] + ); + assert.deepStrictEqual( + match(['a/b/c/.verb.md'], '**/*.md', { dot: true }), + ['a/b/c/.verb.md'] + ); assert.deepStrictEqual(match(['d.md'], '*.md', { dot: true }), ['d.md']); - assert.deepStrictEqual(match(fixtures, 'a/*/b', { dot: true }), ['a/c/b', 'a/.d/b']); + assert.deepStrictEqual(match(fixtures, 'a/*/b', { dot: true }), [ + 'a/c/b', + 'a/.d/b' + ]); assert.deepStrictEqual(match(fixtures, 'a/.*/b'), ['a/.d/b']); - assert.deepStrictEqual(match(fixtures, 'a/.*/b', { dot: true }), ['a/.d/b']); + assert.deepStrictEqual(match(fixtures, 'a/.*/b', { dot: true }), [ + 'a/.d/b' + ]); }); it('should match dotfiles when `options.dot` is true', () => { diff --git a/test/dots-invalid.js b/test/dots-invalid.js index ff730a89..8d657403 100644 --- a/test/dots-invalid.js +++ b/test/dots-invalid.js @@ -398,7 +398,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../abc/../', '**/**/**/**', { dot: true })); assert(!isMatch('abc/../abc/../', '**/**/**/**/', { dot: true })); - assert(!isMatch('abc/../abc/abc/../', '**/**/**/**/**', { dot: true })); + assert( + !isMatch('abc/../abc/abc/../', '**/**/**/**/**', { dot: true }) + ); }); it('with dot + globstar', () => { @@ -412,7 +414,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../abc/../', '**/.**/**/.**', { dot: true })); assert(!isMatch('abc/../abc/../', '**/.**/**/.**/', { dot: true })); - assert(!isMatch('abc/../abc/abc/../', '**/.**/**/.**/**', { dot: true })); + assert( + !isMatch('abc/../abc/abc/../', '**/.**/**/.**/**', { dot: true }) + ); }); it('with globstar + dot + globstar', () => { @@ -424,9 +428,15 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '**/**.**/', { dot: true })); assert(!isMatch('abc/../', '**/**.**/**', { dot: true })); - assert(!isMatch('abc/../abc/../', '**/**.**/**/**.**', { dot: true })); - assert(!isMatch('abc/../abc/../', '**/**.**/**/**.**/', { dot: true })); - assert(!isMatch('abc/../abc/abc/../', '**/**.**/**/.**/**', { dot: true })); + assert( + !isMatch('abc/../abc/../', '**/**.**/**/**.**', { dot: true }) + ); + assert( + !isMatch('abc/../abc/../', '**/**.**/**/**.**/', { dot: true }) + ); + assert( + !isMatch('abc/../abc/abc/../', '**/**.**/**/.**/**', { dot: true }) + ); }); it('with globstar + dot', () => { @@ -440,7 +450,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../abc/../', '**/**./**/**.', { dot: true })); assert(!isMatch('abc/../abc/../', '**/**./**/**./', { dot: true })); - assert(!isMatch('abc/../abc/abc/../', '**/**./**/**./**', { dot: true })); + assert( + !isMatch('abc/../abc/abc/../', '**/**./**/**./**', { dot: true }) + ); }); }); }); @@ -478,7 +490,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('../abc', '**/abc/**/**', { strictSlashes: true })); assert(!isMatch('../abc', '**/**/abc/**', { strictSlashes: true })); - assert(!isMatch('../abc', '**/**/abc/**/**', { strictSlashes: true })); + assert( + !isMatch('../abc', '**/**/abc/**/**', { strictSlashes: true }) + ); }); it('with dot + globstar', () => { @@ -505,7 +519,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('/../abc', '*/*/*', { strictSlashes: true })); assert(!isMatch('abc/../abc', '*/*/*', { strictSlashes: true })); - assert(!isMatch('abc/../abc/abc', '*/*/*/*', { strictSlashes: true })); + assert( + !isMatch('abc/../abc/abc', '*/*/*/*', { strictSlashes: true }) + ); }); it('with dot + star', () => { @@ -530,7 +546,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('/../abc', '**/**/**', { strictSlashes: true })); assert(!isMatch('abc/../abc', '**/**/**', { strictSlashes: true })); - assert(!isMatch('abc/../abc/abc', '**/**/**/**', { strictSlashes: true })); + assert( + !isMatch('abc/../abc/abc', '**/**/**/**', { strictSlashes: true }) + ); }); it('with dot + globstar', () => { @@ -556,7 +574,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('/../abc', '/**.**/**', { strictSlashes: true })); assert(!isMatch('/../abc', '/*.*/**', { strictSlashes: true })); - assert(!isMatch('abc/../abc', '**/**.**/**', { strictSlashes: true })); + assert( + !isMatch('abc/../abc', '**/**.**/**', { strictSlashes: true }) + ); assert(!isMatch('abc/../abc', '**/*.*/**', { strictSlashes: true })); assert(!isMatch('abc/../abc', '/**.**/**', { strictSlashes: true })); @@ -574,9 +594,15 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '*/*/', { strictSlashes: true })); assert(!isMatch('abc/../', '*/*/*', { strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '*/*/*/*', { strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '*/*/*/*/', { strictSlashes: true })); - assert(!isMatch('abc/../abc/abc/../', '*/*/*/*/*', { strictSlashes: true })); + assert( + !isMatch('abc/../abc/../', '*/*/*/*', { strictSlashes: true }) + ); + assert( + !isMatch('abc/../abc/../', '*/*/*/*/', { strictSlashes: true }) + ); + assert( + !isMatch('abc/../abc/abc/../', '*/*/*/*/*', { strictSlashes: true }) + ); }); it('with dot + star', () => { @@ -588,9 +614,17 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '*/.*/', { strictSlashes: true })); assert(!isMatch('abc/../', '*/.*/*', { strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '*/.*/*/.*', { strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '*/.*/*/.*/', { strictSlashes: true })); - assert(!isMatch('abc/../abc/abc/../', '*/.*/*/.*/*', { strictSlashes: true })); + assert( + !isMatch('abc/../abc/../', '*/.*/*/.*', { strictSlashes: true }) + ); + assert( + !isMatch('abc/../abc/../', '*/.*/*/.*/', { strictSlashes: true }) + ); + assert( + !isMatch('abc/../abc/abc/../', '*/.*/*/.*/*', { + strictSlashes: true + }) + ); }); it('with star + dot', () => { @@ -602,9 +636,17 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '*/*./', { strictSlashes: true })); assert(!isMatch('abc/../', '*/*./*', { strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '*/*./*/*.', { strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '*/*./*/*./', { strictSlashes: true })); - assert(!isMatch('abc/../abc/abc/../', '*/*./*/*./*', { strictSlashes: true })); + assert( + !isMatch('abc/../abc/../', '*/*./*/*.', { strictSlashes: true }) + ); + assert( + !isMatch('abc/../abc/../', '*/*./*/*./', { strictSlashes: true }) + ); + assert( + !isMatch('abc/../abc/abc/../', '*/*./*/*./*', { + strictSlashes: true + }) + ); }); it('with globstar', () => { @@ -616,9 +658,17 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '**/**/', { strictSlashes: true })); assert(!isMatch('abc/../', '**/**/**', { strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '**/**/**/**', { strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '**/**/**/**/', { strictSlashes: true })); - assert(!isMatch('abc/../abc/abc/../', '**/**/**/**/**', { strictSlashes: true })); + assert( + !isMatch('abc/../abc/../', '**/**/**/**', { strictSlashes: true }) + ); + assert( + !isMatch('abc/../abc/../', '**/**/**/**/', { strictSlashes: true }) + ); + assert( + !isMatch('abc/../abc/abc/../', '**/**/**/**/**', { + strictSlashes: true + }) + ); }); it('with dot + globstar', () => { @@ -630,9 +680,19 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '**/.**/', { strictSlashes: true })); assert(!isMatch('abc/../', '**/.**/**', { strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '**/.**/**/.**', { strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '**/.**/**/.**/', { strictSlashes: true })); - assert(!isMatch('abc/../abc/abc/../', '**/.**/**/.**/**', { strictSlashes: true })); + assert( + !isMatch('abc/../abc/../', '**/.**/**/.**', { strictSlashes: true }) + ); + assert( + !isMatch('abc/../abc/../', '**/.**/**/.**/', { + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/abc/../', '**/.**/**/.**/**', { + strictSlashes: true + }) + ); }); it('with globstar + dot + globstar', () => { @@ -644,9 +704,21 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '**/**.**/', { strictSlashes: true })); assert(!isMatch('abc/../', '**/**.**/**', { strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '**/**.**/**/**.**', { strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '**/**.**/**/**.**/', { strictSlashes: true })); - assert(!isMatch('abc/../abc/abc/../', '**/**.**/**/.**/**', { strictSlashes: true })); + assert( + !isMatch('abc/../abc/../', '**/**.**/**/**.**', { + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/../', '**/**.**/**/**.**/', { + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/abc/../', '**/**.**/**/.**/**', { + strictSlashes: true + }) + ); }); it('with globstar + dot', () => { @@ -658,9 +730,19 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '**/**./', { strictSlashes: true })); assert(!isMatch('abc/../', '**/**./**', { strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '**/**./**/**.', { strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '**/**./**/**./', { strictSlashes: true })); - assert(!isMatch('abc/../abc/abc/../', '**/**./**/**./**', { strictSlashes: true })); + assert( + !isMatch('abc/../abc/../', '**/**./**/**.', { strictSlashes: true }) + ); + assert( + !isMatch('abc/../abc/../', '**/**./**/**./', { + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/abc/../', '**/**./**/**./**', { + strictSlashes: true + }) + ); }); }); }); @@ -669,218 +751,580 @@ describe('invalid (exclusive) dots', () => { describe('should not match leading double-dots', () => { it('with single star', () => { assert(!isMatch('../abc', '*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', '*/abc', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', '*/abc/*', { dot: true, strictSlashes: true })); + assert( + !isMatch('../abc', '*/abc', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('../abc', '*/abc/*', { dot: true, strictSlashes: true }) + ); }); it('with dot + single star', () => { - assert(!isMatch('../abc', '.*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', '.*/abc', { dot: true, strictSlashes: true })); + assert( + !isMatch('../abc', '.*/*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('../abc', '.*/abc', { dot: true, strictSlashes: true }) + ); - assert(!isMatch('../abc', '*./*', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', '*./abc', { dot: true, strictSlashes: true })); + assert( + !isMatch('../abc', '*./*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('../abc', '*./abc', { dot: true, strictSlashes: true }) + ); }); it('with globstar', () => { assert(!isMatch('../abc', '**', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', '**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', '**/**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('../abc', '**/abc', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', '**/abc/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('../abc', 'abc/**', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', 'abc/**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', 'abc/**/**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('../abc', '**/abc', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', '**/abc/**', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', '**/abc/**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('../abc', '**/**/abc/**', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', '**/**/abc/**/**', { dot: true, strictSlashes: true })); + assert( + !isMatch('../abc', '**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('../abc', '**/**/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('../abc', '**/abc', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('../abc', '**/abc/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('../abc', 'abc/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('../abc', 'abc/**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('../abc', 'abc/**/**/**', { + dot: true, + strictSlashes: true + }) + ); + + assert( + !isMatch('../abc', '**/abc', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('../abc', '**/abc/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('../abc', '**/abc/**/**', { + dot: true, + strictSlashes: true + }) + ); + + assert( + !isMatch('../abc', '**/**/abc/**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('../abc', '**/**/abc/**/**', { + dot: true, + strictSlashes: true + }) + ); }); it('with dot + globstar', () => { assert(!isMatch('../abc', '.**', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', '.**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', '.**/abc', { dot: true, strictSlashes: true })); + assert( + !isMatch('../abc', '.**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('../abc', '.**/abc', { dot: true, strictSlashes: true }) + ); }); it('with globstar + dot + globstar', () => { - assert(!isMatch('../abc', '*.*/**', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', '*.*/abc', { dot: true, strictSlashes: true })); + assert( + !isMatch('../abc', '*.*/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('../abc', '*.*/abc', { dot: true, strictSlashes: true }) + ); }); it('with globstar + dot', () => { - assert(!isMatch('../abc', '**./**', { dot: true, strictSlashes: true })); - assert(!isMatch('../abc', '**./abc', { dot: true, strictSlashes: true })); + assert( + !isMatch('../abc', '**./**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('../abc', '**./abc', { dot: true, strictSlashes: true }) + ); }); }); describe('should not match nested double-dots', () => { it('with star', () => { - assert(!isMatch('/../abc', '*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('/../abc', '/*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('/../abc', '*/*/*', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../abc', '*/*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/abc', '*/*/*/*', { dot: true, strictSlashes: true })); + assert( + !isMatch('/../abc', '*/*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/../abc', '/*/*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/../abc', '*/*/*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../abc', '*/*/*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../abc/abc', '*/*/*/*', { + dot: true, + strictSlashes: true + }) + ); }); it('with dot + star', () => { - assert(!isMatch('/../abc', '*/.*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('/../abc', '/.*/*', { dot: true, strictSlashes: true })); - - assert(!isMatch('/../abc', '*/*.*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('/../abc', '/*.*/*', { dot: true, strictSlashes: true })); - - assert(!isMatch('/../abc', '*/*./*', { dot: true, strictSlashes: true })); - assert(!isMatch('/../abc', '/*./*', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../abc', '*/.*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc', '*/*.*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc', '*/*./*', { dot: true, strictSlashes: true })); + assert( + !isMatch('/../abc', '*/.*/*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/../abc', '/.*/*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('/../abc', '*/*.*/*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/../abc', '/*.*/*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('/../abc', '*/*./*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/../abc', '/*./*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../abc', '*/.*/*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../abc', '*/*.*/*', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc', '*/*./*', { dot: true, strictSlashes: true }) + ); }); it('with globstar', () => { assert(!isMatch('/../abc', '**', { dot: true, strictSlashes: true })); - assert(!isMatch('/../abc', '**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('/../abc', '/**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('/../abc', '**/**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../abc', '**/**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/abc', '**/**/**/**', { dot: true, strictSlashes: true })); + assert( + !isMatch('/../abc', '**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/../abc', '/**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/../abc', '**/**/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../abc', '**/**/**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/abc', '**/**/**/**', { + dot: true, + strictSlashes: true + }) + ); }); it('with dot + globstar', () => { - assert(!isMatch('/../abc', '**/.**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('/../abc', '/.**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../abc', '**/.**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc', '/.**/**', { dot: true, strictSlashes: true })); + assert( + !isMatch('/../abc', '**/.**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/../abc', '/.**/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../abc', '**/.**/**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc', '/.**/**', { + dot: true, + strictSlashes: true + }) + ); }); it('with globstar + dot', () => { - assert(!isMatch('/../abc', '**/**./**', { dot: true, strictSlashes: true })); - assert(!isMatch('/../abc', '/**./**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../abc', '**/**./**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc', '/**./**', { dot: true, strictSlashes: true })); + assert( + !isMatch('/../abc', '**/**./**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/../abc', '/**./**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../abc', '**/**./**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc', '/**./**', { + dot: true, + strictSlashes: true + }) + ); }); it('with globstar + dot + globstar', () => { - assert(!isMatch('/../abc', '**/**.**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('/../abc', '**/*.*/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('/../abc', '/**.**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('/../abc', '/*.*/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../abc', '**/**.**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc', '**/*.*/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../abc', '/**.**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc', '/*.*/**', { dot: true, strictSlashes: true })); + assert( + !isMatch('/../abc', '**/**.**/**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('/../abc', '**/*.*/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('/../abc', '/**.**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/../abc', '/*.*/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../abc', '**/**.**/**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc', '**/*.*/**', { + dot: true, + strictSlashes: true + }) + ); + + assert( + !isMatch('abc/../abc', '/**.**/**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc', '/*.*/**', { + dot: true, + strictSlashes: true + }) + ); }); }); describe('should not match trailing double-dots', () => { it('with single star', () => { assert(!isMatch('abc/..', '*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/..', '*/*/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/..', '*/*/*', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../', '*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../', '*/*/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../', '*/*/*', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../abc/../', '*/*/*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '*/*/*/*/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/abc/../', '*/*/*/*/*', { dot: true, strictSlashes: true })); + assert( + !isMatch('abc/..', '*/*/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/..', '*/*/*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../', '*/*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../', '*/*/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../', '*/*/*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../abc/../', '*/*/*/*', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/../', '*/*/*/*/', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/abc/../', '*/*/*/*/*', { + dot: true, + strictSlashes: true + }) + ); }); it('with dot + star', () => { - assert(!isMatch('abc/..', '*/.*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/..', '*/.*/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/..', '*/.*/*', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../', '*/.*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../', '*/.*/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../', '*/.*/*', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../abc/../', '*/.*/*/.*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '*/.*/*/.*/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/abc/../', '*/.*/*/.*/*', { dot: true, strictSlashes: true })); + assert( + !isMatch('abc/..', '*/.*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/..', '*/.*/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/..', '*/.*/*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../', '*/.*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../', '*/.*/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../', '*/.*/*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../abc/../', '*/.*/*/.*', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/../', '*/.*/*/.*/', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/abc/../', '*/.*/*/.*/*', { + dot: true, + strictSlashes: true + }) + ); }); it('with star + dot', () => { - assert(!isMatch('abc/..', '*/*.', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/..', '*/*./', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/..', '*/*./*', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../', '*/*.', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../', '*/*./', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../', '*/*./*', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../abc/../', '*/*./*/*.', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '*/*./*/*./', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/abc/../', '*/*./*/*./*', { dot: true, strictSlashes: true })); + assert( + !isMatch('abc/..', '*/*.', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/..', '*/*./', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/..', '*/*./*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../', '*/*.', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../', '*/*./', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../', '*/*./*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../abc/../', '*/*./*/*.', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/../', '*/*./*/*./', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/abc/../', '*/*./*/*./*', { + dot: true, + strictSlashes: true + }) + ); }); it('with globstar', () => { - assert(!isMatch('abc/..', '**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/..', '**/**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/..', '**/**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../', '**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../', '**/**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../', '**/**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../abc/../', '**/**/**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '**/**/**/**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/abc/../', '**/**/**/**/**', { dot: true, strictSlashes: true })); + assert( + !isMatch('abc/..', '**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/..', '**/**/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/..', '**/**/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../', '**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../', '**/**/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../', '**/**/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../abc/../', '**/**/**/**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/../', '**/**/**/**/', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/abc/../', '**/**/**/**/**', { + dot: true, + strictSlashes: true + }) + ); }); it('with dot + globstar', () => { - assert(!isMatch('abc/..', '**/.**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/..', '**/.**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/..', '**/.**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../', '**/.**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../', '**/.**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../', '**/.**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../abc/../', '**/.**/**/.**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '**/.**/**/.**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/abc/../', '**/.**/**/.**/**', { dot: true, strictSlashes: true })); + assert( + !isMatch('abc/..', '**/.**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/..', '**/.**/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/..', '**/.**/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../', '**/.**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../', '**/.**/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../', '**/.**/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../abc/../', '**/.**/**/.**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/../', '**/.**/**/.**/', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/abc/../', '**/.**/**/.**/**', { + dot: true, + strictSlashes: true + }) + ); }); it('with globstar + dot + globstar', () => { - assert(!isMatch('abc/..', '**/**.**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/..', '**/**.**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/..', '**/**.**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../', '**/**.**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../', '**/**.**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../', '**/**.**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../abc/../', '**/**.**/**/**.**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '**/**.**/**/**.**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/abc/../', '**/**.**/**/.**/**', { dot: true, strictSlashes: true })); + assert( + !isMatch('abc/..', '**/**.**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/..', '**/**.**/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/..', '**/**.**/**', { + dot: true, + strictSlashes: true + }) + ); + + assert( + !isMatch('abc/../', '**/**.**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../', '**/**.**/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../', '**/**.**/**', { + dot: true, + strictSlashes: true + }) + ); + + assert( + !isMatch('abc/../abc/../', '**/**.**/**/**.**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/../', '**/**.**/**/**.**/', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/abc/../', '**/**.**/**/.**/**', { + dot: true, + strictSlashes: true + }) + ); }); it('with globstar + dot', () => { - assert(!isMatch('abc/..', '**/**.', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/..', '**/**./', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/..', '**/**./**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../', '**/**.', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../', '**/**./', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../', '**/**./**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/../abc/../', '**/**./**/**.', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/../', '**/**./**/**./', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/../abc/abc/../', '**/**./**/**./**', { dot: true, strictSlashes: true })); + assert( + !isMatch('abc/..', '**/**.', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/..', '**/**./', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/..', '**/**./**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../', '**/**.', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../', '**/**./', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/../', '**/**./**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/../abc/../', '**/**./**/**.', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/../', '**/**./**/**./', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/../abc/abc/../', '**/**./**/**./**', { + dot: true, + strictSlashes: true + }) + ); }); }); }); @@ -1295,7 +1739,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./abc/./', '**/.**/**/.**', { dot: true })); assert(!isMatch('abc/./abc/./', '**/.**/**/.**/', { dot: true })); - assert(!isMatch('abc/./abc/abc/./', '**/.**/**/.**/**', { dot: true })); + assert( + !isMatch('abc/./abc/abc/./', '**/.**/**/.**/**', { dot: true }) + ); }); it('with globstar + dot + globstar', () => { @@ -1309,7 +1755,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./abc/./', '**/**.**/**/**.**', { dot: true })); assert(!isMatch('abc/./abc/./', '**/**.**/**/**.**/', { dot: true })); - assert(!isMatch('abc/./abc/abc/./', '**/**.**/**/.**/**', { dot: true })); + assert( + !isMatch('abc/./abc/abc/./', '**/**.**/**/.**/**', { dot: true }) + ); }); it('with globstar + dot', () => { @@ -1323,7 +1771,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./abc/./', '**/**./**/**.', { dot: true })); assert(!isMatch('abc/./abc/./', '**/**./**/**./', { dot: true })); - assert(!isMatch('abc/./abc/abc/./', '**/**./**/**./**', { dot: true })); + assert( + !isMatch('abc/./abc/abc/./', '**/**./**/**./**', { dot: true }) + ); }); }); }); @@ -1413,7 +1863,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('/./abc', '**/**/**', { strictSlashes: true })); assert(!isMatch('abc/./abc', '**/**/**', { strictSlashes: true })); - assert(!isMatch('abc/./abc/abc', '**/**/**/**', { strictSlashes: true })); + assert( + !isMatch('abc/./abc/abc', '**/**/**/**', { strictSlashes: true }) + ); }); it('with dot + globstar', () => { @@ -1459,7 +1911,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./abc/./', '*/*/*/*', { strictSlashes: true })); assert(!isMatch('abc/./abc/./', '*/*/*/*/', { strictSlashes: true })); - assert(!isMatch('abc/./abc/abc/./', '*/*/*/*/*', { strictSlashes: true })); + assert( + !isMatch('abc/./abc/abc/./', '*/*/*/*/*', { strictSlashes: true }) + ); }); it('with dot + star', () => { @@ -1471,9 +1925,15 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./', '*/.*/', { strictSlashes: true })); assert(!isMatch('abc/./', '*/.*/*', { strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '*/.*/*/.*', { strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '*/.*/*/.*/', { strictSlashes: true })); - assert(!isMatch('abc/./abc/abc/./', '*/.*/*/.*/*', { strictSlashes: true })); + assert( + !isMatch('abc/./abc/./', '*/.*/*/.*', { strictSlashes: true }) + ); + assert( + !isMatch('abc/./abc/./', '*/.*/*/.*/', { strictSlashes: true }) + ); + assert( + !isMatch('abc/./abc/abc/./', '*/.*/*/.*/*', { strictSlashes: true }) + ); }); it('with star + dot', () => { @@ -1485,9 +1945,15 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./', '*/*./', { strictSlashes: true })); assert(!isMatch('abc/./', '*/*./*', { strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '*/*./*/*.', { strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '*/*./*/*./', { strictSlashes: true })); - assert(!isMatch('abc/./abc/abc/./', '*/*./*/*./*', { strictSlashes: true })); + assert( + !isMatch('abc/./abc/./', '*/*./*/*.', { strictSlashes: true }) + ); + assert( + !isMatch('abc/./abc/./', '*/*./*/*./', { strictSlashes: true }) + ); + assert( + !isMatch('abc/./abc/abc/./', '*/*./*/*./*', { strictSlashes: true }) + ); }); it('with globstar', () => { @@ -1499,9 +1965,17 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./', '**/**/', { strictSlashes: true })); assert(!isMatch('abc/./', '**/**/**', { strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '**/**/**/**', { strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '**/**/**/**/', { strictSlashes: true })); - assert(!isMatch('abc/./abc/abc/./', '**/**/**/**/**', { strictSlashes: true })); + assert( + !isMatch('abc/./abc/./', '**/**/**/**', { strictSlashes: true }) + ); + assert( + !isMatch('abc/./abc/./', '**/**/**/**/', { strictSlashes: true }) + ); + assert( + !isMatch('abc/./abc/abc/./', '**/**/**/**/**', { + strictSlashes: true + }) + ); }); it('with dot + globstar', () => { @@ -1513,9 +1987,17 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./', '**/.**/', { strictSlashes: true })); assert(!isMatch('abc/./', '**/.**/**', { strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '**/.**/**/.**', { strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '**/.**/**/.**/', { strictSlashes: true })); - assert(!isMatch('abc/./abc/abc/./', '**/.**/**/.**/**', { strictSlashes: true })); + assert( + !isMatch('abc/./abc/./', '**/.**/**/.**', { strictSlashes: true }) + ); + assert( + !isMatch('abc/./abc/./', '**/.**/**/.**/', { strictSlashes: true }) + ); + assert( + !isMatch('abc/./abc/abc/./', '**/.**/**/.**/**', { + strictSlashes: true + }) + ); }); it('with globstar + dot + globstar', () => { @@ -1527,9 +2009,21 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./', '**/**.**/', { strictSlashes: true })); assert(!isMatch('abc/./', '**/**.**/**', { strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '**/**.**/**/**.**', { strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '**/**.**/**/**.**/', { strictSlashes: true })); - assert(!isMatch('abc/./abc/abc/./', '**/**.**/**/.**/**', { strictSlashes: true })); + assert( + !isMatch('abc/./abc/./', '**/**.**/**/**.**', { + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/./', '**/**.**/**/**.**/', { + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/abc/./', '**/**.**/**/.**/**', { + strictSlashes: true + }) + ); }); it('with globstar + dot', () => { @@ -1541,9 +2035,17 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./', '**/**./', { strictSlashes: true })); assert(!isMatch('abc/./', '**/**./**', { strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '**/**./**/**.', { strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '**/**./**/**./', { strictSlashes: true })); - assert(!isMatch('abc/./abc/abc/./', '**/**./**/**./**', { strictSlashes: true })); + assert( + !isMatch('abc/./abc/./', '**/**./**/**.', { strictSlashes: true }) + ); + assert( + !isMatch('abc/./abc/./', '**/**./**/**./', { strictSlashes: true }) + ); + assert( + !isMatch('abc/./abc/abc/./', '**/**./**/**./**', { + strictSlashes: true + }) + ); }); }); }); @@ -1552,118 +2054,269 @@ describe('invalid (exclusive) dots', () => { describe('should not match leading single-dots', () => { it('with single star', () => { assert(!isMatch('./abc', '*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', '*/abc', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', '*/abc/*', { dot: true, strictSlashes: true })); + assert( + !isMatch('./abc', '*/abc', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('./abc', '*/abc/*', { dot: true, strictSlashes: true }) + ); }); it('with dot + single star', () => { assert(!isMatch('./abc', '.*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', '.*/abc', { dot: true, strictSlashes: true })); + assert( + !isMatch('./abc', '.*/abc', { dot: true, strictSlashes: true }) + ); assert(!isMatch('./abc', '*./*', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', '*./abc', { dot: true, strictSlashes: true })); + assert( + !isMatch('./abc', '*./abc', { dot: true, strictSlashes: true }) + ); }); it('with globstar', () => { assert(!isMatch('./abc', '**', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', '**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', '**/**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('./abc', '**/abc', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', '**/abc/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('./abc', 'abc/**', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', 'abc/**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', 'abc/**/**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('./abc', '**/abc', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', '**/abc/**', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', '**/abc/**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('./abc', '**/**/abc/**', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', '**/**/abc/**/**', { dot: true, strictSlashes: true })); + assert( + !isMatch('./abc', '**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('./abc', '**/**/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('./abc', '**/abc', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('./abc', '**/abc/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('./abc', 'abc/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('./abc', 'abc/**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('./abc', 'abc/**/**/**', { + dot: true, + strictSlashes: true + }) + ); + + assert( + !isMatch('./abc', '**/abc', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('./abc', '**/abc/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('./abc', '**/abc/**/**', { + dot: true, + strictSlashes: true + }) + ); + + assert( + !isMatch('./abc', '**/**/abc/**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('./abc', '**/**/abc/**/**', { + dot: true, + strictSlashes: true + }) + ); }); it('with dot + globstar', () => { assert(!isMatch('./abc', '.**', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', '.**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', '.**/abc', { dot: true, strictSlashes: true })); + assert( + !isMatch('./abc', '.**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('./abc', '.**/abc', { dot: true, strictSlashes: true }) + ); }); it('with globstar + dot + globstar', () => { - assert(!isMatch('./abc', '*.*/**', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', '*.*/abc', { dot: true, strictSlashes: true })); + assert( + !isMatch('./abc', '*.*/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('./abc', '*.*/abc', { dot: true, strictSlashes: true }) + ); }); it('with globstar + dot', () => { - assert(!isMatch('./abc', '**./**', { dot: true, strictSlashes: true })); - assert(!isMatch('./abc', '**./abc', { dot: true, strictSlashes: true })); + assert( + !isMatch('./abc', '**./**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('./abc', '**./abc', { dot: true, strictSlashes: true }) + ); }); }); describe('should not match nested single-dots', () => { it('with star', () => { assert(!isMatch('/./abc', '*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('/./abc', '/*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('/./abc', '*/*/*', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./abc', '*/*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/abc', '*/*/*/*', { dot: true, strictSlashes: true })); + assert( + !isMatch('/./abc', '/*/*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/./abc', '*/*/*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./abc', '*/*/*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./abc/abc', '*/*/*/*', { + dot: true, + strictSlashes: true + }) + ); }); it('with dot + star', () => { - assert(!isMatch('/./abc', '*/.*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('/./abc', '/.*/*', { dot: true, strictSlashes: true })); - - assert(!isMatch('/./abc', '*/*.*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('/./abc', '/*.*/*', { dot: true, strictSlashes: true })); - - assert(!isMatch('/./abc', '*/*./*', { dot: true, strictSlashes: true })); - assert(!isMatch('/./abc', '/*./*', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./abc', '*/.*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc', '*/*.*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc', '*/*./*', { dot: true, strictSlashes: true })); + assert( + !isMatch('/./abc', '*/.*/*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/./abc', '/.*/*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('/./abc', '*/*.*/*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/./abc', '/*.*/*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('/./abc', '*/*./*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/./abc', '/*./*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./abc', '*/.*/*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./abc', '*/*.*/*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./abc', '*/*./*', { dot: true, strictSlashes: true }) + ); }); it('with globstar', () => { assert(!isMatch('/./abc', '**', { dot: true, strictSlashes: true })); - assert(!isMatch('/./abc', '**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('/./abc', '/**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('/./abc', '**/**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./abc', '**/**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/abc', '**/**/**/**', { dot: true, strictSlashes: true })); + assert( + !isMatch('/./abc', '**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/./abc', '/**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/./abc', '**/**/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./abc', '**/**/**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/abc', '**/**/**/**', { + dot: true, + strictSlashes: true + }) + ); }); it('with dot + globstar', () => { - assert(!isMatch('/./abc', '**/.**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('/./abc', '/.**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./abc', '**/.**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc', '/.**/**', { dot: true, strictSlashes: true })); + assert( + !isMatch('/./abc', '**/.**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/./abc', '/.**/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./abc', '**/.**/**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc', '/.**/**', { dot: true, strictSlashes: true }) + ); }); it('with globstar + dot', () => { - assert(!isMatch('/./abc', '**/**./**', { dot: true, strictSlashes: true })); - assert(!isMatch('/./abc', '/**./**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./abc', '**/**./**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc', '/**./**', { dot: true, strictSlashes: true })); + assert( + !isMatch('/./abc', '**/**./**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/./abc', '/**./**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./abc', '**/**./**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc', '/**./**', { dot: true, strictSlashes: true }) + ); }); it('with globstar + dot + globstar', () => { - assert(!isMatch('/./abc', '**/**.**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('/./abc', '**/*.*/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('/./abc', '/**.**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('/./abc', '/*.*/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./abc', '**/**.**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc', '**/*.*/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./abc', '/**.**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc', '/*.*/**', { dot: true, strictSlashes: true })); + assert( + !isMatch('/./abc', '**/**.**/**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('/./abc', '**/*.*/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('/./abc', '/**.**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('/./abc', '/*.*/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./abc', '**/**.**/**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc', '**/*.*/**', { + dot: true, + strictSlashes: true + }) + ); + + assert( + !isMatch('abc/./abc', '/**.**/**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc', '/*.*/**', { dot: true, strictSlashes: true }) + ); }); }); @@ -1671,99 +2324,281 @@ describe('invalid (exclusive) dots', () => { it('with single star', () => { assert(!isMatch('abc/.', '*/*', { dot: true, strictSlashes: true })); assert(!isMatch('abc/.', '*/*/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/.', '*/*/*', { dot: true, strictSlashes: true })); + assert( + !isMatch('abc/.', '*/*/*', { dot: true, strictSlashes: true }) + ); assert(!isMatch('abc/./', '*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./', '*/*/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./', '*/*/*', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./abc/./', '*/*/*/*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '*/*/*/*/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/abc/./', '*/*/*/*/*', { dot: true, strictSlashes: true })); + assert( + !isMatch('abc/./', '*/*/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./', '*/*/*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./abc/./', '*/*/*/*', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/./', '*/*/*/*/', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/abc/./', '*/*/*/*/*', { + dot: true, + strictSlashes: true + }) + ); }); it('with dot + star', () => { assert(!isMatch('abc/.', '*/.*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/.', '*/.*/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/.', '*/.*/*', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./', '*/.*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./', '*/.*/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./', '*/.*/*', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./abc/./', '*/.*/*/.*', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '*/.*/*/.*/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/abc/./', '*/.*/*/.*/*', { dot: true, strictSlashes: true })); + assert( + !isMatch('abc/.', '*/.*/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/.', '*/.*/*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./', '*/.*', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./', '*/.*/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./', '*/.*/*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./abc/./', '*/.*/*/.*', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/./', '*/.*/*/.*/', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/abc/./', '*/.*/*/.*/*', { + dot: true, + strictSlashes: true + }) + ); }); it('with star + dot', () => { assert(!isMatch('abc/.', '*/*.', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/.', '*/*./', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/.', '*/*./*', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./', '*/*.', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./', '*/*./', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./', '*/*./*', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./abc/./', '*/*./*/*.', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '*/*./*/*./', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/abc/./', '*/*./*/*./*', { dot: true, strictSlashes: true })); + assert( + !isMatch('abc/.', '*/*./', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/.', '*/*./*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./', '*/*.', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./', '*/*./', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./', '*/*./*', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./abc/./', '*/*./*/*.', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/./', '*/*./*/*./', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/abc/./', '*/*./*/*./*', { + dot: true, + strictSlashes: true + }) + ); }); it('with globstar', () => { - assert(!isMatch('abc/.', '**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/.', '**/**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/.', '**/**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./', '**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./', '**/**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./', '**/**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./abc/./', '**/**/**/**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '**/**/**/**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/abc/./', '**/**/**/**/**', { dot: true, strictSlashes: true })); + assert( + !isMatch('abc/.', '**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/.', '**/**/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/.', '**/**/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./', '**/**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./', '**/**/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./', '**/**/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./abc/./', '**/**/**/**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/./', '**/**/**/**/', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/abc/./', '**/**/**/**/**', { + dot: true, + strictSlashes: true + }) + ); }); it('with dot + globstar', () => { - assert(!isMatch('abc/.', '**/.**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/.', '**/.**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/.', '**/.**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./', '**/.**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./', '**/.**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./', '**/.**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./abc/./', '**/.**/**/.**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '**/.**/**/.**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/abc/./', '**/.**/**/.**/**', { dot: true, strictSlashes: true })); + assert( + !isMatch('abc/.', '**/.**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/.', '**/.**/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/.', '**/.**/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./', '**/.**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./', '**/.**/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./', '**/.**/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./abc/./', '**/.**/**/.**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/./', '**/.**/**/.**/', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/abc/./', '**/.**/**/.**/**', { + dot: true, + strictSlashes: true + }) + ); }); it('with globstar + dot + globstar', () => { - assert(!isMatch('abc/.', '**/**.**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/.', '**/**.**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/.', '**/**.**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./', '**/**.**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./', '**/**.**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./', '**/**.**/**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./abc/./', '**/**.**/**/**.**', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '**/**.**/**/**.**/', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/abc/./', '**/**.**/**/.**/**', { dot: true, strictSlashes: true })); + assert( + !isMatch('abc/.', '**/**.**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/.', '**/**.**/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/.', '**/**.**/**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./', '**/**.**', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./', '**/**.**/', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./', '**/**.**/**', { + dot: true, + strictSlashes: true + }) + ); + + assert( + !isMatch('abc/./abc/./', '**/**.**/**/**.**', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/./', '**/**.**/**/**.**/', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/abc/./', '**/**.**/**/.**/**', { + dot: true, + strictSlashes: true + }) + ); }); it('with globstar + dot', () => { - assert(!isMatch('abc/.', '**/**.', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/.', '**/**./', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/.', '**/**./**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./', '**/**.', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./', '**/**./', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./', '**/**./**', { dot: true, strictSlashes: true })); - - assert(!isMatch('abc/./abc/./', '**/**./**/**.', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/./', '**/**./**/**./', { dot: true, strictSlashes: true })); - assert(!isMatch('abc/./abc/abc/./', '**/**./**/**./**', { dot: true, strictSlashes: true })); + assert( + !isMatch('abc/.', '**/**.', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/.', '**/**./', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/.', '**/**./**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./', '**/**.', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./', '**/**./', { dot: true, strictSlashes: true }) + ); + assert( + !isMatch('abc/./', '**/**./**', { dot: true, strictSlashes: true }) + ); + + assert( + !isMatch('abc/./abc/./', '**/**./**/**.', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/./', '**/**./**/**./', { + dot: true, + strictSlashes: true + }) + ); + assert( + !isMatch('abc/./abc/abc/./', '**/**./**/**./**', { + dot: true, + strictSlashes: true + }) + ); }); }); }); diff --git a/test/extglobs-bash.js b/test/extglobs-bash.js index bea8d179..835ea6f0 100644 --- a/test/extglobs-bash.js +++ b/test/extglobs-bash.js @@ -17,7 +17,9 @@ describe('extglobs (bash)', () => { }); it('"*(a|b[)" should not match "\\*\\(a|b\\[\\)"', () => { - assert(!isMatch('*(a|b[)', '\\*\\(a|b\\[\\)', { bash: true, windows: true })); + assert( + !isMatch('*(a|b[)', '\\*\\(a|b\\[\\)', { bash: true, windows: true }) + ); }); it('"***" should match "\\*\\*\\*"', () => { @@ -25,19 +27,42 @@ describe('extglobs (bash)', () => { }); it('"-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1" should not match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { - assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', { bash: true, windows: true })); + assert( + !isMatch( + '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1', + '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', + { bash: true, windows: true } + ) + ); }); it('"-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1" should match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { - assert(isMatch('-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', { bash: true, windows: true })); + assert( + isMatch( + '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1', + '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', + { bash: true, windows: true } + ) + ); }); it('"-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1" should not match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { - assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', { bash: true, windows: true })); + assert( + !isMatch( + '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1', + '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', + { bash: true, windows: true } + ) + ); }); it('"/dev/udp/129.22.8.102/45" should match "/dev\\/@(tcp|udp)\\/*\\/*"', () => { - assert(isMatch('/dev/udp/129.22.8.102/45', '/dev\\/@(tcp|udp)\\/*\\/*', { bash: true, windows: true })); + assert( + isMatch('/dev/udp/129.22.8.102/45', '/dev\\/@(tcp|udp)\\/*\\/*', { + bash: true, + windows: true + }) + ); }); it('"/x/y/z" should match "/x/y/z"', () => { @@ -77,7 +102,9 @@ describe('extglobs (bash)', () => { }); it('"123abc" should not match "a(b*(foo|bar))d"', () => { - assert(!isMatch('123abc', 'a(b*(foo|bar))d', { bash: true, windows: true })); + assert( + !isMatch('123abc', 'a(b*(foo|bar))d', { bash: true, windows: true }) + ); }); it('"123abc" should not match "ab*(e|f)"', () => { @@ -117,7 +144,9 @@ describe('extglobs (bash)', () => { }); it('"137577991" should match "*(0|1|3|5|7|9)"', () => { - assert(isMatch('137577991', '*(0|1|3|5|7|9)', { bash: true, windows: true })); + assert( + isMatch('137577991', '*(0|1|3|5|7|9)', { bash: true, windows: true }) + ); }); it('"2468" should not match "*(0|1|3|5|7|9)"', () => { @@ -249,7 +278,9 @@ describe('extglobs (bash)', () => { }); it('"a." should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert(!isMatch('a.', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); + assert( + !isMatch('a.', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true }) + ); }); it('"a." should not match "*.+(b|d)"', () => { @@ -297,7 +328,9 @@ describe('extglobs (bash)', () => { }); it('"a.a" should match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert(isMatch('a.a', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); + assert( + isMatch('a.a', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true }) + ); }); it('"a.a" should not match "*.+(b|d)"', () => { @@ -313,7 +346,9 @@ describe('extglobs (bash)', () => { }); it('"a.a.a" should not match "!(*[a-b].[a-b]*)"', () => { - assert(!isMatch('a.a.a', '!(*[a-b].[a-b]*)', { bash: true, windows: true })); + assert( + !isMatch('a.a.a', '!(*[a-b].[a-b]*)', { bash: true, windows: true }) + ); }); it('"a.a.a" should not match "!*.(a|b)"', () => { @@ -345,11 +380,15 @@ describe('extglobs (bash)', () => { }); it('"a.abcd" should not match "!(*.a|*.b|*.c)*"', () => { - assert(!isMatch('a.abcd', '!(*.a|*.b|*.c)*', { bash: true, windows: true })); + assert( + !isMatch('a.abcd', '!(*.a|*.b|*.c)*', { bash: true, windows: true }) + ); }); it('"a.abcd" should match "*!(*.a|*.b|*.c)*"', () => { - assert(isMatch('a.abcd', '*!(*.a|*.b|*.c)*', { bash: true, windows: true })); + assert( + isMatch('a.abcd', '*!(*.a|*.b|*.c)*', { bash: true, windows: true }) + ); }); it('"a.abcd" should match "*!(.a|.b|.c)"', () => { @@ -365,7 +404,12 @@ describe('extglobs (bash)', () => { }); it('"a.abcd" should match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert(isMatch('a.abcd', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); + assert( + isMatch('a.abcd', '*.(a|b|@(ab|a*@(b))*(c)d)', { + bash: true, + windows: true + }) + ); }); it('"a.b" should not match "!(*.*)"', () => { @@ -409,7 +453,9 @@ describe('extglobs (bash)', () => { }); it('"a.b" should match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert(isMatch('a.b', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); + assert( + isMatch('a.b', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true }) + ); }); it('"a.b" should match "*.+(b|d)"', () => { @@ -465,7 +511,12 @@ describe('extglobs (bash)', () => { }); it('"a.c" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert(!isMatch('a.c', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); + assert( + !isMatch('a.c', '*.(a|b|@(ab|a*@(b))*(c)d)', { + bash: true, + windows: true + }) + ); }); it('"a.c.d" should match "!(*.a|*.b|*.c)"', () => { @@ -481,7 +532,12 @@ describe('extglobs (bash)', () => { }); it('"a.c.d" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert(!isMatch('a.c.d', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); + assert( + !isMatch('a.c.d', '*.(a|b|@(ab|a*@(b))*(c)d)', { + bash: true, + windows: true + }) + ); }); it('"a.ccc" should match "!(*.[a-b]*)"', () => { @@ -581,31 +637,48 @@ describe('extglobs (bash)', () => { }); it('"a/b/c.txt" should not match "*/b/!(*).txt"', () => { - assert(!isMatch('a/b/c.txt', '*/b/!(*).txt', { bash: true, windows: true })); + assert( + !isMatch('a/b/c.txt', '*/b/!(*).txt', { bash: true, windows: true }) + ); }); it('"a/b/c.txt" should not match "*/b/!(c).txt"', () => { - assert(!isMatch('a/b/c.txt', '*/b/!(c).txt', { bash: true, windows: true })); + assert( + !isMatch('a/b/c.txt', '*/b/!(c).txt', { bash: true, windows: true }) + ); }); it('"a/b/c.txt" should match "*/b/!(cc).txt"', () => { - assert(isMatch('a/b/c.txt', '*/b/!(cc).txt', { bash: true, windows: true })); + assert( + isMatch('a/b/c.txt', '*/b/!(cc).txt', { bash: true, windows: true }) + ); }); it('"a/b/cc.txt" should not match "*/b/!(*).txt"', () => { - assert(!isMatch('a/b/cc.txt', '*/b/!(*).txt', { bash: true, windows: true })); + assert( + !isMatch('a/b/cc.txt', '*/b/!(*).txt', { bash: true, windows: true }) + ); }); it('"a/b/cc.txt" should not match "*/b/!(c).txt"', () => { - assert(!isMatch('a/b/cc.txt', '*/b/!(c).txt', { bash: true, windows: true })); + assert( + !isMatch('a/b/cc.txt', '*/b/!(c).txt', { bash: true, windows: true }) + ); }); it('"a/b/cc.txt" should not match "*/b/!(cc).txt"', () => { - assert(!isMatch('a/b/cc.txt', '*/b/!(cc).txt', { bash: true, windows: true })); + assert( + !isMatch('a/b/cc.txt', '*/b/!(cc).txt', { bash: true, windows: true }) + ); }); it('"a/dir/foo.txt" should match "*/dir/**/!(bar).txt"', () => { - assert(isMatch('a/dir/foo.txt', '*/dir/**/!(bar).txt', { bash: true, windows: true })); + assert( + isMatch('a/dir/foo.txt', '*/dir/**/!(bar).txt', { + bash: true, + windows: true + }) + ); }); it('"a/z" should not match "a/!(z)"', () => { @@ -838,11 +911,15 @@ describe('extglobs (bash)', () => { }); it('"ab/cXd/efXg/hi" should match "**/*X*/**/*i"', () => { - assert(isMatch('ab/cXd/efXg/hi', '**/*X*/**/*i', { bash: true, windows: true })); + assert( + isMatch('ab/cXd/efXg/hi', '**/*X*/**/*i', { bash: true, windows: true }) + ); }); it('"ab/cXd/efXg/hi" should match "*/*X*/*/*i"', () => { - assert(isMatch('ab/cXd/efXg/hi', '*/*X*/*/*i', { bash: true, windows: true })); + assert( + isMatch('ab/cXd/efXg/hi', '*/*X*/*/*i', { bash: true, windows: true }) + ); }); it('"ab/cXd/efXg/hi" should match "*X*i"', () => { @@ -938,11 +1015,23 @@ describe('extglobs (bash)', () => { }); it('"abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt" should match "**/*a*b*g*n*t"', () => { - assert(isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt', '**/*a*b*g*n*t', { bash: true, windows: true })); + assert( + isMatch( + 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt', + '**/*a*b*g*n*t', + { bash: true, windows: true } + ) + ); }); it('"abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz" should not match "**/*a*b*g*n*t"', () => { - assert(!isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz', '**/*a*b*g*n*t', { bash: true, windows: true })); + assert( + !isMatch( + 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz', + '**/*a*b*g*n*t', + { bash: true, windows: true } + ) + ); }); it('"abcdef" should match "(a+|b)*"', () => { @@ -958,7 +1047,9 @@ describe('extglobs (bash)', () => { }); it('"abcdef" should not match "a(b*(foo|bar))d"', () => { - assert(!isMatch('abcdef', 'a(b*(foo|bar))d', { bash: true, windows: true })); + assert( + !isMatch('abcdef', 'a(b*(foo|bar))d', { bash: true, windows: true }) + ); }); it('"abcdef" should not match "ab*(e|f)"', () => { @@ -1006,7 +1097,9 @@ describe('extglobs (bash)', () => { }); it('"abcfef" should not match "a(b*(foo|bar))d"', () => { - assert(!isMatch('abcfef', 'a(b*(foo|bar))d', { bash: true, windows: true })); + assert( + !isMatch('abcfef', 'a(b*(foo|bar))d', { bash: true, windows: true }) + ); }); it('"abcfef" should not match "ab*(e|f)"', () => { @@ -1054,7 +1147,9 @@ describe('extglobs (bash)', () => { }); it('"abcfefg" should not match "a(b*(foo|bar))d"', () => { - assert(!isMatch('abcfefg', 'a(b*(foo|bar))d', { bash: true, windows: true })); + assert( + !isMatch('abcfefg', 'a(b*(foo|bar))d', { bash: true, windows: true }) + ); }); it('"abcfefg" should not match "ab*(e|f)"', () => { @@ -1306,7 +1401,9 @@ describe('extglobs (bash)', () => { }); it('"accdef" should not match "a(b*(foo|bar))d"', () => { - assert(!isMatch('accdef', 'a(b*(foo|bar))d', { bash: true, windows: true })); + assert( + !isMatch('accdef', 'a(b*(foo|bar))d', { bash: true, windows: true }) + ); }); it('"accdef" should not match "ab*(e|f)"', () => { @@ -1658,7 +1755,12 @@ describe('extglobs (bash)', () => { }); it('"c.c" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert(!isMatch('c.c', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); + assert( + !isMatch('c.c', '*.(a|b|@(ab|a*@(b))*(c)d)', { + bash: true, + windows: true + }) + ); }); it('"c.ccc" should match "!(*.[a-b]*)"', () => { @@ -1834,7 +1936,12 @@ describe('extglobs (bash)', () => { }); it('"d.d" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert(!isMatch('d.d', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); + assert( + !isMatch('d.d', '*.(a|b|@(ab|a*@(b))*(c)d)', { + bash: true, + windows: true + }) + ); }); it('"d.js.d" should match "!(*.js)"', () => { @@ -1874,7 +1981,12 @@ describe('extglobs (bash)', () => { }); it('"e.e" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert(!isMatch('e.e', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); + assert( + !isMatch('e.e', '*.(a|b|@(ab|a*@(b))*(c)d)', { + bash: true, + windows: true + }) + ); }); it('"ef" should match "()ef"', () => { @@ -1882,23 +1994,48 @@ describe('extglobs (bash)', () => { }); it('"effgz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { - assert(isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { bash: true, windows: true })); + assert( + isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { + bash: true, + windows: true + }) + ); }); it('"efgz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { - assert(isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { bash: true, windows: true })); + assert( + isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { + bash: true, + windows: true + }) + ); }); it('"egz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { - assert(isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { bash: true, windows: true })); + assert( + isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { + bash: true, + windows: true + }) + ); }); it('"egz" should not match "@(b+(c)d|e+(f)g?|?(h)i@(j|k))"', () => { - assert(!isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))', { bash: true, windows: true })); + assert( + !isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))', { + bash: true, + windows: true + }) + ); }); it('"egzefffgzbcdij" should match "*(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { - assert(isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { bash: true, windows: true })); + assert( + isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { + bash: true, + windows: true + }) + ); }); it('"f" should not match "!(f!(o))"', () => { @@ -1946,7 +2083,12 @@ describe('extglobs (bash)', () => { }); it('"f.f" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert(!isMatch('f.f', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); + assert( + !isMatch('f.f', '*.(a|b|@(ab|a*@(b))*(c)d)', { + bash: true, + windows: true + }) + ); }); it('"fa" should not match "!(f!(o))"', () => { @@ -1978,7 +2120,12 @@ describe('extglobs (bash)', () => { }); it('"fffooofoooooffoofffooofff" should match "*(*(f)*(o))"', () => { - assert(isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { bash: true, windows: true })); + assert( + isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { + bash: true, + windows: true + }) + ); }); it('"ffo" should match "*(f*(o))"', () => { @@ -2014,11 +2161,15 @@ describe('extglobs (bash)', () => { }); it('"fofoofoofofoo" should match "*(fo|foo)"', () => { - assert(isMatch('fofoofoofofoo', '*(fo|foo)', { bash: true, windows: true })); + assert( + isMatch('fofoofoofofoo', '*(fo|foo)', { bash: true, windows: true }) + ); }); it('"fofoofoofofoo" should match "*(fo|foo)"', () => { - assert(isMatch('fofoofoofofoo', '*(fo|foo)', { bash: true, windows: true })); + assert( + isMatch('fofoofoofofoo', '*(fo|foo)', { bash: true, windows: true }) + ); }); it('"foo" should match "!(!(foo))"', () => { @@ -2154,7 +2305,9 @@ describe('extglobs (bash)', () => { }); it('"foo.js.js" should not match "*.!(js)*.!(js)"', () => { - assert(!isMatch('foo.js.js', '*.!(js)*.!(js)', { bash: true, windows: true })); + assert( + !isMatch('foo.js.js', '*.!(js)*.!(js)', { bash: true, windows: true }) + ); }); it('"foo.js.js" should not match "*.!(js)+"', () => { @@ -2190,11 +2343,21 @@ describe('extglobs (bash)', () => { }); it('"foo/bar/baz.jsx" should match "foo/bar/**/*.+(js|jsx)"', () => { - assert(isMatch('foo/bar/baz.jsx', 'foo/bar/**/*.+(js|jsx)', { bash: true, windows: true })); + assert( + isMatch('foo/bar/baz.jsx', 'foo/bar/**/*.+(js|jsx)', { + bash: true, + windows: true + }) + ); }); it('"foo/bar/baz.jsx" should match "foo/bar/*.+(js|jsx)"', () => { - assert(isMatch('foo/bar/baz.jsx', 'foo/bar/*.+(js|jsx)', { bash: true, windows: true })); + assert( + isMatch('foo/bar/baz.jsx', 'foo/bar/*.+(js|jsx)', { + bash: true, + windows: true + }) + ); }); it('"foo/bb/aa/rr" should match "**/**/**"', () => { @@ -2290,11 +2453,21 @@ describe('extglobs (bash)', () => { }); it('"foofoofo" should match "@(foo|f|fo)*(f|of+(o))"', () => { - assert(isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))', { bash: true, windows: true })); + assert( + isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))', { + bash: true, + windows: true + }) + ); }); it('"foofoofo" should match "@(foo|f|fo)*(f|of+(o))"', () => { - assert(isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))', { bash: true, windows: true })); + assert( + isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))', { + bash: true, + windows: true + }) + ); }); it('"fooofoofofooo" should match "*(f*(o))"', () => { @@ -2318,15 +2491,21 @@ describe('extglobs (bash)', () => { }); it('"foooxfooxfoxfooox" should match "*(f*(o)x)"', () => { - assert(isMatch('foooxfooxfoxfooox', '*(f*(o)x)', { bash: true, windows: true })); + assert( + isMatch('foooxfooxfoxfooox', '*(f*(o)x)', { bash: true, windows: true }) + ); }); it('"foooxfooxfxfooox" should match "*(f*(o)x)"', () => { - assert(isMatch('foooxfooxfxfooox', '*(f*(o)x)', { bash: true, windows: true })); + assert( + isMatch('foooxfooxfxfooox', '*(f*(o)x)', { bash: true, windows: true }) + ); }); it('"foooxfooxofoxfooox" should not match "*(f*(o)x)"', () => { - assert(!isMatch('foooxfooxofoxfooox', '*(f*(o)x)', { bash: true, windows: true })); + assert( + !isMatch('foooxfooxofoxfooox', '*(f*(o)x)', { bash: true, windows: true }) + ); }); it('"foot" should match "@(!(z*)|*x)"', () => { @@ -2362,7 +2541,9 @@ describe('extglobs (bash)', () => { }); it('"mad.moo.cow" should not match "!(*.*).!(*.*)"', () => { - assert(!isMatch('mad.moo.cow', '!(*.*).!(*.*)', { bash: true, windows: true })); + assert( + !isMatch('mad.moo.cow', '!(*.*).!(*.*)', { bash: true, windows: true }) + ); }); it('"mad.moo.cow" should not match ".!(*.*)"', () => { @@ -2370,11 +2551,21 @@ describe('extglobs (bash)', () => { }); it('"Makefile" should match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert(isMatch('Makefile', '!(*.c|*.h|Makefile.in|config*|README)', { bash: true, windows: true })); + assert( + isMatch('Makefile', '!(*.c|*.h|Makefile.in|config*|README)', { + bash: true, + windows: true + }) + ); }); it('"Makefile.in" should not match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert(!isMatch('Makefile.in', '!(*.c|*.h|Makefile.in|config*|README)', { bash: true, windows: true })); + assert( + !isMatch('Makefile.in', '!(*.c|*.h|Makefile.in|config*|README)', { + bash: true, + windows: true + }) + ); }); it('"moo" should match "!(*.*)"', () => { @@ -2402,7 +2593,12 @@ describe('extglobs (bash)', () => { }); it('"mucca.pazza" should not match "mu!(*(c))?.pa!(*(z))?"', () => { - assert(!isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?', { bash: true, windows: true })); + assert( + !isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?', { + bash: true, + windows: true + }) + ); }); it('"ofoofo" should match "*(of+(o))"', () => { @@ -2414,31 +2610,57 @@ describe('extglobs (bash)', () => { }); it('"ofooofoofofooo" should not match "*(f*(o))"', () => { - assert(!isMatch('ofooofoofofooo', '*(f*(o))', { bash: true, windows: true })); + assert( + !isMatch('ofooofoofofooo', '*(f*(o))', { bash: true, windows: true }) + ); }); it('"ofoooxoofxo" should match "*(*(of*(o)x)o)"', () => { - assert(isMatch('ofoooxoofxo', '*(*(of*(o)x)o)', { bash: true, windows: true })); + assert( + isMatch('ofoooxoofxo', '*(*(of*(o)x)o)', { bash: true, windows: true }) + ); }); it('"ofoooxoofxoofoooxoofxo" should match "*(*(of*(o)x)o)"', () => { - assert(isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { bash: true, windows: true })); + assert( + isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { + bash: true, + windows: true + }) + ); }); it('"ofoooxoofxoofoooxoofxofo" should not match "*(*(of*(o)x)o)"', () => { - assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { bash: true, windows: true })); + assert( + !isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { + bash: true, + windows: true + }) + ); }); it('"ofoooxoofxoofoooxoofxoo" should match "*(*(of*(o)x)o)"', () => { - assert(isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { bash: true, windows: true })); + assert( + isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { + bash: true, + windows: true + }) + ); }); it('"ofoooxoofxoofoooxoofxooofxofxo" should match "*(*(of*(o)x)o)"', () => { - assert(isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { bash: true, windows: true })); + assert( + isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { + bash: true, + windows: true + }) + ); }); it('"ofxoofxo" should match "*(*(of*(o)x)o)"', () => { - assert(isMatch('ofxoofxo', '*(*(of*(o)x)o)', { bash: true, windows: true })); + assert( + isMatch('ofxoofxo', '*(*(of*(o)x)o)', { bash: true, windows: true }) + ); }); it('"oofooofo" should match "*(of|oof+(o))"', () => { @@ -2474,19 +2696,30 @@ describe('extglobs (bash)', () => { }); it('"para.38" should match "para!(*.[00-09])"', () => { - assert(isMatch('para.38', 'para!(*.[00-09])', { bash: true, windows: true })); + assert( + isMatch('para.38', 'para!(*.[00-09])', { bash: true, windows: true }) + ); }); it('"para.graph" should match "para!(*.[0-9])"', () => { - assert(isMatch('para.graph', 'para!(*.[0-9])', { bash: true, windows: true })); + assert( + isMatch('para.graph', 'para!(*.[0-9])', { bash: true, windows: true }) + ); }); it('"para13829383746592" should match "para*([0-9])"', () => { - assert(isMatch('para13829383746592', 'para*([0-9])', { bash: true, windows: true })); + assert( + isMatch('para13829383746592', 'para*([0-9])', { + bash: true, + windows: true + }) + ); }); it('"para381" should not match "para?([345]|99)1"', () => { - assert(!isMatch('para381', 'para?([345]|99)1', { bash: true, windows: true })); + assert( + !isMatch('para381', 'para?([345]|99)1', { bash: true, windows: true }) + ); }); it('"para39" should match "para!(*.[0-9])"', () => { @@ -2494,63 +2727,105 @@ describe('extglobs (bash)', () => { }); it('"para987346523" should match "para+([0-9])"', () => { - assert(isMatch('para987346523', 'para+([0-9])', { bash: true, windows: true })); + assert( + isMatch('para987346523', 'para+([0-9])', { bash: true, windows: true }) + ); }); it('"para991" should match "para?([345]|99)1"', () => { - assert(isMatch('para991', 'para?([345]|99)1', { bash: true, windows: true })); + assert( + isMatch('para991', 'para?([345]|99)1', { bash: true, windows: true }) + ); }); it('"paragraph" should match "para!(*.[0-9])"', () => { - assert(isMatch('paragraph', 'para!(*.[0-9])', { bash: true, windows: true })); + assert( + isMatch('paragraph', 'para!(*.[0-9])', { bash: true, windows: true }) + ); }); it('"paragraph" should not match "para*([0-9])"', () => { - assert(!isMatch('paragraph', 'para*([0-9])', { bash: true, windows: true })); + assert( + !isMatch('paragraph', 'para*([0-9])', { bash: true, windows: true }) + ); }); it('"paragraph" should match "para@(chute|graph)"', () => { - assert(isMatch('paragraph', 'para@(chute|graph)', { bash: true, windows: true })); + assert( + isMatch('paragraph', 'para@(chute|graph)', { bash: true, windows: true }) + ); }); it('"paramour" should not match "para@(chute|graph)"', () => { - assert(!isMatch('paramour', 'para@(chute|graph)', { bash: true, windows: true })); + assert( + !isMatch('paramour', 'para@(chute|graph)', { bash: true, windows: true }) + ); }); it('"parse.y" should match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert(isMatch('parse.y', '!(*.c|*.h|Makefile.in|config*|README)', { bash: true, windows: true })); + assert( + isMatch('parse.y', '!(*.c|*.h|Makefile.in|config*|README)', { + bash: true, + windows: true + }) + ); }); it('"shell.c" should not match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert(!isMatch('shell.c', '!(*.c|*.h|Makefile.in|config*|README)', { bash: true, windows: true })); + assert( + !isMatch('shell.c', '!(*.c|*.h|Makefile.in|config*|README)', { + bash: true, + windows: true + }) + ); }); it('"VMS.FILE;" should not match "*\\;[1-9]*([0-9])"', () => { - assert(!isMatch('VMS.FILE;', '*\\;[1-9]*([0-9])', { bash: true, windows: true })); + assert( + !isMatch('VMS.FILE;', '*\\;[1-9]*([0-9])', { bash: true, windows: true }) + ); }); it('"VMS.FILE;0" should not match "*\\;[1-9]*([0-9])"', () => { - assert(!isMatch('VMS.FILE;0', '*\\;[1-9]*([0-9])', { bash: true, windows: true })); + assert( + !isMatch('VMS.FILE;0', '*\\;[1-9]*([0-9])', { bash: true, windows: true }) + ); }); it('"VMS.FILE;9" should match "*\\;[1-9]*([0-9])"', () => { - assert(isMatch('VMS.FILE;9', '*\\;[1-9]*([0-9])', { bash: true, windows: true })); + assert( + isMatch('VMS.FILE;9', '*\\;[1-9]*([0-9])', { bash: true, windows: true }) + ); }); it('"VMS.FILE;1" should match "*\\;[1-9]*([0-9])"', () => { - assert(isMatch('VMS.FILE;1', '*\\;[1-9]*([0-9])', { bash: true, windows: true })); + assert( + isMatch('VMS.FILE;1', '*\\;[1-9]*([0-9])', { bash: true, windows: true }) + ); }); it('"VMS.FILE;1" should match "*;[1-9]*([0-9])"', () => { - assert(isMatch('VMS.FILE;1', '*;[1-9]*([0-9])', { bash: true, windows: true })); + assert( + isMatch('VMS.FILE;1', '*;[1-9]*([0-9])', { bash: true, windows: true }) + ); }); it('"VMS.FILE;139" should match "*\\;[1-9]*([0-9])"', () => { - assert(isMatch('VMS.FILE;139', '*\\;[1-9]*([0-9])', { bash: true, windows: true })); + assert( + isMatch('VMS.FILE;139', '*\\;[1-9]*([0-9])', { + bash: true, + windows: true + }) + ); }); it('"VMS.FILE;1N" should not match "*\\;[1-9]*([0-9])"', () => { - assert(!isMatch('VMS.FILE;1N', '*\\;[1-9]*([0-9])', { bash: true, windows: true })); + assert( + !isMatch('VMS.FILE;1N', '*\\;[1-9]*([0-9])', { + bash: true, + windows: true + }) + ); }); it('"xfoooofof" should not match "*(f*(o))"', () => { @@ -2558,11 +2833,23 @@ describe('extglobs (bash)', () => { }); it('"XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1" should match "XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*"', () => { - assert(isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', { bash: true, windows: false })); + assert( + isMatch( + 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1', + 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', + { bash: true, windows: false } + ) + ); }); it('"XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1" should not match "XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*"', () => { - assert(!isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', { bash: true, windows: true })); + assert( + !isMatch( + 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1', + 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', + { bash: true, windows: true } + ) + ); }); it('"z" should match "*(z)"', () => { @@ -2601,4 +2888,3 @@ describe('extglobs (bash)', () => { assert(!isMatch('zz', '(a+|b)*', { bash: true, windows: true })); }); }); - diff --git a/test/extglobs-minimatch.js b/test/extglobs-minimatch.js index 4d480803..ad528ae2 100644 --- a/test/extglobs-minimatch.js +++ b/test/extglobs-minimatch.js @@ -25,19 +25,41 @@ describe('extglobs (minimatch)', () => { }); it('"-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1" should not match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { - assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', { windows: true })); + assert( + !isMatch( + '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1', + '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', + { windows: true } + ) + ); }); it('"-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1" should match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { - assert(isMatch('-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', { windows: true })); + assert( + isMatch( + '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1', + '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', + { windows: true } + ) + ); }); it('"-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1" should not match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { - assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', { windows: true })); + assert( + !isMatch( + '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1', + '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', + { windows: true } + ) + ); }); it('"/dev/udp/129.22.8.102/45" should match "/dev\\/@(tcp|udp)\\/*\\/*"', () => { - assert(isMatch('/dev/udp/129.22.8.102/45', '/dev\\/@(tcp|udp)\\/*\\/*', { windows: true })); + assert( + isMatch('/dev/udp/129.22.8.102/45', '/dev\\/@(tcp|udp)\\/*\\/*', { + windows: true + }) + ); }); it('"/x/y/z" should match "/x/y/z"', () => { @@ -933,11 +955,23 @@ describe('extglobs (minimatch)', () => { }); it('"abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt" should match "**/*a*b*g*n*t"', () => { - assert(isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt', '**/*a*b*g*n*t', { windows: true })); + assert( + isMatch( + 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt', + '**/*a*b*g*n*t', + { windows: true } + ) + ); }); it('"abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz" should not match "**/*a*b*g*n*t"', () => { - assert(!isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz', '**/*a*b*g*n*t', { windows: true })); + assert( + !isMatch( + 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz', + '**/*a*b*g*n*t', + { windows: true } + ) + ); }); it('"abcdef" should match "(a+|b)*"', () => { @@ -1869,7 +1903,9 @@ describe('extglobs (minimatch)', () => { }); it('"effgz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { - assert(isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); + assert( + isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true }) + ); }); it('"efgz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { @@ -1885,7 +1921,11 @@ describe('extglobs (minimatch)', () => { }); it('"egzefffgzbcdij" should match "*(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { - assert(isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); + assert( + isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { + windows: true + }) + ); }); it('"f" should not match "!(f!(o))"', () => { @@ -1965,7 +2005,9 @@ describe('extglobs (minimatch)', () => { }); it('"fffooofoooooffoofffooofff" should match "*(*(f)*(o))"', () => { - assert(isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { windows: true })); + assert( + isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { windows: true }) + ); }); it('"ffo" should match "*(f*(o))"', () => { @@ -2177,11 +2219,15 @@ describe('extglobs (minimatch)', () => { }); it('"foo/bar/baz.jsx" should match "foo/bar/**/*.+(js|jsx)"', () => { - assert(isMatch('foo/bar/baz.jsx', 'foo/bar/**/*.+(js|jsx)', { windows: true })); + assert( + isMatch('foo/bar/baz.jsx', 'foo/bar/**/*.+(js|jsx)', { windows: true }) + ); }); it('"foo/bar/baz.jsx" should match "foo/bar/*.+(js|jsx)"', () => { - assert(isMatch('foo/bar/baz.jsx', 'foo/bar/*.+(js|jsx)', { windows: true })); + assert( + isMatch('foo/bar/baz.jsx', 'foo/bar/*.+(js|jsx)', { windows: true }) + ); }); it('"foo/bb/aa/rr" should match "**/**/**"', () => { @@ -2349,11 +2395,19 @@ describe('extglobs (minimatch)', () => { }); it('"Makefile" should match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert(isMatch('Makefile', '!(*.c|*.h|Makefile.in|config*|README)', { windows: true })); + assert( + isMatch('Makefile', '!(*.c|*.h|Makefile.in|config*|README)', { + windows: true + }) + ); }); it('"Makefile.in" should not match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert(!isMatch('Makefile.in', '!(*.c|*.h|Makefile.in|config*|README)', { windows: true })); + assert( + !isMatch('Makefile.in', '!(*.c|*.h|Makefile.in|config*|README)', { + windows: true + }) + ); }); it('"moo" should match "!(*.*)"', () => { @@ -2401,19 +2455,29 @@ describe('extglobs (minimatch)', () => { }); it('"ofoooxoofxoofoooxoofxo" should match "*(*(of*(o)x)o)"', () => { - assert(isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { windows: true })); + assert( + isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { windows: true }) + ); }); it('"ofoooxoofxoofoooxoofxofo" should not match "*(*(of*(o)x)o)"', () => { - assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { windows: true })); + assert( + !isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { windows: true }) + ); }); it('"ofoooxoofxoofoooxoofxoo" should match "*(*(of*(o)x)o)"', () => { - assert(isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { windows: true })); + assert( + isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { windows: true }) + ); }); it('"ofoooxoofxoofoooxoofxooofxofxo" should match "*(*(of*(o)x)o)"', () => { - assert(isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { windows: true })); + assert( + isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { + windows: true + }) + ); }); it('"ofxoofxo" should match "*(*(of*(o)x)o)"', () => { @@ -2497,11 +2561,19 @@ describe('extglobs (minimatch)', () => { }); it('"parse.y" should match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert(isMatch('parse.y', '!(*.c|*.h|Makefile.in|config*|README)', { windows: true })); + assert( + isMatch('parse.y', '!(*.c|*.h|Makefile.in|config*|README)', { + windows: true + }) + ); }); it('"shell.c" should not match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert(!isMatch('shell.c', '!(*.c|*.h|Makefile.in|config*|README)', { windows: true })); + assert( + !isMatch('shell.c', '!(*.c|*.h|Makefile.in|config*|README)', { + windows: true + }) + ); }); it('"VMS.FILE;" should not match "*\\;[1-9]*([0-9])"', () => { @@ -2533,11 +2605,23 @@ describe('extglobs (minimatch)', () => { }); it('"XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1" should match "XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*"', () => { - assert(isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', { windows: false })); + assert( + isMatch( + 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1', + 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', + { windows: false } + ) + ); }); it('"XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1" should not match "XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*"', () => { - assert(!isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', { windows: true })); + assert( + !isMatch( + 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1', + 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', + { windows: true } + ) + ); }); it('"z" should match "*(z)"', () => { diff --git a/test/extglobs-temp.js b/test/extglobs-temp.js index b62948f2..cd70d831 100644 --- a/test/extglobs-temp.js +++ b/test/extglobs-temp.js @@ -356,7 +356,9 @@ describe('extglobs', () => { assert(!isMatch('xx', 'foo/!(foo)', { windows: true })); assert(!isMatch('ffffffo', '(foo)bb', { windows: true })); - assert(!isMatch('fffooofoooooffoofffooofff', '(foo)bb', { windows: true })); + assert( + !isMatch('fffooofoooooffoofffooofff', '(foo)bb', { windows: true }) + ); assert(!isMatch('ffo', '(foo)bb', { windows: true })); assert(!isMatch('fofo', '(foo)bb', { windows: true })); assert(!isMatch('fofoofoofofoo', '(foo)bb', { windows: true })); @@ -377,9 +379,13 @@ describe('extglobs', () => { assert(!isMatch('ofooofoofofooo', '(foo)bb', { windows: true })); assert(!isMatch('ofoooxoofxo', '(foo)bb', { windows: true })); assert(!isMatch('ofoooxoofxoofoooxoofxo', '(foo)bb', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxofo', '(foo)bb', { windows: true })); + assert( + !isMatch('ofoooxoofxoofoooxoofxofo', '(foo)bb', { windows: true }) + ); assert(!isMatch('ofoooxoofxoofoooxoofxoo', '(foo)bb', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '(foo)bb', { windows: true })); + assert( + !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '(foo)bb', { windows: true }) + ); assert(!isMatch('ofxoofxo', '(foo)bb', { windows: true })); assert(!isMatch('oofooofo', '(foo)bb', { windows: true })); assert(!isMatch('ooo', '(foo)bb', { windows: true })); @@ -388,7 +394,9 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '(foo)bb', { windows: true })); assert(isMatch('ffffffo', '*(*(f)*(o))', { windows: true })); - assert(isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { windows: true })); + assert( + isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { windows: true }) + ); assert(isMatch('ffo', '*(*(f)*(o))', { windows: true })); assert(isMatch('fofo', '*(*(f)*(o))', { windows: true })); assert(isMatch('fofoofoofofoo', '*(*(f)*(o))', { windows: true })); @@ -408,10 +416,20 @@ describe('extglobs', () => { assert(isMatch('ofoofo', '*(*(f)*(o))', { windows: true })); assert(isMatch('ofooofoofofooo', '*(*(f)*(o))', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(*(f)*(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(*(f)*(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(*(f)*(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(*(f)*(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(f)*(o))', { windows: true })); + assert( + !isMatch('ofoooxoofxoofoooxoofxo', '*(*(f)*(o))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxofo', '*(*(f)*(o))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxoo', '*(*(f)*(o))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(f)*(o))', { + windows: true + }) + ); assert(!isMatch('ofxoofxo', '*(*(f)*(o))', { windows: true })); assert(isMatch('oofooofo', '*(*(f)*(o))', { windows: true })); assert(isMatch('ooo', '*(*(f)*(o))', { windows: true })); @@ -420,7 +438,11 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(*(f)*(o))', { windows: true })); assert(!isMatch('ffffffo', '*(*(of*(o)x)o)', { windows: true })); - assert(!isMatch('fffooofoooooffoofffooofff', '*(*(of*(o)x)o)', { windows: true })); + assert( + !isMatch('fffooofoooooffoofffooofff', '*(*(of*(o)x)o)', { + windows: true + }) + ); assert(!isMatch('ffo', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('fofo', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('fofoofoofofoo', '*(*(of*(o)x)o)', { windows: true })); @@ -432,18 +454,34 @@ describe('extglobs', () => { assert(!isMatch('foooofo', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('foooofof', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('foooofofx', '*(*(of*(o)x)o)', { windows: true })); - assert(!isMatch('foooxfooxfoxfooox', '*(*(of*(o)x)o)', { windows: true })); + assert( + !isMatch('foooxfooxfoxfooox', '*(*(of*(o)x)o)', { windows: true }) + ); assert(!isMatch('foooxfooxfxfooox', '*(*(of*(o)x)o)', { windows: true })); - assert(!isMatch('foooxfooxofoxfooox', '*(*(of*(o)x)o)', { windows: true })); + assert( + !isMatch('foooxfooxofoxfooox', '*(*(of*(o)x)o)', { windows: true }) + ); assert(!isMatch('foot', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('foox', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('ofoofo', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('ofooofoofofooo', '*(*(of*(o)x)o)', { windows: true })); assert(isMatch('ofoooxoofxo', '*(*(of*(o)x)o)', { windows: true })); - assert(isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { windows: true })); - assert(isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { windows: true })); - assert(isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { windows: true })); + assert( + isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { + windows: true + }) + ); + assert( + isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { windows: true }) + ); + assert( + isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { + windows: true + }) + ); assert(isMatch('ofxoofxo', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('oofooofo', '*(*(of*(o)x)o)', { windows: true })); assert(isMatch('ooo', '*(*(of*(o)x)o)', { windows: true })); @@ -452,7 +490,9 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(*(of*(o)x)o)', { windows: true })); assert(isMatch('ffffffo', '*(f*(o))', { windows: true })); - assert(isMatch('fffooofoooooffoofffooofff', '*(f*(o))', { windows: true })); + assert( + isMatch('fffooofoooooffoofffooofff', '*(f*(o))', { windows: true }) + ); assert(isMatch('ffo', '*(f*(o))', { windows: true })); assert(isMatch('fofo', '*(f*(o))', { windows: true })); assert(isMatch('fofoofoofofoo', '*(f*(o))', { windows: true })); @@ -473,9 +513,17 @@ describe('extglobs', () => { assert(!isMatch('ofooofoofofooo', '*(f*(o))', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(f*(o))', { windows: true })); assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(f*(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(f*(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(f*(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(f*(o))', { windows: true })); + assert( + !isMatch('ofoooxoofxoofoooxoofxofo', '*(f*(o))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxoo', '*(f*(o))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(f*(o))', { + windows: true + }) + ); assert(!isMatch('ofxoofxo', '*(f*(o))', { windows: true })); assert(!isMatch('oofooofo', '*(f*(o))', { windows: true })); assert(!isMatch('ooo', '*(f*(o))', { windows: true })); @@ -484,7 +532,9 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(f*(o))', { windows: true })); assert(!isMatch('ffffffo', '*(f*(o)x)', { windows: true })); - assert(!isMatch('fffooofoooooffoofffooofff', '*(f*(o)x)', { windows: true })); + assert( + !isMatch('fffooofoooooffoofffooofff', '*(f*(o)x)', { windows: true }) + ); assert(!isMatch('ffo', '*(f*(o)x)', { windows: true })); assert(!isMatch('fofo', '*(f*(o)x)', { windows: true })); assert(!isMatch('fofoofoofofoo', '*(f*(o)x)', { windows: true })); @@ -504,10 +554,20 @@ describe('extglobs', () => { assert(!isMatch('ofoofo', '*(f*(o)x)', { windows: true })); assert(!isMatch('ofooofoofofooo', '*(f*(o)x)', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(f*(o)x)', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(f*(o)x)', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(f*(o)x)', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(f*(o)x)', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(f*(o)x)', { windows: true })); + assert( + !isMatch('ofoooxoofxoofoooxoofxo', '*(f*(o)x)', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxofo', '*(f*(o)x)', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxoo', '*(f*(o)x)', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(f*(o)x)', { + windows: true + }) + ); assert(!isMatch('ofxoofxo', '*(f*(o)x)', { windows: true })); assert(!isMatch('oofooofo', '*(f*(o)x)', { windows: true })); assert(!isMatch('ooo', '*(f*(o)x)', { windows: true })); @@ -516,7 +576,9 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(f*(o)x)', { windows: true })); assert(!isMatch('ffffffo', '*(f+(o))', { windows: true })); - assert(!isMatch('fffooofoooooffoofffooofff', '*(f+(o))', { windows: true })); + assert( + !isMatch('fffooofoooooffoofffooofff', '*(f+(o))', { windows: true }) + ); assert(!isMatch('ffo', '*(f+(o))', { windows: true })); assert(isMatch('fofo', '*(f+(o))', { windows: true })); assert(isMatch('fofoofoofofoo', '*(f+(o))', { windows: true })); @@ -537,9 +599,17 @@ describe('extglobs', () => { assert(!isMatch('ofooofoofofooo', '*(f+(o))', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(f+(o))', { windows: true })); assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(f+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(f+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(f+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(f+(o))', { windows: true })); + assert( + !isMatch('ofoooxoofxoofoooxoofxofo', '*(f+(o))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxoo', '*(f+(o))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(f+(o))', { + windows: true + }) + ); assert(!isMatch('ofxoofxo', '*(f+(o))', { windows: true })); assert(!isMatch('oofooofo', '*(f+(o))', { windows: true })); assert(!isMatch('ooo', '*(f+(o))', { windows: true })); @@ -548,7 +618,9 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(f+(o))', { windows: true })); assert(!isMatch('ffffffo', '*(of+(o))', { windows: true })); - assert(!isMatch('fffooofoooooffoofffooofff', '*(of+(o))', { windows: true })); + assert( + !isMatch('fffooofoooooffoofffooofff', '*(of+(o))', { windows: true }) + ); assert(!isMatch('ffo', '*(of+(o))', { windows: true })); assert(!isMatch('fofo', '*(of+(o))', { windows: true })); assert(!isMatch('fofoofoofofoo', '*(of+(o))', { windows: true })); @@ -568,10 +640,20 @@ describe('extglobs', () => { assert(isMatch('ofoofo', '*(of+(o))', { windows: true })); assert(!isMatch('ofooofoofofooo', '*(of+(o))', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(of+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(of+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(of+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(of+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(of+(o))', { windows: true })); + assert( + !isMatch('ofoooxoofxoofoooxoofxo', '*(of+(o))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxofo', '*(of+(o))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxoo', '*(of+(o))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(of+(o))', { + windows: true + }) + ); assert(!isMatch('ofxoofxo', '*(of+(o))', { windows: true })); assert(!isMatch('oofooofo', '*(of+(o))', { windows: true })); assert(!isMatch('ooo', '*(of+(o))', { windows: true })); @@ -580,7 +662,9 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(of+(o))', { windows: true })); assert(!isMatch('ffffffo', '*(of+(o)|f)', { windows: true })); - assert(!isMatch('fffooofoooooffoofffooofff', '*(of+(o)|f)', { windows: true })); + assert( + !isMatch('fffooofoooooffoofffooofff', '*(of+(o)|f)', { windows: true }) + ); assert(!isMatch('ffo', '*(of+(o)|f)', { windows: true })); assert(isMatch('fofo', '*(of+(o)|f)', { windows: true })); assert(isMatch('fofoofoofofoo', '*(of+(o)|f)', { windows: true })); @@ -600,10 +684,20 @@ describe('extglobs', () => { assert(isMatch('ofoofo', '*(of+(o)|f)', { windows: true })); assert(isMatch('ofooofoofofooo', '*(of+(o)|f)', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(of+(o)|f)', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(of+(o)|f)', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(of+(o)|f)', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(of+(o)|f)', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(of+(o)|f)', { windows: true })); + assert( + !isMatch('ofoooxoofxoofoooxoofxo', '*(of+(o)|f)', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxofo', '*(of+(o)|f)', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxoo', '*(of+(o)|f)', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(of+(o)|f)', { + windows: true + }) + ); assert(!isMatch('ofxoofxo', '*(of+(o)|f)', { windows: true })); assert(!isMatch('oofooofo', '*(of+(o)|f)', { windows: true })); assert(!isMatch('ooo', '*(of+(o)|f)', { windows: true })); @@ -612,7 +706,11 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(of+(o)|f)', { windows: true })); assert(!isMatch('ffffffo', '*(of|oof+(o))', { windows: true })); - assert(!isMatch('fffooofoooooffoofffooofff', '*(of|oof+(o))', { windows: true })); + assert( + !isMatch('fffooofoooooffoofffooofff', '*(of|oof+(o))', { + windows: true + }) + ); assert(!isMatch('ffo', '*(of|oof+(o))', { windows: true })); assert(!isMatch('fofo', '*(of|oof+(o))', { windows: true })); assert(!isMatch('fofoofoofofoo', '*(of|oof+(o))', { windows: true })); @@ -626,16 +724,28 @@ describe('extglobs', () => { assert(!isMatch('foooofofx', '*(of|oof+(o))', { windows: true })); assert(!isMatch('foooxfooxfoxfooox', '*(of|oof+(o))', { windows: true })); assert(!isMatch('foooxfooxfxfooox', '*(of|oof+(o))', { windows: true })); - assert(!isMatch('foooxfooxofoxfooox', '*(of|oof+(o))', { windows: true })); + assert( + !isMatch('foooxfooxofoxfooox', '*(of|oof+(o))', { windows: true }) + ); assert(!isMatch('foot', '*(of|oof+(o))', { windows: true })); assert(!isMatch('foox', '*(of|oof+(o))', { windows: true })); assert(isMatch('ofoofo', '*(of|oof+(o))', { windows: true })); assert(!isMatch('ofooofoofofooo', '*(of|oof+(o))', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(of|oof+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(of|oof+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(of|oof+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(of|oof+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(of|oof+(o))', { windows: true })); + assert( + !isMatch('ofoooxoofxoofoooxoofxo', '*(of|oof+(o))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxofo', '*(of|oof+(o))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxoo', '*(of|oof+(o))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(of|oof+(o))', { + windows: true + }) + ); assert(!isMatch('ofxoofxo', '*(of|oof+(o))', { windows: true })); assert(isMatch('oofooofo', '*(of|oof+(o))', { windows: true })); assert(!isMatch('ooo', '*(of|oof+(o))', { windows: true })); @@ -644,7 +754,9 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(of|oof+(o))', { windows: true })); assert(!isMatch('ffffffo', '*(oxf+(ox))', { windows: true })); - assert(!isMatch('fffooofoooooffoofffooofff', '*(oxf+(ox))', { windows: true })); + assert( + !isMatch('fffooofoooooffoofffooofff', '*(oxf+(ox))', { windows: true }) + ); assert(!isMatch('ffo', '*(oxf+(ox))', { windows: true })); assert(!isMatch('fofo', '*(oxf+(ox))', { windows: true })); assert(!isMatch('fofoofoofofoo', '*(oxf+(ox))', { windows: true })); @@ -664,10 +776,20 @@ describe('extglobs', () => { assert(!isMatch('ofoofo', '*(oxf+(ox))', { windows: true })); assert(!isMatch('ofooofoofofooo', '*(oxf+(ox))', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(oxf+(ox))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(oxf+(ox))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(oxf+(ox))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(oxf+(ox))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(oxf+(ox))', { windows: true })); + assert( + !isMatch('ofoooxoofxoofoooxoofxo', '*(oxf+(ox))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxofo', '*(oxf+(ox))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxoo', '*(oxf+(ox))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(oxf+(ox))', { + windows: true + }) + ); assert(!isMatch('ofxoofxo', '*(oxf+(ox))', { windows: true })); assert(!isMatch('oofooofo', '*(oxf+(ox))', { windows: true })); assert(!isMatch('ooo', '*(oxf+(ox))', { windows: true })); @@ -676,7 +798,9 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(oxf+(ox))', { windows: true })); assert(isMatch('ffffffo', '@(!(z*)|*x)', { windows: true })); - assert(isMatch('fffooofoooooffoofffooofff', '@(!(z*)|*x)', { windows: true })); + assert( + isMatch('fffooofoooooffoofffooofff', '@(!(z*)|*x)', { windows: true }) + ); assert(isMatch('ffo', '@(!(z*)|*x)', { windows: true })); assert(isMatch('fofo', '@(!(z*)|*x)', { windows: true })); assert(isMatch('fofoofoofofoo', '@(!(z*)|*x)', { windows: true })); @@ -696,10 +820,20 @@ describe('extglobs', () => { assert(isMatch('ofoofo', '@(!(z*)|*x)', { windows: true })); assert(isMatch('ofooofoofofooo', '@(!(z*)|*x)', { windows: true })); assert(isMatch('ofoooxoofxo', '@(!(z*)|*x)', { windows: true })); - assert(isMatch('ofoooxoofxoofoooxoofxo', '@(!(z*)|*x)', { windows: true })); - assert(isMatch('ofoooxoofxoofoooxoofxofo', '@(!(z*)|*x)', { windows: true })); - assert(isMatch('ofoooxoofxoofoooxoofxoo', '@(!(z*)|*x)', { windows: true })); - assert(isMatch('ofoooxoofxoofoooxoofxooofxofxo', '@(!(z*)|*x)', { windows: true })); + assert( + isMatch('ofoooxoofxoofoooxoofxo', '@(!(z*)|*x)', { windows: true }) + ); + assert( + isMatch('ofoooxoofxoofoooxoofxofo', '@(!(z*)|*x)', { windows: true }) + ); + assert( + isMatch('ofoooxoofxoofoooxoofxoo', '@(!(z*)|*x)', { windows: true }) + ); + assert( + isMatch('ofoooxoofxoofoooxoofxooofxofxo', '@(!(z*)|*x)', { + windows: true + }) + ); assert(isMatch('ofxoofxo', '@(!(z*)|*x)', { windows: true })); assert(isMatch('oofooofo', '@(!(z*)|*x)', { windows: true })); assert(isMatch('ooo', '@(!(z*)|*x)', { windows: true })); @@ -708,36 +842,82 @@ describe('extglobs', () => { assert(isMatch('xfoooofof', '@(!(z*)|*x)', { windows: true })); assert(!isMatch('ffffffo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert(!isMatch('fffooofoooooffoofffooofff', '@(foo|f|fo)*(f|of+(o))', { windows: true })); + assert( + !isMatch('fffooofoooooffoofffooofff', '@(foo|f|fo)*(f|of+(o))', { + windows: true + }) + ); assert(!isMatch('ffo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(isMatch('fofo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert(isMatch('fofoofoofofoo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); + assert( + isMatch('fofoofoofofoo', '@(foo|f|fo)*(f|of+(o))', { windows: true }) + ); assert(isMatch('foo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('foob', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('foobb', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert(isMatch('fooofoofofooo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); + assert( + isMatch('fooofoofofooo', '@(foo|f|fo)*(f|of+(o))', { windows: true }) + ); assert(!isMatch('foooofo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('foooofof', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert(!isMatch('foooofofx', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert(!isMatch('foooxfooxfoxfooox', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert(!isMatch('foooxfooxfxfooox', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert(!isMatch('foooxfooxofoxfooox', '@(foo|f|fo)*(f|of+(o))', { windows: true })); + assert( + !isMatch('foooofofx', '@(foo|f|fo)*(f|of+(o))', { windows: true }) + ); + assert( + !isMatch('foooxfooxfoxfooox', '@(foo|f|fo)*(f|of+(o))', { + windows: true + }) + ); + assert( + !isMatch('foooxfooxfxfooox', '@(foo|f|fo)*(f|of+(o))', { + windows: true + }) + ); + assert( + !isMatch('foooxfooxofoxfooox', '@(foo|f|fo)*(f|of+(o))', { + windows: true + }) + ); assert(!isMatch('foot', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('foox', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('ofoofo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert(!isMatch('ofooofoofofooo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxofo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxoo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); + assert( + !isMatch('ofooofoofofooo', '@(foo|f|fo)*(f|of+(o))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxo', '@(foo|f|fo)*(f|of+(o))', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxo', '@(foo|f|fo)*(f|of+(o))', { + windows: true + }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxofo', '@(foo|f|fo)*(f|of+(o))', { + windows: true + }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxoo', '@(foo|f|fo)*(f|of+(o))', { + windows: true + }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '@(foo|f|fo)*(f|of+(o))', { + windows: true + }) + ); assert(!isMatch('ofxoofxo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('oofooofo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('ooo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('oxfoxfox', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert(!isMatch('oxfoxoxfox', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert(!isMatch('xfoooofof', '@(foo|f|fo)*(f|of+(o))', { windows: true })); + assert( + !isMatch('oxfoxoxfox', '@(foo|f|fo)*(f|of+(o))', { windows: true }) + ); + assert( + !isMatch('xfoooofof', '@(foo|f|fo)*(f|of+(o))', { windows: true }) + ); assert(isMatch('aaac', '*(@(a))a@(c)', { windows: true })); assert(isMatch('aac', '*(@(a))a@(c)', { windows: true })); @@ -781,14 +961,15 @@ describe('extglobs', () => { assert(!isMatch('aac', '*(@(a))b@(c)', { windows: true })); }); - }); describe('other', () => { it('should support backtracking in alternation matches', () => { assert(isMatch('fofoofoofofoo', '*(fo|foo)', { windows: true })); assert(!isMatch('ffffffo', '*(fo|foo)', { windows: true })); - assert(!isMatch('fffooofoooooffoofffooofff', '*(fo|foo)', { windows: true })); + assert( + !isMatch('fffooofoooooffoofffooofff', '*(fo|foo)', { windows: true }) + ); assert(!isMatch('ffo', '*(fo|foo)', { windows: true })); assert(isMatch('fofo', '*(fo|foo)', { windows: true })); assert(isMatch('fofoofoofofoo', '*(fo|foo)', { windows: true })); @@ -808,10 +989,20 @@ describe('extglobs', () => { assert(!isMatch('ofoofo', '*(fo|foo)', { windows: true })); assert(!isMatch('ofooofoofofooo', '*(fo|foo)', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(fo|foo)', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(fo|foo)', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(fo|foo)', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(fo|foo)', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(fo|foo)', { windows: true })); + assert( + !isMatch('ofoooxoofxoofoooxoofxo', '*(fo|foo)', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxofo', '*(fo|foo)', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxoo', '*(fo|foo)', { windows: true }) + ); + assert( + !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(fo|foo)', { + windows: true + }) + ); assert(!isMatch('ofxoofxo', '*(fo|foo)', { windows: true })); assert(!isMatch('oofooofo', '*(fo|foo)', { windows: true })); assert(!isMatch('ooo', '*(fo|foo)', { windows: true })); @@ -856,17 +1047,35 @@ describe('extglobs', () => { assert(!isMatch('moo', '.!(*.*)', { windows: true })); assert(!isMatch('cow', '.!(*.*)', { windows: true })); - assert(!isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?', { windows: true })); - - assert(isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); - assert(isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); - assert(isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); - assert(!isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))', { windows: true })); - assert(isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); + assert( + !isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?', { windows: true }) + ); + + assert( + isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true }) + ); + assert( + isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true }) + ); + assert( + isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true }) + ); + assert( + !isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))', { windows: true }) + ); + assert( + isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { + windows: true + }) + ); }); it('valid numbers', () => { - assert(isMatch('/dev/udp/129.22.8.102/45', '/dev/@(tcp|udp)/*/*', { windows: true })); + assert( + isMatch('/dev/udp/129.22.8.102/45', '/dev/@(tcp|udp)/*/*', { + windows: true + }) + ); assert(!isMatch('0', '[1-6]([0-9])', { windows: true })); assert(isMatch('12', '[1-6]([0-9])', { windows: true })); @@ -926,7 +1135,11 @@ describe('extglobs', () => { }); it('More tests derived from a bug report (in bash) concerning extended glob patterns following a *', () => { - assert(isMatch('/dev/udp/129.22.8.102/45', '/dev\\/@(tcp|udp)\\/*\\/*', { windows: true })); + assert( + isMatch('/dev/udp/129.22.8.102/45', '/dev\\/@(tcp|udp)\\/*\\/*', { + windows: true + }) + ); assert(!isMatch('123abc', '(a+|b)*', { windows: true })); assert(isMatch('ab', '(a+|b)*', { windows: true })); assert(isMatch('abab', '(a+|b)*', { windows: true })); @@ -1134,8 +1347,12 @@ describe('extglobs', () => { assert(isMatch('a.c', '+([[:alpha:].])+([[:alpha:].])', opts)); assert(isMatch('a.c', '*([[:alpha:].])', opts)); assert(isMatch('a.c', '*([[:alpha:].])*([[:alpha:].])', opts)); - assert(isMatch('a.c', '?([[:alpha:].])?([[:alpha:].])?([[:alpha:].])', opts)); - assert(isMatch('a.c', '@([[:alpha:].])@([[:alpha:].])@([[:alpha:].])', opts)); + assert( + isMatch('a.c', '?([[:alpha:].])?([[:alpha:].])?([[:alpha:].])', opts) + ); + assert( + isMatch('a.c', '@([[:alpha:].])@([[:alpha:].])@([[:alpha:].])', opts) + ); assert(!isMatch('.', '!(\\.)', opts)); assert(!isMatch('.', '!([[:alpha:].])', opts)); assert(isMatch('.', '?([[:alpha:].])', opts)); @@ -1146,12 +1363,18 @@ describe('extglobs', () => { it('should pass extglob2 tests', () => { assert(!isMatch('baaac', '*(@(a))a@(c)', { windows: true })); assert(!isMatch('c', '*(@(a))a@(c)', { windows: true })); - assert(!isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))', { windows: true })); + assert( + !isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))', { windows: true }) + ); assert(!isMatch('foooofof', '*(f+(o))', { windows: true })); assert(!isMatch('foooofofx', '*(f*(o))', { windows: true })); assert(!isMatch('foooxfooxofoxfooox', '*(f*(o)x)', { windows: true })); assert(!isMatch('ofooofoofofooo', '*(f*(o))', { windows: true })); - assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { windows: true })); + assert( + !isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { + windows: true + }) + ); assert(!isMatch('oxfoxfox', '*(oxf+(ox))', { windows: true })); assert(!isMatch('xfoooofof', '*(f*(o))', { windows: true })); assert(isMatch('aaac', '*(@(a))a@(c)', { windows: true })); @@ -1161,11 +1384,23 @@ describe('extglobs', () => { assert(isMatch('abcd', '@(ab|a*@(b))*(c)d', { windows: true })); assert(isMatch('ac', '*(@(a))a@(c)', { windows: true })); assert(isMatch('acd', '@(ab|a*(b))*(c)d', { windows: true })); - assert(isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); - assert(isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); - assert(isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); - assert(isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); - assert(isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { windows: true })); + assert( + isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true }) + ); + assert( + isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true }) + ); + assert( + isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true }) + ); + assert( + isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { + windows: true + }) + ); + assert( + isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { windows: true }) + ); assert(isMatch('ffo', '*(f*(o))', { windows: true })); assert(isMatch('fofo', '*(f*(o))', { windows: true })); assert(isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); @@ -1177,9 +1412,17 @@ describe('extglobs', () => { assert(isMatch('ofoofo', '*(of+(o))', { windows: true })); assert(isMatch('ofoofo', '*(of+(o)|f)', { windows: true })); assert(isMatch('ofoooxoofxo', '*(*(of*(o)x)o)', { windows: true })); - assert(isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { windows: true })); - assert(isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { windows: true })); - assert(isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { windows: true })); + assert( + isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { windows: true }) + ); + assert( + isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { windows: true }) + ); + assert( + isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { + windows: true + }) + ); assert(isMatch('ofxoofxo', '*(*(of*(o)x)o)', { windows: true })); assert(isMatch('oofooofo', '*(of|oof+(o))', { windows: true })); assert(isMatch('oxfoxoxfox', '*(oxf+(ox))', { windows: true })); @@ -1192,7 +1435,9 @@ describe('extglobs', () => { assert(!isMatch('foo', '!(foo)', { windows: true })); assert(!isMatch('foob', '!(foo)b*', { windows: true })); assert(!isMatch('mad.moo.cow', '!(*.*).!(*.*)', { windows: true })); - assert(!isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?', { windows: true })); + assert( + !isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?', { windows: true }) + ); assert(!isMatch('zoot', '@(!(z*)|*x)', { windows: true })); assert(isMatch('fff', '!(f)', { windows: true })); assert(isMatch('fff', '*(!(f))', { windows: true })); @@ -1212,4 +1457,3 @@ describe('extglobs', () => { }); }); }); - diff --git a/test/extglobs.js b/test/extglobs.js index ea436d1f..2dc40a02 100644 --- a/test/extglobs.js +++ b/test/extglobs.js @@ -137,31 +137,31 @@ describe('extglobs', () => { }); it('should support negation extglobs following !', () => { - assert(isMatch('abc', '!!(abc)')); + assert(isMatch('abc', '!!(abc)')); assert(!isMatch('abc', '!!!(abc)')); - assert(isMatch('abc', '!!!!(abc)')); + assert(isMatch('abc', '!!!!(abc)')); assert(!isMatch('abc', '!!!!!(abc)')); - assert(isMatch('abc', '!!!!!!(abc)')); + assert(isMatch('abc', '!!!!!!(abc)')); assert(!isMatch('abc', '!!!!!!!(abc)')); - assert(isMatch('abc', '!!!!!!!!(abc)')); + assert(isMatch('abc', '!!!!!!!!(abc)')); }); it('should support nested negation extglobs', () => { - assert(isMatch('abc', '!(!(abc))')); + assert(isMatch('abc', '!(!(abc))')); assert(!isMatch('abc', '!(!(!(abc)))')); - assert(isMatch('abc', '!(!(!(!(abc))))')); + assert(isMatch('abc', '!(!(!(!(abc))))')); assert(!isMatch('abc', '!(!(!(!(!(abc)))))')); - assert(isMatch('abc', '!(!(!(!(!(!(abc))))))')); + assert(isMatch('abc', '!(!(!(!(!(!(abc))))))')); assert(!isMatch('abc', '!(!(!(!(!(!(!(abc)))))))')); - assert(isMatch('abc', '!(!(!(!(!(!(!(!(abc))))))))')); + assert(isMatch('abc', '!(!(!(!(!(!(!(!(abc))))))))')); - assert(isMatch('foo/abc', 'foo/!(!(abc))')); + assert(isMatch('foo/abc', 'foo/!(!(abc))')); assert(!isMatch('foo/abc', 'foo/!(!(!(abc)))')); - assert(isMatch('foo/abc', 'foo/!(!(!(!(abc))))')); + assert(isMatch('foo/abc', 'foo/!(!(!(!(abc))))')); assert(!isMatch('foo/abc', 'foo/!(!(!(!(!(abc)))))')); - assert(isMatch('foo/abc', 'foo/!(!(!(!(!(!(abc))))))')); + assert(isMatch('foo/abc', 'foo/!(!(!(!(!(!(abc))))))')); assert(!isMatch('foo/abc', 'foo/!(!(!(!(!(!(!(abc)))))))')); - assert(isMatch('foo/abc', 'foo/!(!(!(!(!(!(!(!(abc))))))))')); + assert(isMatch('foo/abc', 'foo/!(!(!(!(!(!(!(!(abc))))))))')); }); it('should support multiple !(...) extglobs in a pattern', () => { @@ -473,7 +473,7 @@ describe('extglobs', () => { assert(isMatch('b.a', '@(b|a).@(a)')); }); - it('should pass tests from rosenblatt\'s korn shell book', () => { + it("should pass tests from rosenblatt's korn shell book", () => { // This one is the only difference, since picomatch does not match empty strings. assert(!isMatch('', '*(0|1|3|5|7|9)')); @@ -550,7 +550,7 @@ describe('extglobs', () => { assert(!isMatch('acd', 'a[b*(foo|bar)]d')); }); - it('stuff from korn\'s book', () => { + it("stuff from korn's book", () => { assert(!isMatch('para', 'para+([0-9])')); assert(!isMatch('para381', 'para?([345]|99)1')); assert(!isMatch('paragraph', 'para*([0-9])')); @@ -748,7 +748,23 @@ describe('extglobs', () => { // these are not extglobs, and do not need to pass, but they are included // to test integration with other features it('should support regex characters', () => { - const fixtures = ['a c', 'a.c', 'a.xy.zc', 'a.zc', 'a123c', 'a1c', 'abbbbc', 'abbbc', 'abbc', 'abc', 'abq', 'axy zc', 'axy', 'axy.zc', 'axyzc']; + const fixtures = [ + 'a c', + 'a.c', + 'a.xy.zc', + 'a.zc', + 'a123c', + 'a1c', + 'abbbbc', + 'abbbc', + 'abbc', + 'abc', + 'abq', + 'axy zc', + 'axy', + 'axy.zc', + 'axyzc' + ]; if (process.platform !== 'win32') { assert.deepStrictEqual(match(['a\\b', 'a/b', 'ab'], 'a/b'), ['a/b']); @@ -756,18 +772,63 @@ describe('extglobs', () => { assert.deepStrictEqual(match(['a/b', 'ab'], 'a/b'), ['a/b']); assert.deepStrictEqual(match(fixtures, 'ab?bc'), ['abbbc']); - assert.deepStrictEqual(match(fixtures, 'ab*c'), ['abbbbc', 'abbbc', 'abbc', 'abc']); - assert.deepStrictEqual(match(fixtures, 'a+(b)bc'), ['abbbbc', 'abbbc', 'abbc']); + assert.deepStrictEqual(match(fixtures, 'ab*c'), [ + 'abbbbc', + 'abbbc', + 'abbc', + 'abc' + ]); + assert.deepStrictEqual(match(fixtures, 'a+(b)bc'), [ + 'abbbbc', + 'abbbc', + 'abbc' + ]); assert.deepStrictEqual(match(fixtures, '^abc$'), []); assert.deepStrictEqual(match(fixtures, 'a.c'), ['a.c']); assert.deepStrictEqual(match(fixtures, 'a.*c'), ['a.c', 'a.xy.zc', 'a.zc']); - assert.deepStrictEqual(match(fixtures, 'a*c'), ['a c', 'a.c', 'a.xy.zc', 'a.zc', 'a123c', 'a1c', 'abbbbc', 'abbbc', 'abbc', 'abc', 'axy zc', 'axy.zc', 'axyzc']); - assert.deepStrictEqual(match(fixtures, 'a[\\w]+c'), ['a123c', 'a1c', 'abbbbc', 'abbbc', 'abbc', 'abc', 'axyzc'], 'Should match word characters'); - assert.deepStrictEqual(match(fixtures, 'a[\\W]+c'), ['a c', 'a.c'], 'Should match non-word characters'); - assert.deepStrictEqual(match(fixtures, 'a[\\d]+c'), ['a123c', 'a1c'], 'Should match numbers'); - assert.deepStrictEqual(match(['foo@#$%123ASD #$$%^&', 'foo!@#$asdfl;', '123'], '[\\d]+'), ['123']); - assert.deepStrictEqual(match(['a123c', 'abbbc'], 'a[\\D]+c'), ['abbbc'], 'Should match non-numbers'); - assert.deepStrictEqual(match(['foo', ' foo '], '(f|o)+\\b'), ['foo'], 'Should match word boundaries'); + assert.deepStrictEqual(match(fixtures, 'a*c'), [ + 'a c', + 'a.c', + 'a.xy.zc', + 'a.zc', + 'a123c', + 'a1c', + 'abbbbc', + 'abbbc', + 'abbc', + 'abc', + 'axy zc', + 'axy.zc', + 'axyzc' + ]); + assert.deepStrictEqual( + match(fixtures, 'a[\\w]+c'), + ['a123c', 'a1c', 'abbbbc', 'abbbc', 'abbc', 'abc', 'axyzc'], + 'Should match word characters' + ); + assert.deepStrictEqual( + match(fixtures, 'a[\\W]+c'), + ['a c', 'a.c'], + 'Should match non-word characters' + ); + assert.deepStrictEqual( + match(fixtures, 'a[\\d]+c'), + ['a123c', 'a1c'], + 'Should match numbers' + ); + assert.deepStrictEqual( + match(['foo@#$%123ASD #$$%^&', 'foo!@#$asdfl;', '123'], '[\\d]+'), + ['123'] + ); + assert.deepStrictEqual( + match(['a123c', 'abbbc'], 'a[\\D]+c'), + ['abbbc'], + 'Should match non-numbers' + ); + assert.deepStrictEqual( + match(['foo', ' foo '], '(f|o)+\\b'), + ['foo'], + 'Should match word boundaries' + ); }); }); - diff --git a/test/globstars.js b/test/globstars.js index 9d101344..0a640d2b 100644 --- a/test/globstars.js +++ b/test/globstars.js @@ -14,7 +14,33 @@ describe('stars', () => { }); it('should regard non-exclusive double-stars as single stars', () => { - const fixtures = ['a', 'a/', 'a/a', 'a/a/', 'a/a/a', 'a/a/a/', 'a/a/a/a', 'a/a/a/a/', 'a/a/a/a/a', 'a/a/a/a/a/', 'a/a/b', 'a/a/b/', 'a/b', 'a/b/', 'a/b/c/.d/e/', 'a/c', 'a/c/', 'a/b', 'a/x/', 'b', 'b/', 'x/y', 'x/y/', 'z/z', 'z/z/']; + const fixtures = [ + 'a', + 'a/', + 'a/a', + 'a/a/', + 'a/a/a', + 'a/a/a/', + 'a/a/a/a', + 'a/a/a/a/', + 'a/a/a/a/a', + 'a/a/a/a/a/', + 'a/a/b', + 'a/a/b/', + 'a/b', + 'a/b/', + 'a/b/c/.d/e/', + 'a/c', + 'a/c/', + 'a/b', + 'a/x/', + 'b', + 'b/', + 'x/y', + 'x/y/', + 'z/z', + 'z/z/' + ]; assert.deepStrictEqual(match(fixtures, '**a/a/*/'), ['a/a/a/', 'a/a/b/']); assert(!isMatch('aaa/bba/ccc', 'aaa/**ccc')); @@ -52,31 +78,97 @@ describe('stars', () => { }); it('should match file extensions:', () => { - assert.deepStrictEqual(match(['.md', 'a.md', 'a/b/c.md', '.txt'], '**/*.md'), ['a.md', 'a/b/c.md']); - assert.deepStrictEqual(match(['.md/.md', '.md', 'a/.md', 'a/b/.md'], '**/.md'), ['.md', 'a/.md', 'a/b/.md']); - assert.deepStrictEqual(match(['.md/.md', '.md/foo/.md', '.md', 'a/.md', 'a/b/.md'], '.md/**/.md'), ['.md/.md', '.md/foo/.md']); + assert.deepStrictEqual( + match(['.md', 'a.md', 'a/b/c.md', '.txt'], '**/*.md'), + ['a.md', 'a/b/c.md'] + ); + assert.deepStrictEqual( + match(['.md/.md', '.md', 'a/.md', 'a/b/.md'], '**/.md'), + ['.md', 'a/.md', 'a/b/.md'] + ); + assert.deepStrictEqual( + match( + ['.md/.md', '.md/foo/.md', '.md', 'a/.md', 'a/b/.md'], + '.md/**/.md' + ), + ['.md/.md', '.md/foo/.md'] + ); }); it('should respect trailing slashes on paterns', () => { - const fixtures = ['a', 'a/', 'a/a', 'a/a/', 'a/a/a', 'a/a/a/', 'a/a/a/a', 'a/a/a/a/', 'a/a/a/a/a', 'a/a/a/a/a/', 'a/a/b', 'a/a/b/', 'a/b', 'a/b/', 'a/b/c/.d/e/', 'a/c', 'a/c/', 'a/b', 'a/x/', 'b', 'b/', 'x/y', 'x/y/', 'z/z', 'z/z/']; + const fixtures = [ + 'a', + 'a/', + 'a/a', + 'a/a/', + 'a/a/a', + 'a/a/a/', + 'a/a/a/a', + 'a/a/a/a/', + 'a/a/a/a/a', + 'a/a/a/a/a/', + 'a/a/b', + 'a/a/b/', + 'a/b', + 'a/b/', + 'a/b/c/.d/e/', + 'a/c', + 'a/c/', + 'a/b', + 'a/x/', + 'b', + 'b/', + 'x/y', + 'x/y/', + 'z/z', + 'z/z/' + ]; - assert.deepStrictEqual(match(fixtures, '**/*/a/'), ['a/a/', 'a/a/a/', 'a/a/a/a/', 'a/a/a/a/a/']); - assert.deepStrictEqual(match(fixtures, '**/*/a/*/'), ['a/a/a/', 'a/a/a/a/', 'a/a/a/a/a/', 'a/a/b/']); + assert.deepStrictEqual(match(fixtures, '**/*/a/'), [ + 'a/a/', + 'a/a/a/', + 'a/a/a/a/', + 'a/a/a/a/a/' + ]); + assert.deepStrictEqual(match(fixtures, '**/*/a/*/'), [ + 'a/a/a/', + 'a/a/a/a/', + 'a/a/a/a/a/', + 'a/a/b/' + ]); assert.deepStrictEqual(match(fixtures, '**/*/x/'), ['a/x/']); - assert.deepStrictEqual(match(fixtures, '**/*/*/*/*/'), ['a/a/a/a/', 'a/a/a/a/a/']); + assert.deepStrictEqual(match(fixtures, '**/*/*/*/*/'), [ + 'a/a/a/a/', + 'a/a/a/a/a/' + ]); assert.deepStrictEqual(match(fixtures, '**/*/*/*/*/*/'), ['a/a/a/a/a/']); assert.deepStrictEqual(match(fixtures, '*a/a/*/'), ['a/a/a/', 'a/a/b/']); assert.deepStrictEqual(match(fixtures, '**a/a/*/'), ['a/a/a/', 'a/a/b/']); - assert.deepStrictEqual(match(fixtures, '**/a/*/*/'), ['a/a/a/', 'a/a/a/a/', 'a/a/a/a/a/', 'a/a/b/']); - assert.deepStrictEqual(match(fixtures, '**/a/*/*/*/'), ['a/a/a/a/', 'a/a/a/a/a/']); + assert.deepStrictEqual(match(fixtures, '**/a/*/*/'), [ + 'a/a/a/', + 'a/a/a/a/', + 'a/a/a/a/a/', + 'a/a/b/' + ]); + assert.deepStrictEqual(match(fixtures, '**/a/*/*/*/'), [ + 'a/a/a/a/', + 'a/a/a/a/a/' + ]); assert.deepStrictEqual(match(fixtures, '**/a/*/*/*/*/'), ['a/a/a/a/a/']); - assert.deepStrictEqual(match(fixtures, '**/a/*/a/'), ['a/a/a/', 'a/a/a/a/', 'a/a/a/a/a/']); + assert.deepStrictEqual(match(fixtures, '**/a/*/a/'), [ + 'a/a/a/', + 'a/a/a/a/', + 'a/a/a/a/a/' + ]); assert.deepStrictEqual(match(fixtures, '**/a/*/b/'), ['a/a/b/']); }); it('should match literal globstars when stars are escaped', () => { const fixtures = ['.md', '**a.md', '**.md', '.md', '**']; - assert.deepStrictEqual(match(fixtures, '\\*\\**.md'), ['**a.md', '**.md']); + assert.deepStrictEqual(match(fixtures, '\\*\\**.md'), [ + '**a.md', + '**.md' + ]); assert.deepStrictEqual(match(fixtures, '\\*\\*.md'), ['**.md']); }); @@ -309,7 +401,13 @@ describe('stars', () => { }); it('should match leading dots when defined in pattern', () => { - const fixtures = ['.gitignore', 'a/b/z/.dotfile', 'a/b/z/.dotfile.md', 'a/b/z/.dotfile.md', 'a/b/z/.dotfile.md']; + const fixtures = [ + '.gitignore', + 'a/b/z/.dotfile', + 'a/b/z/.dotfile.md', + 'a/b/z/.dotfile.md', + 'a/b/z/.dotfile.md' + ]; assert(!isMatch('.gitignore', 'a/**/z/*.md')); assert(!isMatch('a/b/z/.dotfile', 'a/**/z/*.md')); assert(!isMatch('a/b/z/.dotfile.md', '**/c/.*.md')); @@ -317,16 +415,32 @@ describe('stars', () => { assert(isMatch('a/b/z/.a', 'a/*/z/.a')); assert(isMatch('a/b/z/.dotfile.md', '**/.*.md')); assert(isMatch('a/b/z/.dotfile.md', 'a/**/z/.*.md')); - assert.deepStrictEqual(match(['.md', 'a.md', 'a/b/c.md', '.txt'], '**/*.md'), ['a.md', 'a/b/c.md']); - assert.deepStrictEqual(match(['.md/.md', '.md', 'a/.md', 'a/b/.md'], '**/.md'), ['.md', 'a/.md', 'a/b/.md']); - assert.deepStrictEqual(match(['.md/.md', '.md/foo/.md', '.md', 'a/.md', 'a/b/.md'], '.md/**/.md'), ['.md/.md', '.md/foo/.md']); - assert.deepStrictEqual(match(fixtures, 'a/**/z/.*.md'), ['a/b/z/.dotfile.md']); + assert.deepStrictEqual( + match(['.md', 'a.md', 'a/b/c.md', '.txt'], '**/*.md'), + ['a.md', 'a/b/c.md'] + ); + assert.deepStrictEqual( + match(['.md/.md', '.md', 'a/.md', 'a/b/.md'], '**/.md'), + ['.md', 'a/.md', 'a/b/.md'] + ); + assert.deepStrictEqual( + match( + ['.md/.md', '.md/foo/.md', '.md', 'a/.md', 'a/b/.md'], + '.md/**/.md' + ), + ['.md/.md', '.md/foo/.md'] + ); + assert.deepStrictEqual(match(fixtures, 'a/**/z/.*.md'), [ + 'a/b/z/.dotfile.md' + ]); }); it('todo... (micromatch/#24)', () => { assert(isMatch('foo/bar/baz/one/image.png', 'foo/bar/**/one/**/*.*')); assert(isMatch('foo/bar/baz/one/two/image.png', 'foo/bar/**/one/**/*.*')); - assert(isMatch('foo/bar/baz/one/two/three/image.png', 'foo/bar/**/one/**/*.*')); + assert( + isMatch('foo/bar/baz/one/two/three/image.png', 'foo/bar/**/one/**/*.*') + ); assert(!isMatch('a/b/c/d/', 'a/b/**/f')); assert(isMatch('a', 'a/**')); assert(isMatch('a', '**')); diff --git a/test/issue-related.js b/test/issue-related.js index f85b3e62..3b27eec4 100644 --- a/test/issue-related.js +++ b/test/issue-related.js @@ -5,8 +5,12 @@ const { isMatch } = require('..'); describe('issue-related tests', () => { it('should match with braces (see picomatch/issues#8)', () => { - assert(isMatch('directory/.test.txt', '{file.txt,directory/**/*}', { dot: true })); - assert(isMatch('directory/test.txt', '{file.txt,directory/**/*}', { dot: true })); + assert( + isMatch('directory/.test.txt', '{file.txt,directory/**/*}', { dot: true }) + ); + assert( + isMatch('directory/test.txt', '{file.txt,directory/**/*}', { dot: true }) + ); assert(!isMatch('directory/.test.txt', '{file.txt,directory/**/*}')); assert(isMatch('directory/test.txt', '{file.txt,directory/**/*}')); }); diff --git a/test/malicious.js b/test/malicious.js index 82a7d2c9..d11e3cf5 100644 --- a/test/malicious.js +++ b/test/malicious.js @@ -11,15 +11,30 @@ const repeat = n => '\\'.repeat(n); describe('handling of potential regex exploits', () => { it('should support long escape sequences', () => { if (process.platform !== 'win32') { - assert(isMatch('\\A', `${repeat(65500)}A`), 'within the limits, and valid match'); + assert( + isMatch('\\A', `${repeat(65500)}A`), + 'within the limits, and valid match' + ); } - assert(isMatch('A', `!${repeat(65500)}A`), 'within the limits, and valid match'); - assert(isMatch('A', `!(${repeat(65500)}A)`), 'within the limits, and valid match'); - assert(!isMatch('A', `[!(${repeat(65500)}A`), 'within the limits, but invalid regex'); + assert( + isMatch('A', `!${repeat(65500)}A`), + 'within the limits, and valid match' + ); + assert( + isMatch('A', `!(${repeat(65500)}A)`), + 'within the limits, and valid match' + ); + assert( + !isMatch('A', `[!(${repeat(65500)}A`), + 'within the limits, but invalid regex' + ); }); it('should throw an error when the pattern is too long', () => { - assert.throws(() => isMatch('foo', '*'.repeat(65537)), /exceeds maximum allowed/); + assert.throws( + () => isMatch('foo', '*'.repeat(65537)), + /exceeds maximum allowed/ + ); assert.throws(() => { assert(!isMatch('A', `!(${repeat(65536)}A)`)); }, /Input length: 65540, exceeds maximum allowed length: 65536/); diff --git a/test/minimatch.js b/test/minimatch.js index 853e120a..5f612f63 100644 --- a/test/minimatch.js +++ b/test/minimatch.js @@ -26,13 +26,17 @@ describe('minimatch parity:', () => { it('https://github.com/isaacs/minimatch/issues/50', () => { assert(isMatch('foo/bar-[ABC].txt', 'foo/**/*-\\[ABC\\].txt')); assert(!isMatch('foo/bar-[ABC].txt', 'foo/**/*-\\[abc\\].txt')); - assert(isMatch('foo/bar-[ABC].txt', 'foo/**/*-\\[abc\\].txt', { nocase: true })); + assert( + isMatch('foo/bar-[ABC].txt', 'foo/**/*-\\[abc\\].txt', { nocase: true }) + ); }); it('https://github.com/isaacs/minimatch/issues/67 (should work consistently with `makeRe` and matcher functions)', () => { const re = makeRe('node_modules/foobar/**/*.bar'); assert(re.test('node_modules/foobar/foo.bar')); - assert(isMatch('node_modules/foobar/foo.bar', 'node_modules/foobar/**/*.bar')); + assert( + isMatch('node_modules/foobar/foo.bar', 'node_modules/foobar/**/*.bar') + ); }); it('https://github.com/isaacs/minimatch/issues/75', () => { diff --git a/test/negation.js b/test/negation.js index a3a6a832..792ca65e 100644 --- a/test/negation.js +++ b/test/negation.js @@ -49,24 +49,24 @@ describe('negation patterns - "!"', () => { it('should support multiple leading ! to toggle negation', () => { assert(!isMatch('abc', '!abc')); - assert(isMatch('abc', '!!abc')); + assert(isMatch('abc', '!!abc')); assert(!isMatch('abc', '!!!abc')); - assert(isMatch('abc', '!!!!abc')); + assert(isMatch('abc', '!!!!abc')); assert(!isMatch('abc', '!!!!!abc')); - assert(isMatch('abc', '!!!!!!abc')); + assert(isMatch('abc', '!!!!!!abc')); assert(!isMatch('abc', '!!!!!!!abc')); - assert(isMatch('abc', '!!!!!!!!abc')); + assert(isMatch('abc', '!!!!!!!!abc')); }); it('should support negation extglobs after leading !', () => { assert(!isMatch('abc', '!(abc)')); - assert(isMatch('abc', '!!(abc)')); + assert(isMatch('abc', '!!(abc)')); assert(!isMatch('abc', '!!!(abc)')); - assert(isMatch('abc', '!!!!(abc)')); + assert(isMatch('abc', '!!!!(abc)')); assert(!isMatch('abc', '!!!!!(abc)')); - assert(isMatch('abc', '!!!!!!(abc)')); + assert(isMatch('abc', '!!!!!!(abc)')); assert(!isMatch('abc', '!!!!!!!(abc)')); - assert(isMatch('abc', '!!!!!!!!(abc)')); + assert(isMatch('abc', '!!!!!!!!(abc)')); }); it('should support negation with globs', () => { diff --git a/test/options.expandRange.js b/test/options.expandRange.js index 0eb05fc3..72b33d40 100644 --- a/test/options.expandRange.js +++ b/test/options.expandRange.js @@ -6,12 +6,18 @@ const { isMatch } = require('..'); describe('options.expandRange', () => { it('should support a custom function for expanding ranges in brace patterns', () => { - assert(isMatch('a/c', 'a/{a..c}', { expandRange: (a, b) => `([${a}-${b}])` })); - assert(!isMatch('a/z', 'a/{a..c}', { expandRange: (a, b) => `([${a}-${b}])` })); - assert(isMatch('a/99', 'a/{1..100}', { - expandRange(a, b) { - return `(${fill(a, b, { toRegex: true })})`; - } - })); + assert( + isMatch('a/c', 'a/{a..c}', { expandRange: (a, b) => `([${a}-${b}])` }) + ); + assert( + !isMatch('a/z', 'a/{a..c}', { expandRange: (a, b) => `([${a}-${b}])` }) + ); + assert( + isMatch('a/99', 'a/{1..100}', { + expandRange(a, b) { + return `(${fill(a, b, { toRegex: true })})`; + } + }) + ); }); }); diff --git a/test/options.format.js b/test/options.format.js index b4f3444d..3fb4b683 100644 --- a/test/options.format.js +++ b/test/options.format.js @@ -5,15 +5,35 @@ const match = require('./support/match'); const { isMatch } = require('..'); const equal = (actual, expected, msg) => { - assert.deepStrictEqual([].concat(actual).sort(), [].concat(expected).sort(), msg); + assert.deepStrictEqual( + [].concat(actual).sort(), + [].concat(expected).sort(), + msg + ); }; describe('options.format', () => { - // see https://github.com/isaacs/minimatch/issues/30 it('should match the string returned by options.format', () => { - const opts = { format: str => str.replace(/\\/g, '/').replace(/^\.\//, ''), strictSlashes: true }; - const fixtures = ['a', './a', 'b', 'a/a', './a/b', 'a/c', './a/x', './a/a/a', 'a/a/b', './a/a/a/a', './a/a/a/a/a', 'x/y', './z/z']; + const opts = { + format: str => str.replace(/\\/g, '/').replace(/^\.\//, ''), + strictSlashes: true + }; + const fixtures = [ + 'a', + './a', + 'b', + 'a/a', + './a/b', + 'a/c', + './a/x', + './a/a/a', + 'a/a/b', + './a/a/a/a', + './a/a/a/a/a', + 'x/y', + './z/z' + ]; assert(!isMatch('./.a', '*.a', opts)); assert(!isMatch('./.a', './*.a', opts)); @@ -43,13 +63,38 @@ describe('options.format', () => { assert(isMatch('.\\foo\\bar.js', '**/foo/**', { ...opts, windows: false })); assert(isMatch('.\\foo\\bar.js', './**/foo/**', opts)); equal(match(fixtures, '*', opts), ['a', 'b']); - equal(match(fixtures, '**/a/**', opts), ['a/a', 'a/c', 'a/b', 'a/x', 'a/a/a', 'a/a/b', 'a/a/a/a', 'a/a/a/a/a']); - equal(match(fixtures, '*/*', opts), ['a/a', 'a/b', 'a/c', 'a/x', 'x/y', 'z/z']); + equal(match(fixtures, '**/a/**', opts), [ + 'a/a', + 'a/c', + 'a/b', + 'a/x', + 'a/a/a', + 'a/a/b', + 'a/a/a/a', + 'a/a/a/a/a' + ]); + equal(match(fixtures, '*/*', opts), [ + 'a/a', + 'a/b', + 'a/c', + 'a/x', + 'x/y', + 'z/z' + ]); equal(match(fixtures, '*/*/*', opts), ['a/a/a', 'a/a/b']); equal(match(fixtures, '*/*/*/*', opts), ['a/a/a/a']); equal(match(fixtures, '*/*/*/*/*', opts), ['a/a/a/a/a']); equal(match(fixtures, '*', opts), ['a', 'b']); - equal(match(fixtures, '**/a/**', opts), ['a/a', 'a/c', 'a/b', 'a/x', 'a/a/a', 'a/a/b', 'a/a/a/a', 'a/a/a/a/a']); + equal(match(fixtures, '**/a/**', opts), [ + 'a/a', + 'a/c', + 'a/b', + 'a/x', + 'a/a/a', + 'a/a/b', + 'a/a/a/a', + 'a/a/a/a/a' + ]); equal(match(fixtures, 'a/*/a', opts), ['a/a/a']); equal(match(fixtures, 'a/*', opts), ['a/a', 'a/b', 'a/c', 'a/x']); equal(match(fixtures, 'a/*/*', opts), ['a/a/a', 'a/a/b']); diff --git a/test/options.ignore.js b/test/options.ignore.js index e8cc6285..4f6814b4 100644 --- a/test/options.ignore.js +++ b/test/options.ignore.js @@ -6,50 +6,134 @@ const { isMatch } = require('..'); describe('options.ignore', () => { it('should not match ignored patterns', () => { - assert(isMatch('a+b/src/glimini.js', 'a+b/src/*.js', { ignore: ['**/f*'] })); - assert(!isMatch('a+b/src/glimini.js', 'a+b/src/*.js', { ignore: ['**/g*'] })); + assert( + isMatch('a+b/src/glimini.js', 'a+b/src/*.js', { ignore: ['**/f*'] }) + ); + assert( + !isMatch('a+b/src/glimini.js', 'a+b/src/*.js', { ignore: ['**/g*'] }) + ); assert(isMatch('+b/src/glimini.md', '+b/src/*', { ignore: ['**/*.js'] })); assert(!isMatch('+b/src/glimini.js', '+b/src/*', { ignore: ['**/*.js'] })); }); const negations = ['a/a', 'a/b', 'a/c', 'a/d', 'a/e', 'b/a', 'b/b', 'b/c']; - const globs = ['.a', '.a/a', '.a/a/a', '.a/a/a/a', 'a', 'a/.a', 'a/a', 'a/a/.a', 'a/a/a', 'a/a/a/a', 'a/a/a/a/a', 'a/a/b', 'a/b', 'a/b/c', 'a/c', 'a/x', 'b', 'b/b/b', 'b/b/c', 'c/c/c', 'e/f/g', 'h/i/a', 'x/x/x', 'x/y', 'z/z', 'z/z/z'].sort(); + const globs = [ + '.a', + '.a/a', + '.a/a/a', + '.a/a/a/a', + 'a', + 'a/.a', + 'a/a', + 'a/a/.a', + 'a/a/a', + 'a/a/a/a', + 'a/a/a/a/a', + 'a/a/b', + 'a/b', + 'a/b/c', + 'a/c', + 'a/x', + 'b', + 'b/b/b', + 'b/b/c', + 'c/c/c', + 'e/f/g', + 'h/i/a', + 'x/x/x', + 'x/y', + 'z/z', + 'z/z/z' + ].sort(); it('should filter out ignored patterns', () => { const opts = { ignore: ['a/**'], strictSlashes: true }; const dotOpts = { ...opts, dot: true }; assert.deepStrictEqual(match(globs, '*', opts), ['a', 'b']); - assert.deepStrictEqual(match(globs, '*', { ...opts, strictSlashes: false }), ['b']); + assert.deepStrictEqual( + match(globs, '*', { ...opts, strictSlashes: false }), + ['b'] + ); assert.deepStrictEqual(match(globs, '*', { ignore: '**/a' }), ['b']); assert.deepStrictEqual(match(globs, '*/*', opts), ['x/y', 'z/z']); - assert.deepStrictEqual(match(globs, '*/*/*', opts), ['b/b/b', 'b/b/c', 'c/c/c', 'e/f/g', 'h/i/a', 'x/x/x', 'z/z/z']); + assert.deepStrictEqual(match(globs, '*/*/*', opts), [ + 'b/b/b', + 'b/b/c', + 'c/c/c', + 'e/f/g', + 'h/i/a', + 'x/x/x', + 'z/z/z' + ]); assert.deepStrictEqual(match(globs, '*/*/*/*', opts), []); assert.deepStrictEqual(match(globs, '*/*/*/*/*', opts), []); assert.deepStrictEqual(match(globs, 'a/*', opts), []); assert.deepStrictEqual(match(globs, '**/*/x', opts), ['x/x/x']); - assert.deepStrictEqual(match(globs, '**/*/[b-z]', opts), ['b/b/b', 'b/b/c', 'c/c/c', 'e/f/g', 'x/x/x', 'x/y', 'z/z', 'z/z/z']); + assert.deepStrictEqual(match(globs, '**/*/[b-z]', opts), [ + 'b/b/b', + 'b/b/c', + 'c/c/c', + 'e/f/g', + 'x/x/x', + 'x/y', + 'z/z', + 'z/z/z' + ]); - assert.deepStrictEqual(match(globs, '*', { ignore: '**/a', dot: true }), ['.a', 'b']); + assert.deepStrictEqual(match(globs, '*', { ignore: '**/a', dot: true }), [ + '.a', + 'b' + ]); assert.deepStrictEqual(match(globs, '*', dotOpts), ['.a', 'a', 'b']); - assert.deepStrictEqual(match(globs, '*/*', dotOpts), ['.a/a', 'x/y', 'z/z'].sort()); - assert.deepStrictEqual(match(globs, '*/*/*', dotOpts), ['.a/a/a', 'b/b/b', 'b/b/c', 'c/c/c', 'e/f/g', 'h/i/a', 'x/x/x', 'z/z/z'].sort()); + assert.deepStrictEqual( + match(globs, '*/*', dotOpts), + ['.a/a', 'x/y', 'z/z'].sort() + ); + assert.deepStrictEqual( + match(globs, '*/*/*', dotOpts), + [ + '.a/a/a', + 'b/b/b', + 'b/b/c', + 'c/c/c', + 'e/f/g', + 'h/i/a', + 'x/x/x', + 'z/z/z' + ].sort() + ); assert.deepStrictEqual(match(globs, '*/*/*/*', dotOpts), ['.a/a/a/a']); assert.deepStrictEqual(match(globs, '*/*/*/*/*', dotOpts), []); assert.deepStrictEqual(match(globs, 'a/*', dotOpts), []); assert.deepStrictEqual(match(globs, '**/*/x', dotOpts), ['x/x/x']); // see https://github.com/jonschlinkert/micromatch/issues/79 - assert.deepStrictEqual(match(['foo.js', 'a/foo.js'], '**/foo.js'), ['foo.js', 'a/foo.js']); - assert.deepStrictEqual(match(['foo.js', 'a/foo.js'], '**/foo.js', { dot: true }), ['foo.js', 'a/foo.js']); + assert.deepStrictEqual(match(['foo.js', 'a/foo.js'], '**/foo.js'), [ + 'foo.js', + 'a/foo.js' + ]); + assert.deepStrictEqual( + match(['foo.js', 'a/foo.js'], '**/foo.js', { dot: true }), + ['foo.js', 'a/foo.js'] + ); assert.deepStrictEqual(match(negations, '!b/a', opts), ['b/b', 'b/c']); assert.deepStrictEqual(match(negations, '!b/(a)', opts), ['b/b', 'b/c']); assert.deepStrictEqual(match(negations, '!(b/(a))', opts), ['b/b', 'b/c']); assert.deepStrictEqual(match(negations, '!(b/a)', opts), ['b/b', 'b/c']); - assert.deepStrictEqual(match(negations, '**'), negations, 'nothing is ignored'); - assert.deepStrictEqual(match(negations, '**', { ignore: ['*/b', '*/a'] }), ['a/c', 'a/d', 'a/e', 'b/c']); + assert.deepStrictEqual( + match(negations, '**'), + negations, + 'nothing is ignored' + ); + assert.deepStrictEqual(match(negations, '**', { ignore: ['*/b', '*/a'] }), [ + 'a/c', + 'a/d', + 'a/e', + 'b/c' + ]); assert.deepStrictEqual(match(negations, '**', { ignore: ['**'] }), []); }); }); diff --git a/test/options.js b/test/options.js index 8993d181..d2b6c828 100644 --- a/test/options.js +++ b/test/options.js @@ -7,49 +7,118 @@ const { isMatch } = require('..'); describe('options', () => { describe('options.matchBase', () => { it('should match the basename of file paths when `options.matchBase` is true', () => { - assert.deepStrictEqual(match(['a/b/c/d.md'], '*.md', { windows: true }), [], 'should not match multiple levels'); - assert.deepStrictEqual(match(['a/b/c/foo.md'], '*.md', { windows: true }), [], 'should not match multiple levels'); - assert.deepStrictEqual(match(['ab', 'acb', 'acb/', 'acb/d/e', 'x/y/acb', 'x/y/acb/d'], 'a?b', { windows: true }), ['acb'], 'should not match multiple levels'); - assert.deepStrictEqual(match(['a/b/c/d.md'], '*.md', { matchBase: true, windows: true }), ['a/b/c/d.md']); - assert.deepStrictEqual(match(['a/b/c/foo.md'], '*.md', { matchBase: true, windows: true }), ['a/b/c/foo.md']); - assert.deepStrictEqual(match(['x/y/acb', 'acb/', 'acb/d/e', 'x/y/acb/d'], 'a?b', { matchBase: true, windows: true }), ['x/y/acb', 'acb/']); + assert.deepStrictEqual( + match(['a/b/c/d.md'], '*.md', { windows: true }), + [], + 'should not match multiple levels' + ); + assert.deepStrictEqual( + match(['a/b/c/foo.md'], '*.md', { windows: true }), + [], + 'should not match multiple levels' + ); + assert.deepStrictEqual( + match(['ab', 'acb', 'acb/', 'acb/d/e', 'x/y/acb', 'x/y/acb/d'], 'a?b', { + windows: true + }), + ['acb'], + 'should not match multiple levels' + ); + assert.deepStrictEqual( + match(['a/b/c/d.md'], '*.md', { matchBase: true, windows: true }), + ['a/b/c/d.md'] + ); + assert.deepStrictEqual( + match(['a/b/c/foo.md'], '*.md', { matchBase: true, windows: true }), + ['a/b/c/foo.md'] + ); + assert.deepStrictEqual( + match(['x/y/acb', 'acb/', 'acb/d/e', 'x/y/acb/d'], 'a?b', { + matchBase: true, + windows: true + }), + ['x/y/acb', 'acb/'] + ); }); it('should work with negation patterns', () => { assert(isMatch('./x/y.js', '*.js', { matchBase: true, windows: true })); assert(!isMatch('./x/y.js', '!*.js', { matchBase: true, windows: true })); - assert(isMatch('./x/y.js', '**/*.js', { matchBase: true, windows: true })); - assert(!isMatch('./x/y.js', '!**/*.js', { matchBase: true, windows: true })); + assert( + isMatch('./x/y.js', '**/*.js', { matchBase: true, windows: true }) + ); + assert( + !isMatch('./x/y.js', '!**/*.js', { matchBase: true, windows: true }) + ); }); }); describe('options.flags', () => { it('should be case-sensitive by default', () => { - assert.deepStrictEqual(match(['a/b/d/e.md'], 'a/b/D/*.md', { windows: true }), [], 'should not match a dirname'); - assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/*/E.md', { windows: true }), [], 'should not match a basename'); - assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/C/*.MD', { windows: true }), [], 'should not match a file extension'); + assert.deepStrictEqual( + match(['a/b/d/e.md'], 'a/b/D/*.md', { windows: true }), + [], + 'should not match a dirname' + ); + assert.deepStrictEqual( + match(['a/b/c/e.md'], 'A/b/*/E.md', { windows: true }), + [], + 'should not match a basename' + ); + assert.deepStrictEqual( + match(['a/b/c/e.md'], 'A/b/C/*.MD', { windows: true }), + [], + 'should not match a file extension' + ); }); it('should not be case-sensitive when `i` is set on `options.flags`', () => { - assert.deepStrictEqual(match(['a/b/d/e.md'], 'a/b/D/*.md', { flags: 'i', windows: true }), ['a/b/d/e.md']); - assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/*/E.md', { flags: 'i', windows: true }), ['a/b/c/e.md']); - assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/C/*.MD', { flags: 'i', windows: true }), ['a/b/c/e.md']); + assert.deepStrictEqual( + match(['a/b/d/e.md'], 'a/b/D/*.md', { flags: 'i', windows: true }), + ['a/b/d/e.md'] + ); + assert.deepStrictEqual( + match(['a/b/c/e.md'], 'A/b/*/E.md', { flags: 'i', windows: true }), + ['a/b/c/e.md'] + ); + assert.deepStrictEqual( + match(['a/b/c/e.md'], 'A/b/C/*.MD', { flags: 'i', windows: true }), + ['a/b/c/e.md'] + ); }); }); describe('options.nocase', () => { it('should not be case-sensitive when `options.nocase` is true', () => { - assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/*/E.md', { nocase: true, windows: true }), ['a/b/c/e.md']); - assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/C/*.MD', { nocase: true, windows: true }), ['a/b/c/e.md']); - assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/C/*.md', { nocase: true, windows: true }), ['a/b/c/e.md']); - assert.deepStrictEqual(match(['a/b/d/e.md'], 'a/b/D/*.md', { nocase: true, windows: true }), ['a/b/d/e.md']); + assert.deepStrictEqual( + match(['a/b/c/e.md'], 'A/b/*/E.md', { nocase: true, windows: true }), + ['a/b/c/e.md'] + ); + assert.deepStrictEqual( + match(['a/b/c/e.md'], 'A/b/C/*.MD', { nocase: true, windows: true }), + ['a/b/c/e.md'] + ); + assert.deepStrictEqual( + match(['a/b/c/e.md'], 'A/b/C/*.md', { nocase: true, windows: true }), + ['a/b/c/e.md'] + ); + assert.deepStrictEqual( + match(['a/b/d/e.md'], 'a/b/D/*.md', { nocase: true, windows: true }), + ['a/b/d/e.md'] + ); }); it('should not double-set `i` when both `nocase` and the `i` flag are set', () => { const opts = { nocase: true, flags: 'i', windows: true }; - assert.deepStrictEqual(match(['a/b/d/e.md'], 'a/b/D/*.md', opts), ['a/b/d/e.md']); - assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/*/E.md', opts), ['a/b/c/e.md']); - assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/C/*.MD', opts), ['a/b/c/e.md']); + assert.deepStrictEqual(match(['a/b/d/e.md'], 'a/b/D/*.md', opts), [ + 'a/b/d/e.md' + ]); + assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/*/E.md', opts), [ + 'a/b/c/e.md' + ]); + assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/C/*.MD', opts), [ + 'a/b/c/e.md' + ]); }); }); @@ -60,102 +129,370 @@ describe('options', () => { it('should not match extglobs when noextglob is true', () => { assert(!isMatch('ax', '?(a*|b)', { noextglob: true, windows: true })); - assert.deepStrictEqual(match(['a.j.js', 'a.md.js'], '*.*(j).js', { noextglob: true, windows: true }), ['a.j.js']); - assert.deepStrictEqual(match(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)', { noextglob: true, windows: true }), ['a/!(z)']); - assert.deepStrictEqual(match(['a/z', 'a/b'], 'a/!(z)', { noextglob: true, windows: true }), []); - assert.deepStrictEqual(match(['c/a/v'], 'c/!(z)/v', { noextglob: true, windows: true }), []); - assert.deepStrictEqual(match(['c/z/v', 'c/a/v'], 'c/!(z)/v', { noextglob: true, windows: true }), []); - assert.deepStrictEqual(match(['c/z/v', 'c/a/v'], 'c/@(z)/v', { noextglob: true, windows: true }), []); - assert.deepStrictEqual(match(['c/z/v', 'c/a/v'], 'c/+(z)/v', { noextglob: true, windows: true }), []); - assert.deepStrictEqual(match(['c/z/v', 'c/a/v'], 'c/*(z)/v', { noextglob: true, windows: true }), ['c/z/v']); - assert.deepStrictEqual(match(['c/z/v', 'z', 'zf', 'fz'], '?(z)', { noextglob: true, windows: true }), ['fz']); - assert.deepStrictEqual(match(['c/z/v', 'z', 'zf', 'fz'], '+(z)', { noextglob: true, windows: true }), []); - assert.deepStrictEqual(match(['c/z/v', 'z', 'zf', 'fz'], '*(z)', { noextglob: true, windows: true }), ['z', 'fz']); - assert.deepStrictEqual(match(['cz', 'abz', 'az'], 'a@(z)', { noextglob: true, windows: true }), []); - assert.deepStrictEqual(match(['cz', 'abz', 'az'], 'a*@(z)', { noextglob: true, windows: true }), []); - assert.deepStrictEqual(match(['cz', 'abz', 'az'], 'a!(z)', { noextglob: true, windows: true }), []); - assert.deepStrictEqual(match(['cz', 'abz', 'az', 'azz'], 'a?(z)', { noextglob: true, windows: true }), ['abz', 'azz']); - assert.deepStrictEqual(match(['cz', 'abz', 'az', 'azz', 'a+z'], 'a+(z)', { noextglob: true, windows: true }), ['a+z']); - assert.deepStrictEqual(match(['cz', 'abz', 'az'], 'a*(z)', { noextglob: true, windows: true }), ['abz', 'az']); - assert.deepStrictEqual(match(['cz', 'abz', 'az'], 'a**(z)', { noextglob: true, windows: true }), ['abz', 'az']); - assert.deepStrictEqual(match(['cz', 'abz', 'az'], 'a*!(z)', { noextglob: true, windows: true }), []); + assert.deepStrictEqual( + match(['a.j.js', 'a.md.js'], '*.*(j).js', { + noextglob: true, + windows: true + }), + ['a.j.js'] + ); + assert.deepStrictEqual( + match(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)', { + noextglob: true, + windows: true + }), + ['a/!(z)'] + ); + assert.deepStrictEqual( + match(['a/z', 'a/b'], 'a/!(z)', { noextglob: true, windows: true }), + [] + ); + assert.deepStrictEqual( + match(['c/a/v'], 'c/!(z)/v', { noextglob: true, windows: true }), + [] + ); + assert.deepStrictEqual( + match(['c/z/v', 'c/a/v'], 'c/!(z)/v', { + noextglob: true, + windows: true + }), + [] + ); + assert.deepStrictEqual( + match(['c/z/v', 'c/a/v'], 'c/@(z)/v', { + noextglob: true, + windows: true + }), + [] + ); + assert.deepStrictEqual( + match(['c/z/v', 'c/a/v'], 'c/+(z)/v', { + noextglob: true, + windows: true + }), + [] + ); + assert.deepStrictEqual( + match(['c/z/v', 'c/a/v'], 'c/*(z)/v', { + noextglob: true, + windows: true + }), + ['c/z/v'] + ); + assert.deepStrictEqual( + match(['c/z/v', 'z', 'zf', 'fz'], '?(z)', { + noextglob: true, + windows: true + }), + ['fz'] + ); + assert.deepStrictEqual( + match(['c/z/v', 'z', 'zf', 'fz'], '+(z)', { + noextglob: true, + windows: true + }), + [] + ); + assert.deepStrictEqual( + match(['c/z/v', 'z', 'zf', 'fz'], '*(z)', { + noextglob: true, + windows: true + }), + ['z', 'fz'] + ); + assert.deepStrictEqual( + match(['cz', 'abz', 'az'], 'a@(z)', { noextglob: true, windows: true }), + [] + ); + assert.deepStrictEqual( + match(['cz', 'abz', 'az'], 'a*@(z)', { + noextglob: true, + windows: true + }), + [] + ); + assert.deepStrictEqual( + match(['cz', 'abz', 'az'], 'a!(z)', { noextglob: true, windows: true }), + [] + ); + assert.deepStrictEqual( + match(['cz', 'abz', 'az', 'azz'], 'a?(z)', { + noextglob: true, + windows: true + }), + ['abz', 'azz'] + ); + assert.deepStrictEqual( + match(['cz', 'abz', 'az', 'azz', 'a+z'], 'a+(z)', { + noextglob: true, + windows: true + }), + ['a+z'] + ); + assert.deepStrictEqual( + match(['cz', 'abz', 'az'], 'a*(z)', { noextglob: true, windows: true }), + ['abz', 'az'] + ); + assert.deepStrictEqual( + match(['cz', 'abz', 'az'], 'a**(z)', { + noextglob: true, + windows: true + }), + ['abz', 'az'] + ); + assert.deepStrictEqual( + match(['cz', 'abz', 'az'], 'a*!(z)', { + noextglob: true, + windows: true + }), + [] + ); }); }); describe('options.unescape', () => { it('should remove backslashes in glob patterns:', () => { const fixtures = ['abc', '/a/b/c', '\\a\\b\\c']; - assert.deepStrictEqual(match(fixtures, '\\a\\b\\c', { windows: true }), ['/a/b/c']); - assert.deepStrictEqual(match(fixtures, '\\a\\b\\c', { unescape: true, windows: true }), ['abc', '/a/b/c']); - assert.deepStrictEqual(match(fixtures, '\\a\\b\\c', { unescape: false, windows: true }), ['/a/b/c']); + assert.deepStrictEqual(match(fixtures, '\\a\\b\\c', { windows: true }), [ + '/a/b/c' + ]); + assert.deepStrictEqual( + match(fixtures, '\\a\\b\\c', { unescape: true, windows: true }), + ['abc', '/a/b/c'] + ); + assert.deepStrictEqual( + match(fixtures, '\\a\\b\\c', { unescape: false, windows: true }), + ['/a/b/c'] + ); }); }); describe('options.nonegate', () => { it('should support the `nonegate` option:', () => { - assert.deepStrictEqual(match(['a/a/a', 'a/b/a', 'b/b/a', 'c/c/a', 'c/c/b'], '!**/a', { windows: true }), ['c/c/b']); - assert.deepStrictEqual(match(['a.md', '!a.md', 'a.txt'], '!*.md', { nonegate: true, windows: true }), ['!a.md']); - assert.deepStrictEqual(match(['!a/a/a', '!a/a', 'a/b/a', 'b/b/a', '!c/c/a', '!c/a'], '!**/a', { nonegate: true, windows: true }), ['!a/a', '!c/a']); - assert.deepStrictEqual(match(['!*.md', '.dotfile.txt', 'a/b/.dotfile'], '!*.md', { nonegate: true, windows: true }), ['!*.md']); + assert.deepStrictEqual( + match(['a/a/a', 'a/b/a', 'b/b/a', 'c/c/a', 'c/c/b'], '!**/a', { + windows: true + }), + ['c/c/b'] + ); + assert.deepStrictEqual( + match(['a.md', '!a.md', 'a.txt'], '!*.md', { + nonegate: true, + windows: true + }), + ['!a.md'] + ); + assert.deepStrictEqual( + match(['!a/a/a', '!a/a', 'a/b/a', 'b/b/a', '!c/c/a', '!c/a'], '!**/a', { + nonegate: true, + windows: true + }), + ['!a/a', '!c/a'] + ); + assert.deepStrictEqual( + match(['!*.md', '.dotfile.txt', 'a/b/.dotfile'], '!*.md', { + nonegate: true, + windows: true + }), + ['!*.md'] + ); }); }); describe('options.windows', () => { it('should windows file paths by default', () => { - assert.deepStrictEqual(match(['a\\b\\c.md'], '**/*.md', { windows: true }), ['a/b/c.md']); - assert.deepStrictEqual(match(['a\\b\\c.md'], '**/*.md', { windows: false }), ['a\\b\\c.md']); + assert.deepStrictEqual( + match(['a\\b\\c.md'], '**/*.md', { windows: true }), + ['a/b/c.md'] + ); + assert.deepStrictEqual( + match(['a\\b\\c.md'], '**/*.md', { windows: false }), + ['a\\b\\c.md'] + ); }); it('should windows absolute paths', () => { - assert.deepStrictEqual(match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: true }), ['E:/a/b/c.md']); - assert.deepStrictEqual(match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: false }), []); + assert.deepStrictEqual( + match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: true }), + ['E:/a/b/c.md'] + ); + assert.deepStrictEqual( + match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: false }), + [] + ); }); it('should strip leading `./`', () => { - const fixtures = ['./a', './a/a/a', './a/a/a/a', './a/a/a/a/a', './a/b', './a/x', './z/z', 'a', 'a/a', 'a/a/b', 'a/c', 'b', 'x/y'].sort(); + const fixtures = [ + './a', + './a/a/a', + './a/a/a/a', + './a/a/a/a/a', + './a/b', + './a/x', + './z/z', + 'a', + 'a/a', + 'a/a/b', + 'a/c', + 'b', + 'x/y' + ].sort(); const format = str => str.replace(/^\.\//, ''); const opts = { format, windows: true }; assert.deepStrictEqual(match(fixtures, '*', opts), ['a', 'b']); - assert.deepStrictEqual(match(fixtures, '**/a/**', opts), ['a', 'a/a/a', 'a/a/a/a', 'a/a/a/a/a', 'a/b', 'a/x', 'a/a', 'a/a/b', 'a/c']); - assert.deepStrictEqual(match(fixtures, '*/*', opts), ['a/b', 'a/x', 'z/z', 'a/a', 'a/c', 'x/y']); - assert.deepStrictEqual(match(fixtures, '*/*/*', opts), ['a/a/a', 'a/a/b']); + assert.deepStrictEqual(match(fixtures, '**/a/**', opts), [ + 'a', + 'a/a/a', + 'a/a/a/a', + 'a/a/a/a/a', + 'a/b', + 'a/x', + 'a/a', + 'a/a/b', + 'a/c' + ]); + assert.deepStrictEqual(match(fixtures, '*/*', opts), [ + 'a/b', + 'a/x', + 'z/z', + 'a/a', + 'a/c', + 'x/y' + ]); + assert.deepStrictEqual(match(fixtures, '*/*/*', opts), [ + 'a/a/a', + 'a/a/b' + ]); assert.deepStrictEqual(match(fixtures, '*/*/*/*', opts), ['a/a/a/a']); assert.deepStrictEqual(match(fixtures, '*/*/*/*/*', opts), ['a/a/a/a/a']); assert.deepStrictEqual(match(fixtures, './*', opts), ['a', 'b']); - assert.deepStrictEqual(match(fixtures, './**/a/**', opts), ['a', 'a/a/a', 'a/a/a/a', 'a/a/a/a/a', 'a/b', 'a/x', 'a/a', 'a/a/b', 'a/c']); + assert.deepStrictEqual(match(fixtures, './**/a/**', opts), [ + 'a', + 'a/a/a', + 'a/a/a/a', + 'a/a/a/a/a', + 'a/b', + 'a/x', + 'a/a', + 'a/a/b', + 'a/c' + ]); assert.deepStrictEqual(match(fixtures, './a/*/a', opts), ['a/a/a']); - assert.deepStrictEqual(match(fixtures, 'a/*', opts), ['a/b', 'a/x', 'a/a', 'a/c']); - assert.deepStrictEqual(match(fixtures, 'a/*/*', opts), ['a/a/a', 'a/a/b']); + assert.deepStrictEqual(match(fixtures, 'a/*', opts), [ + 'a/b', + 'a/x', + 'a/a', + 'a/c' + ]); + assert.deepStrictEqual(match(fixtures, 'a/*/*', opts), [ + 'a/a/a', + 'a/a/b' + ]); assert.deepStrictEqual(match(fixtures, 'a/*/*/*', opts), ['a/a/a/a']); assert.deepStrictEqual(match(fixtures, 'a/*/*/*/*', opts), ['a/a/a/a/a']); assert.deepStrictEqual(match(fixtures, 'a/*/a', opts), ['a/a/a']); - assert.deepStrictEqual(match(fixtures, '*', { ...opts, windows: false }), ['a', 'b']); - assert.deepStrictEqual(match(fixtures, '**/a/**', { ...opts, windows: false }), ['a', 'a/a/a', 'a/a/a/a', 'a/a/a/a/a', 'a/b', 'a/x', 'a/a', 'a/a/b', 'a/c']); - assert.deepStrictEqual(match(fixtures, '*/*', { ...opts, windows: false }), ['a/b', 'a/x', 'z/z', 'a/a', 'a/c', 'x/y']); - assert.deepStrictEqual(match(fixtures, '*/*/*', { ...opts, windows: false }), ['a/a/a', 'a/a/b']); - assert.deepStrictEqual(match(fixtures, '*/*/*/*', { ...opts, windows: false }), ['a/a/a/a']); - assert.deepStrictEqual(match(fixtures, '*/*/*/*/*', { ...opts, windows: false }), ['a/a/a/a/a']); - assert.deepStrictEqual(match(fixtures, './*', { ...opts, windows: false }), ['a', 'b']); - assert.deepStrictEqual(match(fixtures, './**/a/**', { ...opts, windows: false }), ['a', 'a/a/a', 'a/a/a/a', 'a/a/a/a/a', 'a/b', 'a/x', 'a/a', 'a/a/b', 'a/c']); - assert.deepStrictEqual(match(fixtures, './a/*/a', { ...opts, windows: false }), ['a/a/a']); - assert.deepStrictEqual(match(fixtures, 'a/*', { ...opts, windows: false }), ['a/b', 'a/x', 'a/a', 'a/c']); - assert.deepStrictEqual(match(fixtures, 'a/*/*', { ...opts, windows: false }), ['a/a/a', 'a/a/b']); - assert.deepStrictEqual(match(fixtures, 'a/*/*/*', { ...opts, windows: false }), ['a/a/a/a']); - assert.deepStrictEqual(match(fixtures, 'a/*/*/*/*', { ...opts, windows: false }), ['a/a/a/a/a']); - assert.deepStrictEqual(match(fixtures, 'a/*/a', { ...opts, windows: false }), ['a/a/a']); + assert.deepStrictEqual( + match(fixtures, '*', { ...opts, windows: false }), + ['a', 'b'] + ); + assert.deepStrictEqual( + match(fixtures, '**/a/**', { ...opts, windows: false }), + [ + 'a', + 'a/a/a', + 'a/a/a/a', + 'a/a/a/a/a', + 'a/b', + 'a/x', + 'a/a', + 'a/a/b', + 'a/c' + ] + ); + assert.deepStrictEqual( + match(fixtures, '*/*', { ...opts, windows: false }), + ['a/b', 'a/x', 'z/z', 'a/a', 'a/c', 'x/y'] + ); + assert.deepStrictEqual( + match(fixtures, '*/*/*', { ...opts, windows: false }), + ['a/a/a', 'a/a/b'] + ); + assert.deepStrictEqual( + match(fixtures, '*/*/*/*', { ...opts, windows: false }), + ['a/a/a/a'] + ); + assert.deepStrictEqual( + match(fixtures, '*/*/*/*/*', { ...opts, windows: false }), + ['a/a/a/a/a'] + ); + assert.deepStrictEqual( + match(fixtures, './*', { ...opts, windows: false }), + ['a', 'b'] + ); + assert.deepStrictEqual( + match(fixtures, './**/a/**', { ...opts, windows: false }), + [ + 'a', + 'a/a/a', + 'a/a/a/a', + 'a/a/a/a/a', + 'a/b', + 'a/x', + 'a/a', + 'a/a/b', + 'a/c' + ] + ); + assert.deepStrictEqual( + match(fixtures, './a/*/a', { ...opts, windows: false }), + ['a/a/a'] + ); + assert.deepStrictEqual( + match(fixtures, 'a/*', { ...opts, windows: false }), + ['a/b', 'a/x', 'a/a', 'a/c'] + ); + assert.deepStrictEqual( + match(fixtures, 'a/*/*', { ...opts, windows: false }), + ['a/a/a', 'a/a/b'] + ); + assert.deepStrictEqual( + match(fixtures, 'a/*/*/*', { ...opts, windows: false }), + ['a/a/a/a'] + ); + assert.deepStrictEqual( + match(fixtures, 'a/*/*/*/*', { ...opts, windows: false }), + ['a/a/a/a/a'] + ); + assert.deepStrictEqual( + match(fixtures, 'a/*/a', { ...opts, windows: false }), + ['a/a/a'] + ); }); }); describe('windows', () => { it('should convert file paths to posix slashes', () => { - assert.deepStrictEqual(match(['a\\b\\c.md'], '**/*.md', { windows: true }), ['a/b/c.md']); - assert.deepStrictEqual(match(['a\\b\\c.md'], '**/*.md', { windows: false }), ['a\\b\\c.md']); + assert.deepStrictEqual( + match(['a\\b\\c.md'], '**/*.md', { windows: true }), + ['a/b/c.md'] + ); + assert.deepStrictEqual( + match(['a\\b\\c.md'], '**/*.md', { windows: false }), + ['a\\b\\c.md'] + ); }); it('should convert absolute paths to posix slashes', () => { - assert.deepStrictEqual(match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: true }), ['E:/a/b/c.md']); - assert.deepStrictEqual(match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: false }), []); + assert.deepStrictEqual( + match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: true }), + ['E:/a/b/c.md'] + ); + assert.deepStrictEqual( + match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: false }), + [] + ); }); }); }); diff --git a/test/options.onMatch.js b/test/options.onMatch.js index caf23355..e365b837 100644 --- a/test/options.onMatch.js +++ b/test/options.onMatch.js @@ -6,15 +6,22 @@ const picomatch = require('..'); const { isMatch } = picomatch; const equal = (actual, expected, msg) => { - assert.deepStrictEqual([].concat(actual).sort(), [].concat(expected).sort(), msg); + assert.deepStrictEqual( + [].concat(actual).sort(), + [].concat(expected).sort(), + msg + ); }; const format = str => str.replace(/^\.\//, ''); const options = () => { return { format, - onMatch({ pattern, regex, input, output }, matches) { - if (output.length > 2 && (output.startsWith('./') || output.startsWith('.\\'))) { + onMatch({ output }, matches) { + if ( + output.length > 2 && + (output.startsWith('./') || output.startsWith('.\\')) + ) { output = output.slice(2); } if (matches) { @@ -26,7 +33,21 @@ const options = () => { describe('options.onMatch', () => { it('should call options.onMatch on each matching string', () => { - const fixtures = ['a', './a', 'b', 'a/a', './a/b', 'a/c', './a/x', './a/a/a', 'a/a/b', './a/a/a/a', './a/a/a/a/a', 'x/y', './z/z']; + const fixtures = [ + 'a', + './a', + 'b', + 'a/a', + './a/b', + 'a/c', + './a/x', + './a/a/a', + 'a/a/b', + './a/a/a/a', + './a/a/a/a/a', + 'x/y', + './z/z' + ]; assert(!isMatch('./.a', '*.a', { format })); assert(!isMatch('./.a', './*.a', { format })); @@ -36,7 +57,9 @@ describe('options.onMatch', () => { assert(!isMatch('a/b/c/d/e/z/c.md', './a/**/j/**/z/*.md', { format })); assert(isMatch('./.a', './.a', { format })); assert(isMatch('./a/b/c.md', 'a/**/*.md', { format })); - assert(isMatch('./a/b/c/d/e/j/n/p/o/z/c.md', './a/**/j/**/z/*.md', { format })); + assert( + isMatch('./a/b/c/d/e/j/n/p/o/z/c.md', './a/**/j/**/z/*.md', { format }) + ); assert(isMatch('./a/b/c/d/e/z/c.md', '**/*.md', { format })); assert(isMatch('./a/b/c/d/e/z/c.md', './a/**/z/*.md', { format })); assert(isMatch('./a/b/c/d/e/z/c.md', 'a/**/z/*.md', { format })); @@ -51,13 +74,40 @@ describe('options.onMatch', () => { assert(isMatch('a/b/c/j/e/z/c.md', 'a/**/j/**/z/*.md', { format })); equal(match(fixtures, '*', options()), ['a', 'b']); - equal(match(fixtures, '**/a/**', options()), ['a', 'a/a', 'a/c', 'a/b', 'a/x', 'a/a/a', 'a/a/b', 'a/a/a/a', 'a/a/a/a/a']); - equal(match(fixtures, '*/*', options()), ['a/a', 'a/b', 'a/c', 'a/x', 'x/y', 'z/z']); + equal(match(fixtures, '**/a/**', options()), [ + 'a', + 'a/a', + 'a/c', + 'a/b', + 'a/x', + 'a/a/a', + 'a/a/b', + 'a/a/a/a', + 'a/a/a/a/a' + ]); + equal(match(fixtures, '*/*', options()), [ + 'a/a', + 'a/b', + 'a/c', + 'a/x', + 'x/y', + 'z/z' + ]); equal(match(fixtures, '*/*/*', options()), ['a/a/a', 'a/a/b']); equal(match(fixtures, '*/*/*/*', options()), ['a/a/a/a']); equal(match(fixtures, '*/*/*/*/*', options()), ['a/a/a/a/a']); equal(match(fixtures, './*', options()), ['a', 'b']); - equal(match(fixtures, './**/a/**', options()), ['a', 'a/a', 'a/b', 'a/c', 'a/x', 'a/a/a', 'a/a/b', 'a/a/a/a', 'a/a/a/a/a']); + equal(match(fixtures, './**/a/**', options()), [ + 'a', + 'a/a', + 'a/b', + 'a/c', + 'a/x', + 'a/a/a', + 'a/a/b', + 'a/a/a/a', + 'a/a/a/a/a' + ]); equal(match(fixtures, './a/*/a', options()), ['a/a/a']); equal(match(fixtures, 'a/*', options()), ['a/a', 'a/b', 'a/c', 'a/x']); equal(match(fixtures, 'a/*/*', options()), ['a/a/a', 'a/a/b']); diff --git a/test/posix-classes.js b/test/posix-classes.js index f3eed940..35750e78 100644 --- a/test/posix-classes.js +++ b/test/posix-classes.js @@ -15,16 +15,36 @@ describe('posix classes', () => { describe('posix bracket type conversion', () => { it('should create regex character classes from POSIX bracket expressions:', () => { assert.strictEqual(convert('foo[[:lower:]]bar'), 'foo[a-z]bar'); - assert.strictEqual(convert('foo[[:lower:][:upper:]]bar'), 'foo[a-zA-Z]bar'); + assert.strictEqual( + convert('foo[[:lower:][:upper:]]bar'), + 'foo[a-zA-Z]bar' + ); assert.strictEqual(convert('[[:alpha:]123]'), '(?=.)[a-zA-Z123]'); assert.strictEqual(convert('[[:lower:]]'), '(?=.)[a-z]'); assert.strictEqual(convert('[![:lower:]]'), '(?=.)[^a-z]'); - assert.strictEqual(convert('[[:digit:][:upper:][:space:]]'), '(?=.)[0-9A-Z \\t\\r\\n\\v\\f]'); + assert.strictEqual( + convert('[[:digit:][:upper:][:space:]]'), + '(?=.)[0-9A-Z \\t\\r\\n\\v\\f]' + ); assert.strictEqual(convert('[[:xdigit:]]'), '(?=.)[A-Fa-f0-9]'); - assert.strictEqual(convert('[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'), '(?=.)[a-zA-Z0-9a-zA-Z \\t\\x00-\\x1F\\x7F0-9\\x21-\\x7Ea-z\\x20-\\x7E \\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~ \\t\\r\\n\\v\\fA-ZA-Fa-f0-9]'); - assert.strictEqual(convert('[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'), '(?=.)[^a-zA-Z0-9a-zA-Z \\t\\x00-\\x1F\\x7F0-9a-z \\t\\r\\n\\v\\fA-ZA-Fa-f0-9]'); + assert.strictEqual( + convert( + '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]' + ), + '(?=.)[a-zA-Z0-9a-zA-Z \\t\\x00-\\x1F\\x7F0-9\\x21-\\x7Ea-z\\x20-\\x7E \\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~ \\t\\r\\n\\v\\fA-ZA-Fa-f0-9]' + ); + assert.strictEqual( + convert( + '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]' + ), + '(?=.)[^a-zA-Z0-9a-zA-Z \\t\\x00-\\x1F\\x7F0-9a-z \\t\\r\\n\\v\\fA-ZA-Fa-f0-9]' + ); assert.strictEqual(convert('[a-c[:digit:]x-z]'), '(?=.)[a-c0-9x-z]'); - assert.strictEqual(convert('[_[:alpha:]][_[:alnum:]][_[:alnum:]]*'), '(?=.)[_a-zA-Z][_a-zA-Z0-9][_a-zA-Z0-9]*', []); + assert.strictEqual( + convert('[_[:alpha:]][_[:alnum:]][_[:alnum:]]*'), + '(?=.)[_a-zA-Z][_a-zA-Z0-9][_a-zA-Z0-9]*', + [] + ); }); }); @@ -65,12 +85,30 @@ describe('posix classes', () => { assert(!isMatch('A', '[[:lower:]]')); assert(!isMatch('9', '[[:lower:]]')); - assert(isMatch('a', '[:alpha:]'), 'invalid posix bracket, but valid char class'); - assert(isMatch('l', '[:alpha:]'), 'invalid posix bracket, but valid char class'); - assert(isMatch('p', '[:alpha:]'), 'invalid posix bracket, but valid char class'); - assert(isMatch('h', '[:alpha:]'), 'invalid posix bracket, but valid char class'); - assert(isMatch(':', '[:alpha:]'), 'invalid posix bracket, but valid char class'); - assert(!isMatch('b', '[:alpha:]'), 'invalid posix bracket, but valid char class'); + assert( + isMatch('a', '[:alpha:]'), + 'invalid posix bracket, but valid char class' + ); + assert( + isMatch('l', '[:alpha:]'), + 'invalid posix bracket, but valid char class' + ); + assert( + isMatch('p', '[:alpha:]'), + 'invalid posix bracket, but valid char class' + ); + assert( + isMatch('h', '[:alpha:]'), + 'invalid posix bracket, but valid char class' + ); + assert( + isMatch(':', '[:alpha:]'), + 'invalid posix bracket, but valid char class' + ); + assert( + !isMatch('b', '[:alpha:]'), + 'invalid posix bracket, but valid char class' + ); }); it('should support multiple posix brackets in one character class', () => { @@ -133,7 +171,10 @@ describe('posix classes', () => { it('should not create an invalid posix character class:', () => { assert.strictEqual(convert('[:al:]'), '(?:\\[:al:\\]|[:al:])'); - assert.strictEqual(convert('[abc[:punct:][0-9]'), '(?=.)[abc\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~\\[0-9]'); + assert.strictEqual( + convert('[abc[:punct:][0-9]'), + '(?=.)[abc\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~\\[0-9]' + ); }); it('should return `true` when the pattern matches:', () => { @@ -145,9 +186,24 @@ describe('posix classes', () => { assert(isMatch('5', '[[:xdigit:]]')); assert(isMatch('f', '[[:xdigit:]]')); assert(isMatch('D', '[[:xdigit:]]')); - assert(isMatch('_', '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]')); - assert(isMatch('_', '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]')); - assert(isMatch('.', '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]')); + assert( + isMatch( + '_', + '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]' + ) + ); + assert( + isMatch( + '_', + '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]' + ) + ); + assert( + isMatch( + '.', + '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]' + ) + ); assert(isMatch('5', '[a-c[:digit:]x-z]')); assert(isMatch('b', '[a-c[:digit:]x-z]')); assert(isMatch('y', '[a-c[:digit:]x-z]')); @@ -159,7 +215,12 @@ describe('posix classes', () => { assert(!isMatch('a', '[[:upper:]]')); assert(!isMatch('a', '[[:digit:][:upper:][:space:]]')); assert(!isMatch('.', '[[:digit:][:upper:][:space:]]')); - assert(!isMatch('.', '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]')); + assert( + !isMatch( + '.', + '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]' + ) + ); assert(!isMatch('q', '[a-c[:digit:]x-z]')); }); }); @@ -185,7 +246,10 @@ describe('posix classes', () => { describe('.makeRe()', () => { it('should make a regular expression for the given pattern:', () => { - assert.deepStrictEqual(makeRe('[[:alpha:]123]', opts), /^(?:(?=.)[a-zA-Z123])$/); + assert.deepStrictEqual( + makeRe('[[:alpha:]123]', opts), + /^(?:(?=.)[a-zA-Z123])$/ + ); assert.deepStrictEqual(makeRe('[![:lower:]]', opts), /^(?:(?=.)[^a-z])$/); }); }); @@ -328,13 +392,13 @@ describe('posix classes', () => { assert(!isMatch('b', '[[:alpha:]\\]')); }); - it('OK, what\'s a tab? is it a blank? a space?', () => { + it("OK, what's a tab? is it a blank? a space?", () => { assert(isMatch('\t', '[[:blank:]]')); assert(isMatch('\t', '[[:space:]]')); assert(isMatch(' ', '[[:space:]]')); }); - it('let\'s check out characters in the ASCII range', () => { + it("let's check out characters in the ASCII range", () => { assert(!isMatch('\\377', '[[:ascii:]]')); assert(!isMatch('9', '[1[:alpha:]123]')); }); diff --git a/test/qmarks.js b/test/qmarks.js index 1a2dadf3..2f3b37de 100644 --- a/test/qmarks.js +++ b/test/qmarks.js @@ -15,30 +15,79 @@ describe('qmarks and stars', () => { assert.deepStrictEqual(match(['?', '??', '???'], '?*'), ['?', '??', '???']); assert.deepStrictEqual(match(['?', '??', '???'], '*?'), ['?', '??', '???']); assert.deepStrictEqual(match(['?', '??', '???'], '?*?'), ['??', '???']); - assert.deepStrictEqual(match(['?*', '?*?', '?*?*?'], '?*'), ['?*', '?*?', '?*?*?']); - assert.deepStrictEqual(match(['?*', '?*?', '?*?*?'], '*?'), ['?*', '?*?', '?*?*?']); - assert.deepStrictEqual(match(['?*', '?*?', '?*?*?'], '?*?'), ['?*', '?*?', '?*?*?']); + assert.deepStrictEqual(match(['?*', '?*?', '?*?*?'], '?*'), [ + '?*', + '?*?', + '?*?*?' + ]); + assert.deepStrictEqual(match(['?*', '?*?', '?*?*?'], '*?'), [ + '?*', + '?*?', + '?*?*?' + ]); + assert.deepStrictEqual(match(['?*', '?*?', '?*?*?'], '?*?'), [ + '?*', + '?*?', + '?*?*?' + ]); }); it('should support consecutive stars and question marks', () => { - assert.deepStrictEqual(match(['aaa', 'aac', 'abc'], 'a*?c'), ['aac', 'abc']); - assert.deepStrictEqual(match(['abc', 'abb', 'acc'], 'a**?c'), ['abc', 'acc']); - assert.deepStrictEqual(match(['abc', 'aaaabbbbbbccccc'], 'a*****?c'), ['abc', 'aaaabbbbbbccccc']); - assert.deepStrictEqual(match(['a', 'ab', 'abc', 'abcd'], '*****?'), ['a', 'ab', 'abc', 'abcd']); - assert.deepStrictEqual(match(['a', 'ab', 'abc', 'abcd'], '*****??'), ['ab', 'abc', 'abcd']); - assert.deepStrictEqual(match(['a', 'ab', 'abc', 'abcd'], '?*****??'), ['abc', 'abcd']); + assert.deepStrictEqual(match(['aaa', 'aac', 'abc'], 'a*?c'), [ + 'aac', + 'abc' + ]); + assert.deepStrictEqual(match(['abc', 'abb', 'acc'], 'a**?c'), [ + 'abc', + 'acc' + ]); + assert.deepStrictEqual(match(['abc', 'aaaabbbbbbccccc'], 'a*****?c'), [ + 'abc', + 'aaaabbbbbbccccc' + ]); + assert.deepStrictEqual(match(['a', 'ab', 'abc', 'abcd'], '*****?'), [ + 'a', + 'ab', + 'abc', + 'abcd' + ]); + assert.deepStrictEqual(match(['a', 'ab', 'abc', 'abcd'], '*****??'), [ + 'ab', + 'abc', + 'abcd' + ]); + assert.deepStrictEqual(match(['a', 'ab', 'abc', 'abcd'], '?*****??'), [ + 'abc', + 'abcd' + ]); assert.deepStrictEqual(match(['abc', 'abb', 'zzz'], '?*****?c'), ['abc']); - assert.deepStrictEqual(match(['abc', 'bbb', 'zzz'], '?***?****?'), ['abc', 'bbb', 'zzz']); + assert.deepStrictEqual(match(['abc', 'bbb', 'zzz'], '?***?****?'), [ + 'abc', + 'bbb', + 'zzz' + ]); assert.deepStrictEqual(match(['abc', 'bbb', 'zzz'], '?***?****c'), ['abc']); assert.deepStrictEqual(match(['abc'], '*******?'), ['abc']); assert.deepStrictEqual(match(['abc'], '*******c'), ['abc']); assert.deepStrictEqual(match(['abc'], '?***?****'), ['abc']); - assert.deepStrictEqual(match(['abcdecdhjk'], 'a****c**?**??*****'), ['abcdecdhjk']); - assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??***k'), ['abcdecdhjk']); - assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??***k**'), ['abcdecdhjk']); - assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??k'), ['abcdecdhjk']); - assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??k***'), ['abcdecdhjk']); - assert.deepStrictEqual(match(['abcdecdhjk'], 'a*cd**?**??k'), ['abcdecdhjk']); + assert.deepStrictEqual(match(['abcdecdhjk'], 'a****c**?**??*****'), [ + 'abcdecdhjk' + ]); + assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??***k'), [ + 'abcdecdhjk' + ]); + assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??***k**'), [ + 'abcdecdhjk' + ]); + assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??k'), [ + 'abcdecdhjk' + ]); + assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??k***'), [ + 'abcdecdhjk' + ]); + assert.deepStrictEqual(match(['abcdecdhjk'], 'a*cd**?**??k'), [ + 'abcdecdhjk' + ]); }); it('should match backslashes with question marks when not on windows', () => { @@ -54,17 +103,32 @@ describe('qmarks and stars', () => { assert.deepStrictEqual(match(fixtures, '?'), ['a']); assert.deepStrictEqual(match(fixtures, '??'), ['aa', 'ab']); assert.deepStrictEqual(match(fixtures, '???'), ['aaa']); - assert.deepStrictEqual(match(['a/', '/a/', '/a/b/', '/a/b/c/', '/a/b/c/d/'], '??'), []); + assert.deepStrictEqual( + match(['a/', '/a/', '/a/b/', '/a/b/c/', '/a/b/c/d/'], '??'), + [] + ); assert.deepStrictEqual(match(['a/b/c.md'], 'a/?/c.md'), ['a/b/c.md']); assert.deepStrictEqual(match(['a/bb/c.md'], 'a/?/c.md'), []); assert.deepStrictEqual(match(['a/bb/c.md'], 'a/??/c.md'), ['a/bb/c.md']); assert.deepStrictEqual(match(['a/bbb/c.md'], 'a/??/c.md'), []); assert.deepStrictEqual(match(['a/bbb/c.md'], 'a/???/c.md'), ['a/bbb/c.md']); - assert.deepStrictEqual(match(['a/bbbb/c.md'], 'a/????/c.md'), ['a/bbbb/c.md']); + assert.deepStrictEqual(match(['a/bbbb/c.md'], 'a/????/c.md'), [ + 'a/bbbb/c.md' + ]); }); it('should not match slashes question marks', () => { - const fixtures = ['//', 'a/', '/a', '/a/', 'aa', '/aa', 'a/a', 'aaa', '/aaa']; + const fixtures = [ + '//', + 'a/', + '/a', + '/a/', + 'aa', + '/aa', + 'a/a', + 'aaa', + '/aaa' + ]; assert.deepStrictEqual(match(fixtures, '/?'), ['/a']); assert.deepStrictEqual(match(fixtures, '/??'), ['/aa']); assert.deepStrictEqual(match(fixtures, '/???'), ['/aaa']); @@ -78,20 +142,41 @@ describe('qmarks and stars', () => { }); it('should support question marks and stars between slashes', () => { - assert.deepStrictEqual(match(['a/b.bb/c/d/efgh.ijk/e'], 'a/*/?/**/e'), ['a/b.bb/c/d/efgh.ijk/e']); + assert.deepStrictEqual(match(['a/b.bb/c/d/efgh.ijk/e'], 'a/*/?/**/e'), [ + 'a/b.bb/c/d/efgh.ijk/e' + ]); assert.deepStrictEqual(match(['a/b/c/d/e'], 'a/?/c/?/*/e'), []); - assert.deepStrictEqual(match(['a/b/c/d/e/e'], 'a/?/c/?/*/e'), ['a/b/c/d/e/e']); - assert.deepStrictEqual(match(['a/b/c/d/efgh.ijk/e'], 'a/*/?/**/e'), ['a/b/c/d/efgh.ijk/e']); - assert.deepStrictEqual(match(['a/b/c/d/efghijk/e'], 'a/*/?/**/e'), ['a/b/c/d/efghijk/e']); - assert.deepStrictEqual(match(['a/b/c/d/efghijk/e'], 'a/?/**/e'), ['a/b/c/d/efghijk/e']); - assert.deepStrictEqual(match(['a/b/c/d/efghijk/e'], 'a/?/c/?/*/e'), ['a/b/c/d/efghijk/e']); + assert.deepStrictEqual(match(['a/b/c/d/e/e'], 'a/?/c/?/*/e'), [ + 'a/b/c/d/e/e' + ]); + assert.deepStrictEqual(match(['a/b/c/d/efgh.ijk/e'], 'a/*/?/**/e'), [ + 'a/b/c/d/efgh.ijk/e' + ]); + assert.deepStrictEqual(match(['a/b/c/d/efghijk/e'], 'a/*/?/**/e'), [ + 'a/b/c/d/efghijk/e' + ]); + assert.deepStrictEqual(match(['a/b/c/d/efghijk/e'], 'a/?/**/e'), [ + 'a/b/c/d/efghijk/e' + ]); + assert.deepStrictEqual(match(['a/b/c/d/efghijk/e'], 'a/?/c/?/*/e'), [ + 'a/b/c/d/efghijk/e' + ]); assert.deepStrictEqual(match(['a/bb/e'], 'a/?/**/e'), []); assert.deepStrictEqual(match(['a/bb/e'], 'a/?/e'), []); - assert.deepStrictEqual(match(['a/bbb/c/d/efgh.ijk/e'], 'a/*/?/**/e'), ['a/bbb/c/d/efgh.ijk/e']); + assert.deepStrictEqual(match(['a/bbb/c/d/efgh.ijk/e'], 'a/*/?/**/e'), [ + 'a/bbb/c/d/efgh.ijk/e' + ]); }); it('should match no more than one character between slashes', () => { - const fixtures = ['a/a', 'a/a/a', 'a/aa/a', 'a/aaa/a', 'a/aaaa/a', 'a/aaaaa/a']; + const fixtures = [ + 'a/a', + 'a/a/a', + 'a/aa/a', + 'a/aaa/a', + 'a/aaaa/a', + 'a/aaaaa/a' + ]; assert.deepStrictEqual(match(fixtures, '?/?'), ['a/a']); assert.deepStrictEqual(match(fixtures, '?/???/?'), ['a/aaa/a']); assert.deepStrictEqual(match(fixtures, '?/????/?'), ['a/aaaa/a']); @@ -105,7 +190,18 @@ describe('qmarks and stars', () => { }); it('should not match non-leading dots with question marks', () => { - const fixtures = ['.', '.a', 'a', 'aa', 'a.a', 'aa.a', 'aaa', 'aaa.a', 'aaaa.a', 'aaaaa']; + const fixtures = [ + '.', + '.a', + 'a', + 'aa', + 'a.a', + 'aa.a', + 'aaa', + 'aaa.a', + 'aaaa.a', + 'aaaaa' + ]; assert.deepStrictEqual(match(fixtures, '?'), ['a']); assert.deepStrictEqual(match(fixtures, '.?'), ['.a']); assert.deepStrictEqual(match(fixtures, '?a'), ['aa']); @@ -118,7 +214,18 @@ describe('qmarks and stars', () => { }); it('should match non-leading dots with question marks when options.dot is true', () => { - const fixtures = ['.', '.a', 'a', 'aa', 'a.a', 'aa.a', '.aa', 'aaa.a', 'aaaa.a', 'aaaaa']; + const fixtures = [ + '.', + '.a', + 'a', + 'aa', + 'a.a', + 'aa.a', + '.aa', + 'aaa.a', + 'aaaa.a', + 'aaaaa' + ]; const opts = { dot: true }; assert.deepStrictEqual(match(fixtures, '?', opts), ['.', 'a']); assert.deepStrictEqual(match(fixtures, '.?', opts), ['.a']); diff --git a/test/slashes-posix.js b/test/slashes-posix.js index cd4d0b9f..d8d2df5c 100644 --- a/test/slashes-posix.js +++ b/test/slashes-posix.js @@ -1151,7 +1151,9 @@ describe('slash handling - posix', () => { const format = str => str.replace(/^\.\//, ''); assert(!isMatch('./a/b/c/d/e/z/c.md', './a/**/j/**/z/*.md', { format })); assert(!isMatch('./a/b/c/j/e/z/c.txt', './a/**/j/**/z/*.md', { format })); - assert(isMatch('./a/b/c/d/e/j/n/p/o/z/c.md', './a/**/j/**/z/*.md', { format })); + assert( + isMatch('./a/b/c/d/e/j/n/p/o/z/c.md', './a/**/j/**/z/*.md', { format }) + ); assert(isMatch('./a/b/c/d/e/z/c.md', './a/**/z/*.md', { format })); assert(isMatch('./a/b/c/j/e/z/c.md', './a/**/j/**/z/*.md', { format })); assert(isMatch('./a/b/z/.a', './a/**/z/.a', { format })); @@ -1198,14 +1200,55 @@ describe('slash handling - posix', () => { assert(!isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/*')); assert(!isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/*')); assert(isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/**')); - assert(!isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/**', { noglobstar: true })); + assert( + !isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/**', { + noglobstar: true + }) + ); assert(isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/**')); - assert(isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/**/app.min.js')); - assert(isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/*/*/app.min.js')); - assert(isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/*/*/app.min.js', { noglobstar: true })); - assert(!isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/*/app.min.js')); - assert(!isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/*/app.min.js')); - assert(isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/**/app.min.js')); - assert(!isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/**/app.min.js', { noglobstar: true })); + assert( + isMatch( + 'https://foo.com/bar/baz/app.min.js', + 'https://foo.com/**/app.min.js' + ) + ); + assert( + isMatch( + 'https://foo.com/bar/baz/app.min.js', + 'https://foo.com/*/*/app.min.js' + ) + ); + assert( + isMatch( + 'https://foo.com/bar/baz/app.min.js', + 'https://foo.com/*/*/app.min.js', + { noglobstar: true } + ) + ); + assert( + !isMatch( + 'https://foo.com/bar/baz/app.min.js', + 'https://foo.com/*/app.min.js' + ) + ); + assert( + !isMatch( + 'https://foo.com/bar/baz/app.min.js', + 'https://foo.com/*/app.min.js' + ) + ); + assert( + isMatch( + 'https://foo.com/bar/baz/app.min.js', + 'https://foo.com/**/app.min.js' + ) + ); + assert( + !isMatch( + 'https://foo.com/bar/baz/app.min.js', + 'https://foo.com/**/app.min.js', + { noglobstar: true } + ) + ); }); }); diff --git a/test/slashes-windows.js b/test/slashes-windows.js index 1e109948..584fd438 100644 --- a/test/slashes-windows.js +++ b/test/slashes-windows.js @@ -6,7 +6,11 @@ const { isMatch, makeRe } = require('..'); describe('slash handling - windows', () => { it('should match absolute windows paths with regex from makeRe', () => { const regex = makeRe('**/path/**', { windows: true }); - assert(regex.test('C:\\Users\\user\\Projects\\project\\path\\image.jpg', { windows: true })); + assert( + regex.test('C:\\Users\\user\\Projects\\project\\path\\image.jpg', { + windows: true + }) + ); }); it('should match windows path separators with a string literal', () => { diff --git a/test/special-characters.js b/test/special-characters.js index c6958a51..579643cf 100644 --- a/test/special-characters.js +++ b/test/special-characters.js @@ -270,7 +270,9 @@ describe('special characters', () => { assert(isMatch('\\\\foo/bar', '//*/*', { windows: true })); assert(isMatch('\\\\unc\\admin$', '**', { windows: true })); assert(isMatch('\\\\unc\\admin$', '//*/*$', { windows: true })); - assert(isMatch('\\\\unc\\admin$\\system32', '//*/*$/*32', { windows: true })); + assert( + isMatch('\\\\unc\\admin$\\system32', '//*/*$/*32', { windows: true }) + ); assert(isMatch('\\\\unc\\share\\foo', '//u*/s*/f*', { windows: true })); assert(isMatch('foo\\bar\\baz', 'f*/*/*', { windows: true })); }); @@ -284,9 +286,16 @@ describe('special characters', () => { assert(isMatch('\\\\foo/bar', '//*/*', { windows: true })); assert(isMatch('\\\\unc\\admin$', '//**', { windows: true })); assert(isMatch('\\\\unc\\admin$', '//*/*$', { windows: true })); - assert(isMatch('\\\\unc\\admin$\\system32', '//*/*$/*32', { windows: true })); + assert( + isMatch('\\\\unc\\admin$\\system32', '//*/*$/*32', { windows: true }) + ); assert(isMatch('\\\\unc\\share\\foo', '//u*/s*/f*', { windows: true })); - assert(isMatch('\\\\\\\\\\\\unc\\share\\foo', '/\\{1,\\}u*/s*/f*', { windows: true, unescape: true })); + assert( + isMatch('\\\\\\\\\\\\unc\\share\\foo', '/\\{1,\\}u*/s*/f*', { + windows: true, + unescape: true + }) + ); assert(isMatch('foo\\bar\\baz', 'f*/*/*', { windows: true })); assert(isMatch('//*:/**', '**')); assert(!isMatch('//server/file', '//*')); diff --git a/test/wildmat.js b/test/wildmat.js index c61195e5..5f39d71c 100644 --- a/test/wildmat.js +++ b/test/wildmat.js @@ -20,11 +20,26 @@ describe('Wildmat (git) tests', () => { }); it('should support recursion', () => { - assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*')); - assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*')); + assert( + !isMatch( + '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1', + '-*-*-*-*-*-*-12-*-*-*-m-*-*-*' + ) + ); + assert( + !isMatch( + '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1', + '-*-*-*-*-*-*-12-*-*-*-m-*-*-*' + ) + ); assert(!isMatch('ab/cXd/efXg/hi', '*X*i')); assert(!isMatch('ab/cXd/efXg/hi', '*Xg*i')); - assert(!isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz', '**/*a*b*g*n*t')); + assert( + !isMatch( + 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz', + '**/*a*b*g*n*t' + ) + ); assert(!isMatch('foo', '*/*/*')); assert(!isMatch('foo', 'fo')); assert(!isMatch('foo/bar', '*/*/*')); @@ -37,11 +52,23 @@ describe('Wildmat (git) tests', () => { assert(!isMatch('foo/bba/arr', 'foo/**z')); assert(!isMatch('foo/bba/arr', 'foo/*arr')); assert(!isMatch('foo/bba/arr', 'foo/*z')); - assert(!isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*')); - assert(isMatch('-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*')); + assert( + !isMatch( + 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1', + 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*' + ) + ); + assert( + isMatch( + '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1', + '-*-*-*-*-*-*-12-*-*-*-m-*-*-*' + ) + ); assert(isMatch('ab/cXd/efXg/hi', '**/*X*/**/*i')); assert(isMatch('ab/cXd/efXg/hi', '*/*X*/*/*i')); - assert(isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt', '**/*a*b*g*n*t')); + assert( + isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt', '**/*a*b*g*n*t') + ); assert(isMatch('abcXdefXghi', '*X*i')); assert(isMatch('foo', 'foo')); assert(isMatch('foo/bar', 'foo/*')); From 0557d1d18a6b596a739050fd97671b43c5b0a196 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Wed, 18 Mar 2026 19:49:22 +0100 Subject: [PATCH 2/6] chore: Remove codeql and active in repo settings --- .github/workflows/codeql.yml | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 31696b7c..00000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: "CodeQL" - -on: - push: - pull_request: - schedule: - - cron: "0 0 * * 0" - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: "javascript" - - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 From 61f78d998e89088ebd7568f76ef8ee45873f36b1 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Wed, 18 Mar 2026 20:05:58 +0100 Subject: [PATCH 3/6] run less workflows in prs --- .github/workflows/test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d3b0ca48..0323099d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,10 @@ name: Tests -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: env: FORCE_COLOR: 2 From 9645141b1b26cf1f714c323583895ed2eb42d337 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Wed, 18 Mar 2026 20:08:30 +0100 Subject: [PATCH 4/6] update actions --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0323099d..8bb3e5d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,10 +27,10 @@ jobs: steps: - name: Clone repository - uses: actions/checkout@v2 + uses: actions/checkout@v6 - name: Setup Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v6 with: node-version: ${{ matrix.node }} From 32343abe4bd49441cedf3f8264a7b0d785b477ba Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Thu, 19 Mar 2026 22:25:38 +0100 Subject: [PATCH 5/6] Revert "chore: use prettier, update eslint, add node 24 and 25 to ci" This reverts commit 02b2d38f351fc35bff7b32944ed0b772f99b5495. --- .eslintrc.json | 124 +++ .github/workflows/test.yml | 2 +- .prettierrc.json | 5 - bench/glob-parent.js | 8 +- eslint.config.mjs | 47 -- examples/match.js | 11 +- examples/option-onMatch.js | 2 +- examples/option-onResult.js | 2 +- lib/constants.js | 86 +- lib/parse.js | 207 ++--- lib/picomatch.js | 34 +- lib/scan.js | 55 +- lib/utils.js | 4 +- package.json | 9 +- test/api.picomatch.js | 19 +- test/api.scan.js | 282 ++----- test/bash.js | 2 +- test/braces.js | 40 +- test/dotfiles.js | 138 +--- test/dots-invalid.js | 1523 ++++++++--------------------------- test/extglobs-bash.js | 454 ++--------- test/extglobs-minimatch.js | 126 +-- test/extglobs-temp.js | 440 +++------- test/extglobs.js | 111 +-- test/globstars.js | 150 +--- test/issue-related.js | 8 +- test/malicious.js | 25 +- test/minimatch.js | 8 +- test/negation.js | 16 +- test/options.expandRange.js | 20 +- test/options.format.js | 59 +- test/options.ignore.js | 110 +-- test/options.js | 489 ++--------- test/options.onMatch.js | 66 +- test/posix-classes.js | 102 +-- test/qmarks.js | 165 +--- test/slashes-posix.js | 61 +- test/slashes-windows.js | 6 +- test/special-characters.js | 15 +- test/wildmat.js | 39 +- 40 files changed, 1149 insertions(+), 3921 deletions(-) create mode 100644 .eslintrc.json delete mode 100644 .prettierrc.json delete mode 100644 eslint.config.mjs diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..ba84ad66 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,124 @@ +{ + "extends": [ + "eslint:recommended" + ], + + "env": { + "es6": true, + "node": true + }, + + "parserOptions": { + "ecmaVersion": 2018 + }, + + "rules": { + "accessor-pairs": 2, + "arrow-parens": [2, "as-needed"], + "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-implicit-coercion": 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-lonely-if": 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": 2, + "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": 2, + "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": 2, + "no-undef": 2, + "no-undef-init": 2, + "no-unexpected-multiline": 2, + "no-unneeded-ternary": [2, { "defaultAssignment": false }], + "no-unreachable": 2, + "no-unused-expressions": 2, + "no-unused-vars": [2, { "vars": "all", "args": "none" }], + "no-useless-call": 2, + "no-with": 2, + "object-curly-spacing": ["error", "always", { "objectsInObjects": true }], + "one-var": [2, { "initialized": "never" }], + "operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }], + "padded-blocks": [0, "never"], + "prefer-const": [2, { "destructuring": "all", "ignoreReadBeforeAssign": false }], + "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, { "anonymous": "never", "named": "never", "asyncArrow": "always" }], + "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", "!", ","] }], + "strict": 2, + "use-isnan": 2, + "valid-typeof": 2, + "wrap-iife": [2, "any"], + "yoda": [2, "never"] + } +} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8bb3e5d5..926dcc8a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - node: [12, 14, 16, 18, 20, 22, 24, 25] + node: [12, 14, 16, 18, 20, 22, 23] os: [ubuntu-latest, windows-latest, macos-latest] exclude: - os: macos-latest diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index 4b5afdb2..00000000 --- a/.prettierrc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "singleQuote": true, - "arrowParens": "avoid", - "trailingComma": "none" -} diff --git a/bench/glob-parent.js b/bench/glob-parent.js index 279b444d..2790415a 100644 --- a/bench/glob-parent.js +++ b/bench/glob-parent.js @@ -68,9 +68,7 @@ bench('*.js { parts: true, tokens: true }') .run(); bench('foo/bar/baz { parts: true, tokens: true }') - .add('picomatch.scan', () => - scan('foo/bar/baz', { parts: true, tokens: true }) - ) + .add('picomatch.scan', () => scan('foo/bar/baz', { parts: true, tokens: true })) .add(' glob-parent', () => parent('foo/bar/baz')) .run(); @@ -80,8 +78,6 @@ bench('foo/*.js { parts: true, tokens: true }') .run(); bench('foo/{a,b}/*.js { parts: true, tokens: true }') - .add('picomatch.scan', () => - scan('foo/{a,b}/*.js', { parts: true, tokens: true }) - ) + .add('picomatch.scan', () => scan('foo/{a,b}/*.js', { parts: true, tokens: true })) .add(' glob-parent', () => parent('foo/{a,b}/*.js')) .run(); diff --git a/eslint.config.mjs b/eslint.config.mjs deleted file mode 100644 index 4ef3ac94..00000000 --- a/eslint.config.mjs +++ /dev/null @@ -1,47 +0,0 @@ -import { globalIgnores, defineConfig } from 'eslint/config'; -import globals from 'globals'; -import js from '@eslint/js'; -import prettierRecommended from 'eslint-plugin-prettier/recommended'; - -export default defineConfig([ - globalIgnores(['**/coverage', '**/node_modules']), - js.configs.recommended, - { - files: ['**/*.js', '**/*.cjs'], - languageOptions: { - globals: { - ...globals.node - }, - - ecmaVersion: 2018, - sourceType: 'script' - }, - - rules: { - 'prefer-const': 'error', - strict: ['error', 'global'] - } - }, - { - files: ['test/**/*.js', 'test/**/*.cjs'], - languageOptions: { - globals: { - ...globals.node, - ...globals.mocha - } - } - }, - { - files: ['**/*.mjs'], - - languageOptions: { - globals: { - ...globals.node - }, - - ecmaVersion: 2018, - sourceType: 'module' - } - }, - prettierRecommended -]); diff --git a/examples/match.js b/examples/match.js index d40411b4..aca9f949 100644 --- a/examples/match.js +++ b/examples/match.js @@ -28,16 +28,7 @@ const match = (list, pattern, options = {}) => { return [...matches]; }; -const 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' -]; +const 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')); diff --git a/examples/option-onMatch.js b/examples/option-onMatch.js index a803fd33..3ceb2a85 100644 --- a/examples/option-onMatch.js +++ b/examples/option-onMatch.js @@ -2,7 +2,7 @@ const pm = require('..'); -const onMatch = ({ input, output }) => { +const onMatch = ({ glob, regex, input, output }) => { console.log({ input, output }); // { input: 'some\\path', output: 'some/path' } // { input: 'some\\path', output: 'some/path' } diff --git a/examples/option-onResult.js b/examples/option-onResult.js index 659ce56d..2c5aa453 100644 --- a/examples/option-onResult.js +++ b/examples/option-onResult.js @@ -2,7 +2,7 @@ const pm = require('..'); -const onResult = ({ input, output }) => { +const onResult = ({ glob, regex, input, output }) => { console.log({ input, output }); }; diff --git a/lib/constants.js b/lib/constants.js index c562cfed..3f7ef7e5 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -106,55 +106,55 @@ module.exports = { }, // Digits - CHAR_0: 48 /* 0 */, - CHAR_9: 57 /* 9 */, + CHAR_0: 48, /* 0 */ + CHAR_9: 57, /* 9 */ // Alphabet chars. - CHAR_UPPERCASE_A: 65 /* A */, - CHAR_LOWERCASE_A: 97 /* a */, - CHAR_UPPERCASE_Z: 90 /* Z */, - CHAR_LOWERCASE_Z: 122 /* z */, + CHAR_UPPERCASE_A: 65, /* A */ + CHAR_LOWERCASE_A: 97, /* a */ + CHAR_UPPERCASE_Z: 90, /* Z */ + CHAR_LOWERCASE_Z: 122, /* z */ - CHAR_LEFT_PARENTHESES: 40 /* ( */, - CHAR_RIGHT_PARENTHESES: 41 /* ) */, + CHAR_LEFT_PARENTHESES: 40, /* ( */ + CHAR_RIGHT_PARENTHESES: 41, /* ) */ - CHAR_ASTERISK: 42 /* * */, + CHAR_ASTERISK: 42, /* * */ // Non-alphabetic chars. - CHAR_AMPERSAND: 38 /* & */, - CHAR_AT: 64 /* @ */, - CHAR_BACKWARD_SLASH: 92 /* \ */, - CHAR_CARRIAGE_RETURN: 13 /* \r */, - CHAR_CIRCUMFLEX_ACCENT: 94 /* ^ */, - CHAR_COLON: 58 /* : */, - CHAR_COMMA: 44 /* , */, - CHAR_DOT: 46 /* . */, - CHAR_DOUBLE_QUOTE: 34 /* " */, - CHAR_EQUAL: 61 /* = */, - CHAR_EXCLAMATION_MARK: 33 /* ! */, - CHAR_FORM_FEED: 12 /* \f */, - CHAR_FORWARD_SLASH: 47 /* / */, - CHAR_GRAVE_ACCENT: 96 /* ` */, - CHAR_HASH: 35 /* # */, - CHAR_HYPHEN_MINUS: 45 /* - */, - CHAR_LEFT_ANGLE_BRACKET: 60 /* < */, - CHAR_LEFT_CURLY_BRACE: 123 /* { */, - CHAR_LEFT_SQUARE_BRACKET: 91 /* [ */, - CHAR_LINE_FEED: 10 /* \n */, - CHAR_NO_BREAK_SPACE: 160 /* \u00A0 */, - CHAR_PERCENT: 37 /* % */, - CHAR_PLUS: 43 /* + */, - CHAR_QUESTION_MARK: 63 /* ? */, - CHAR_RIGHT_ANGLE_BRACKET: 62 /* > */, - CHAR_RIGHT_CURLY_BRACE: 125 /* } */, - CHAR_RIGHT_SQUARE_BRACKET: 93 /* ] */, - CHAR_SEMICOLON: 59 /* ; */, - CHAR_SINGLE_QUOTE: 39 /* ' */, - CHAR_SPACE: 32 /* */, - CHAR_TAB: 9 /* \t */, - CHAR_UNDERSCORE: 95 /* _ */, - CHAR_VERTICAL_LINE: 124 /* | */, - CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279 /* \uFEFF */, + CHAR_AMPERSAND: 38, /* & */ + CHAR_AT: 64, /* @ */ + CHAR_BACKWARD_SLASH: 92, /* \ */ + CHAR_CARRIAGE_RETURN: 13, /* \r */ + CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */ + CHAR_COLON: 58, /* : */ + CHAR_COMMA: 44, /* , */ + CHAR_DOT: 46, /* . */ + CHAR_DOUBLE_QUOTE: 34, /* " */ + CHAR_EQUAL: 61, /* = */ + CHAR_EXCLAMATION_MARK: 33, /* ! */ + CHAR_FORM_FEED: 12, /* \f */ + CHAR_FORWARD_SLASH: 47, /* / */ + CHAR_GRAVE_ACCENT: 96, /* ` */ + CHAR_HASH: 35, /* # */ + CHAR_HYPHEN_MINUS: 45, /* - */ + CHAR_LEFT_ANGLE_BRACKET: 60, /* < */ + CHAR_LEFT_CURLY_BRACE: 123, /* { */ + CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */ + CHAR_LINE_FEED: 10, /* \n */ + CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */ + CHAR_PERCENT: 37, /* % */ + CHAR_PLUS: 43, /* + */ + CHAR_QUESTION_MARK: 63, /* ? */ + CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */ + CHAR_RIGHT_CURLY_BRACE: 125, /* } */ + CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */ + CHAR_SEMICOLON: 59, /* ; */ + CHAR_SINGLE_QUOTE: 39, /* ' */ + CHAR_SPACE: 32, /* */ + CHAR_TAB: 9, /* \t */ + CHAR_UNDERSCORE: 95, /* _ */ + CHAR_VERTICAL_LINE: 124, /* | */ + CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */ /** * Create EXTGLOB_CHARS diff --git a/lib/parse.js b/lib/parse.js index 177dc283..8fd8ff49 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -28,8 +28,8 @@ const expandRange = (args, options) => { const value = `[${args.join('-')}]`; try { + /* eslint-disable-next-line no-new */ new RegExp(value); - // eslint-disable-next-line no-unused-vars } catch (ex) { return args.map(v => utils.escapeRegex(v)).join('..'); } @@ -60,16 +60,11 @@ const parse = (input, options) => { input = REPLACEMENTS[input] || input; const opts = { ...options }; - const max = - typeof opts.maxLength === 'number' - ? Math.min(MAX_LENGTH, opts.maxLength) - : MAX_LENGTH; + const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH; let len = input.length; if (len > max) { - throw new SyntaxError( - `Input length: ${len}, exceeds maximum allowed length: ${max}` - ); + throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); } const bos = { type: 'bos', value: '', output: opts.prepend || '' }; @@ -145,8 +140,8 @@ const parse = (input, options) => { */ const eos = () => state.index === len - 1; - const peek = (state.peek = (n = 1) => input[state.index + n]); - const advance = (state.advance = () => input[++state.index] || ''); + const peek = state.peek = (n = 1) => input[state.index + n]; + const advance = state.advance = () => input[++state.index] || ''; const remaining = () => input.slice(state.index + 1); const consume = (value = '', num = 0) => { state.consumed += value; @@ -196,18 +191,10 @@ const parse = (input, options) => { const push = tok => { if (prev.type === 'globstar') { - const isBrace = - state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace'); - const isExtglob = - tok.extglob === true || - (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren')); - - if ( - tok.type !== 'slash' && - tok.type !== 'paren' && - !isBrace && - !isExtglob - ) { + const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace'); + const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren')); + + if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) { state.output = state.output.slice(0, -prev.output.length); prev.type = 'star'; prev.value = '*'; @@ -261,11 +248,7 @@ const parse = (input, options) => { output = token.close = `)$))${extglobStar}`; } - if ( - token.inner.includes('*') && - (rest = remaining()) && - /^\.[^\\/.]+$/.test(rest) - ) { + if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) { // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis. // In this case, we need to parse the string and use it in the output of the original pattern. // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`. @@ -292,44 +275,41 @@ const parse = (input, options) => { if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) { let backslashes = false; - let output = input.replace( - REGEX_SPECIAL_CHARS_BACKREF, - (m, esc, chars, first, rest, index) => { - if (first === '\\') { - backslashes = true; - return m; - } + let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => { + if (first === '\\') { + backslashes = true; + return m; + } - if (first === '?') { - if (esc) { - return esc + first + (rest ? QMARK.repeat(rest.length) : ''); - } - if (index === 0) { - return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : ''); - } - return QMARK.repeat(chars.length); + if (first === '?') { + if (esc) { + return esc + first + (rest ? QMARK.repeat(rest.length) : ''); } - - if (first === '.') { - return DOT_LITERAL.repeat(chars.length); + if (index === 0) { + return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : ''); } + return QMARK.repeat(chars.length); + } - if (first === '*') { - if (esc) { - return esc + first + (rest ? star : ''); - } - return star; + if (first === '.') { + return DOT_LITERAL.repeat(chars.length); + } + + if (first === '*') { + if (esc) { + return esc + first + (rest ? star : ''); } - return esc ? m : `\\${m}`; + return star; } - ); + return esc ? m : `\\${m}`; + }); if (backslashes === true) { if (opts.unescape === true) { output = output.replace(/\\/g, ''); } else { output = output.replace(/\\+/g, m => { - return m.length % 2 === 0 ? '\\\\' : m ? '\\' : ''; + return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : ''); }); } } @@ -377,9 +357,10 @@ const parse = (input, options) => { // collapse slashes to reduce potential for exploits const match = /^\\+/.exec(remaining()); + let slashes = 0; if (match && match[0].length > 2) { - const slashes = match[0].length; + slashes = match[0].length; state.index += slashes; if (slashes % 2 !== 0) { value += '\\'; @@ -403,10 +384,7 @@ const parse = (input, options) => { * until we reach the closing bracket. */ - if ( - state.brackets > 0 && - (value !== ']' || prev.value === '[' || prev.value === '[^') - ) { + if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) { if (opts.posix !== false && value === ':') { const inner = prev.value.slice(1); if (inner.includes('[')) { @@ -431,10 +409,7 @@ const parse = (input, options) => { } } - if ( - (value === '[' && peek() !== ':') || - (value === '-' && peek() === ']') - ) { + if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) { value = `\\${value}`; } @@ -521,10 +496,7 @@ const parse = (input, options) => { } if (value === ']') { - if ( - opts.nobracket === true || - (prev && prev.type === 'bracket' && prev.value.length === 1) - ) { + if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) { push({ type: 'text', value, output: `\\${value}` }); continue; } @@ -541,11 +513,7 @@ const parse = (input, options) => { decrement('brackets'); const prevValue = prev.value.slice(1); - if ( - prev.posix !== true && - prevValue[0] === '^' && - !prevValue.includes('/') - ) { + if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) { value = `/${value}`; } @@ -630,7 +598,7 @@ const parse = (input, options) => { value = output = '\\}'; state.output = out; for (const t of toks) { - state.output += t.output || t.value; + state.output += (t.output || t.value); } } @@ -706,11 +674,7 @@ const parse = (input, options) => { continue; } - if ( - state.braces + state.parens === 0 && - prev.type !== 'bos' && - prev.type !== 'slash' - ) { + if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') { push({ type: 'text', value, output: DOT_LITERAL }); continue; } @@ -725,12 +689,7 @@ const parse = (input, options) => { if (value === '?') { const isGroup = prev && prev.value === '('; - if ( - !isGroup && - opts.noextglob !== true && - peek() === '(' && - peek(2) !== '?' - ) { + if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { extglobOpen('qmark', value); continue; } @@ -739,10 +698,7 @@ const parse = (input, options) => { const next = peek(); let output = value; - if ( - (prev.value === '(' && !/[!=<:]/.test(next)) || - (next === '<' && !/<([!=]|\w+>)/.test(remaining())) - ) { + if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) { output = `\\${value}`; } @@ -792,13 +748,7 @@ const parse = (input, options) => { continue; } - if ( - (prev && - (prev.type === 'bracket' || - prev.type === 'paren' || - prev.type === 'brace')) || - state.parens > 0 - ) { + if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) { push({ type: 'plus', value }); continue; } @@ -870,18 +820,15 @@ const parse = (input, options) => { const prior = prev.prev; const before = prior.prev; const isStart = prior.type === 'slash' || prior.type === 'bos'; - const afterStar = - before && (before.type === 'star' || before.type === 'globstar'); + const afterStar = before && (before.type === 'star' || before.type === 'globstar'); if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) { push({ type: 'star', value, output: '' }); continue; } - const isBrace = - state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace'); - const isExtglob = - extglobs.length && (prior.type === 'pipe' || prior.type === 'paren'); + const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace'); + const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren'); if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) { push({ type: 'star', value, output: '' }); continue; @@ -907,16 +854,8 @@ const parse = (input, options) => { continue; } - if ( - prior.type === 'slash' && - prior.prev.type !== 'bos' && - !afterStar && - eos() - ) { - state.output = state.output.slice( - 0, - -(prior.output + prev.output).length - ); + if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { + state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; @@ -928,17 +867,10 @@ const parse = (input, options) => { continue; } - if ( - prior.type === 'slash' && - prior.prev.type !== 'bos' && - rest[0] === '/' - ) { + if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') { const end = rest[1] !== void 0 ? '|$' : ''; - state.output = state.output.slice( - 0, - -(prior.output + prev.output).length - ); + state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; @@ -991,27 +923,21 @@ const parse = (input, options) => { continue; } - if ( - prev && - (prev.type === 'bracket' || prev.type === 'paren') && - opts.regex === true - ) { + if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { token.output = value; push(token); continue; } - if ( - state.index === state.start || - prev.type === 'slash' || - prev.type === 'dot' - ) { + if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { if (prev.type === 'dot') { state.output += NO_DOT_SLASH; prev.output += NO_DOT_SLASH; + } else if (opts.dot === true) { state.output += NO_DOTS_SLASH; prev.output += NO_DOTS_SLASH; + } else { state.output += nodot; prev.output += nodot; @@ -1027,30 +953,24 @@ const parse = (input, options) => { } while (state.brackets > 0) { - if (opts.strictBrackets === true) - throw new SyntaxError(syntaxError('closing', ']')); + if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); state.output = utils.escapeLast(state.output, '['); decrement('brackets'); } while (state.parens > 0) { - if (opts.strictBrackets === true) - throw new SyntaxError(syntaxError('closing', ')')); + if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); state.output = utils.escapeLast(state.output, '('); decrement('parens'); } while (state.braces > 0) { - if (opts.strictBrackets === true) - throw new SyntaxError(syntaxError('closing', '}')); + if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); state.output = utils.escapeLast(state.output, '{'); decrement('braces'); } - if ( - opts.strictSlashes !== true && - (prev.type === 'star' || prev.type === 'bracket') - ) { + if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); } @@ -1078,15 +998,10 @@ const parse = (input, options) => { parse.fastpaths = (input, options) => { const opts = { ...options }; - const max = - typeof opts.maxLength === 'number' - ? Math.min(MAX_LENGTH, opts.maxLength) - : MAX_LENGTH; + const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH; const len = input.length; if (len > max) { - throw new SyntaxError( - `Input length: ${len}, exceeds maximum allowed length: ${max}` - ); + throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); } input = REPLACEMENTS[input] || input; diff --git a/lib/picomatch.js b/lib/picomatch.js index 5c077578..d0ebd9f1 100644 --- a/lib/picomatch.js +++ b/lib/picomatch.js @@ -58,20 +58,12 @@ const picomatch = (glob, options, returnState = false) => { let isIgnored = () => false; if (opts.ignore) { - const ignoreOpts = { - ...options, - ignore: null, - onMatch: null, - onResult: null - }; + const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null }; isIgnored = picomatch(opts.ignore, ignoreOpts, returnState); } const matcher = (input, returnObject = false) => { - const { isMatch, match, output } = picomatch.test(input, regex, options, { - glob, - posix - }); + const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix }); const result = { glob, state, regex, posix, input, output, match, isMatch }; if (typeof opts.onResult === 'function') { @@ -133,7 +125,7 @@ picomatch.test = (input, regex, options, { glob, posix } = {}) => { const opts = options || {}; const format = opts.format || (posix ? utils.toPosixSlashes : null); let match = input === glob; - let output = match && format ? format(input) : input; + let output = (match && format) ? format(input) : input; if (match === false) { output = format ? format(input) : input; @@ -187,8 +179,7 @@ picomatch.matchBase = (input, glob, options) => { * @api public */ -picomatch.isMatch = (str, patterns, options) => - picomatch(patterns, options)(str); +picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str); /** * Parse a glob pattern to create the source string for a regular @@ -205,8 +196,7 @@ picomatch.isMatch = (str, patterns, options) => */ picomatch.parse = (pattern, options) => { - if (Array.isArray(pattern)) - return pattern.map(p => picomatch.parse(p, options)); + if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options)); return parse(pattern, { ...options, fastpaths: false }); }; @@ -251,12 +241,7 @@ picomatch.scan = (input, options) => scan(input, options); * @api public */ -picomatch.compileRe = ( - state, - options, - returnOutput = false, - returnState = false -) => { +picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => { if (returnOutput === true) { return state.output; } @@ -297,12 +282,7 @@ picomatch.compileRe = ( * @api public */ -picomatch.makeRe = ( - input, - options = {}, - returnOutput = false, - returnState = false -) => { +picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => { if (!input || typeof input !== 'string') { throw new TypeError('Expected a non-empty string'); } diff --git a/lib/scan.js b/lib/scan.js index 23c63c0f..e59cd7a1 100644 --- a/lib/scan.js +++ b/lib/scan.js @@ -2,21 +2,21 @@ const utils = require('./utils'); const { - CHAR_ASTERISK /* * */, - CHAR_AT /* @ */, - CHAR_BACKWARD_SLASH /* \ */, - CHAR_COMMA /* , */, - CHAR_DOT /* . */, - CHAR_EXCLAMATION_MARK /* ! */, - CHAR_FORWARD_SLASH /* / */, - CHAR_LEFT_CURLY_BRACE /* { */, - CHAR_LEFT_PARENTHESES /* ( */, - CHAR_LEFT_SQUARE_BRACKET /* [ */, - CHAR_PLUS /* + */, - CHAR_QUESTION_MARK /* ? */, - CHAR_RIGHT_CURLY_BRACE /* } */, - CHAR_RIGHT_PARENTHESES /* ) */, - CHAR_RIGHT_SQUARE_BRACKET /* ] */ + CHAR_ASTERISK, /* * */ + CHAR_AT, /* @ */ + CHAR_BACKWARD_SLASH, /* \ */ + CHAR_COMMA, /* , */ + CHAR_DOT, /* . */ + CHAR_EXCLAMATION_MARK, /* ! */ + CHAR_FORWARD_SLASH, /* / */ + CHAR_LEFT_CURLY_BRACE, /* { */ + CHAR_LEFT_PARENTHESES, /* ( */ + CHAR_LEFT_SQUARE_BRACKET, /* [ */ + CHAR_PLUS, /* + */ + CHAR_QUESTION_MARK, /* ? */ + CHAR_RIGHT_CURLY_BRACE, /* } */ + CHAR_RIGHT_PARENTHESES, /* ) */ + CHAR_RIGHT_SQUARE_BRACKET /* ] */ } = require('./constants'); const isPathSeparator = code => { @@ -110,11 +110,7 @@ const scan = (input, options) => { continue; } - if ( - braceEscaped !== true && - code === CHAR_DOT && - (code = advance()) === CHAR_DOT - ) { + if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) { isBrace = token.isBrace = true; isGlob = token.isGlob = true; finished = true; @@ -163,7 +159,7 @@ const scan = (input, options) => { token = { value: '', depth: 0, isGlob: false }; if (finished === true) continue; - if (prev === CHAR_DOT && index === start + 1) { + if (prev === CHAR_DOT && index === (start + 1)) { start += 2; continue; } @@ -173,12 +169,11 @@ const scan = (input, options) => { } if (opts.noext !== true) { - const isExtglobChar = - code === CHAR_PLUS || - code === CHAR_AT || - code === CHAR_ASTERISK || - code === CHAR_QUESTION_MARK || - code === CHAR_EXCLAMATION_MARK; + const isExtglobChar = code === CHAR_PLUS + || code === CHAR_AT + || code === CHAR_ASTERISK + || code === CHAR_QUESTION_MARK + || code === CHAR_EXCLAMATION_MARK; if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) { isGlob = token.isGlob = true; @@ -252,11 +247,7 @@ const scan = (input, options) => { break; } - if ( - opts.nonegate !== true && - code === CHAR_EXCLAMATION_MARK && - index === start - ) { + if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) { negated = token.negated = true; start++; continue; diff --git a/lib/utils.js b/lib/utils.js index 606760ba..9c97cae2 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,3 +1,4 @@ +/*global navigator*/ 'use strict'; const { @@ -7,8 +8,7 @@ const { REGEX_SPECIAL_CHARS_GLOBAL } = require('./constants'); -exports.isObject = val => - val !== null && typeof val === 'object' && !Array.isArray(val); +exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val); exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str); exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str); exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1'); diff --git a/package.json b/package.json index 2c109de4..372e27e0 100644 --- a/package.json +++ b/package.json @@ -21,23 +21,18 @@ "node": ">=12" }, "scripts": { - "lint": "eslint --cache --cache-location node_modules/.cache/.eslintcache --report-unused-disable-directives .", + "lint": "eslint --cache --cache-location node_modules/.cache/.eslintcache --report-unused-disable-directives --ignore-path .gitignore .", "mocha": "mocha --reporter dot", "test": "npm run lint && npm run mocha", "test:ci": "npm run test:cover", "test:cover": "nyc npm run mocha" }, "devDependencies": { - "@eslint/js": "^10.0.1", - "eslint": "^10.0.3", - "eslint-config-prettier": "^10.1.8", - "eslint-plugin-prettier": "^5.5.5", + "eslint": "^8.57.0", "fill-range": "^7.0.1", - "globals": "^17.4.0", "gulp-format-md": "^2.0.0", "mocha": "^10.4.0", "nyc": "^15.1.0", - "prettier": "^3.8.1", "time-require": "github:jonschlinkert/time-require" }, "keywords": [ diff --git a/test/api.picomatch.js b/test/api.picomatch.js index fc8815f4..2fe67cff 100644 --- a/test/api.picomatch.js +++ b/test/api.picomatch.js @@ -12,14 +12,8 @@ const assertTokens = (actual, expected) => { describe('picomatch', () => { describe('validation', () => { it('should throw an error when invalid arguments are given', () => { - assert.throws( - () => isMatch('foo', ''), - /Expected pattern to be a non-empty string/ - ); - assert.throws( - () => isMatch('foo', null), - /Expected pattern to be a non-empty string/ - ); + assert.throws(() => isMatch('foo', ''), /Expected pattern to be a non-empty string/); + assert.throws(() => isMatch('foo', null), /Expected pattern to be a non-empty string/); }); }); @@ -252,9 +246,7 @@ describe('picomatch', () => { assert(!isMatch('foo/baz/bar', 'foo**bar')); assert(!isMatch('foo/baz/bar', 'foo*bar')); assert(!isMatch('deep/foo/bar/baz', '**/bar/*/')); - assert( - !isMatch('deep/foo/bar/baz/', '**/bar/*', { strictSlashes: true }) - ); + assert(!isMatch('deep/foo/bar/baz/', '**/bar/*', { strictSlashes: true })); assert(isMatch('deep/foo/bar/baz/', '**/bar/*')); assert(isMatch('deep/foo/bar/baz', '**/bar/*')); assert(isMatch('foo', 'foo/**')); @@ -366,10 +358,7 @@ describe('picomatch', () => { ['text', { output: undefined, value: 'js' }] ]; - const keyValuePairs = tokens.map(token => [ - token.type, - { output: token.output, value: token.value } - ]); + const keyValuePairs = tokens.map(token => [token.type, { output: token.output, value: token.value }]); assert.deepStrictEqual(keyValuePairs, expected); }); }); diff --git a/test/api.scan.js b/test/api.scan.js index 7f974045..b1e63db1 100644 --- a/test/api.scan.js +++ b/test/api.scan.js @@ -253,16 +253,8 @@ describe('picomatch', () => { assert.strictEqual(base('path/**/subdir/foo.*'), 'path'); assert.strictEqual(base('path/*/foo'), 'path'); assert.strictEqual(base('path/*/foo/'), 'path'); - assert.strictEqual( - base('path/+/foo'), - 'path/+/foo', - 'plus sign must be escaped' - ); - assert.strictEqual( - base('path/+/foo/'), - 'path/+/foo/', - 'plus sign must be escaped' - ); + assert.strictEqual(base('path/+/foo'), 'path/+/foo', 'plus sign must be escaped'); + assert.strictEqual(base('path/+/foo/'), 'path/+/foo/', 'plus sign must be escaped'); assert.strictEqual(base('path/?/foo'), 'path', 'qmarks must be escaped'); assert.strictEqual(base('path/?/foo/'), 'path', 'qmarks must be escaped'); assert.strictEqual(base('path/@/foo'), 'path/@/foo'); @@ -273,18 +265,9 @@ describe('picomatch', () => { }); it('should respect escaped characters', () => { - assert.strictEqual( - base('path/\\*\\*/subdir/foo.*'), - 'path/\\*\\*/subdir' - ); - assert.strictEqual( - base('path/\\[\\*\\]/subdir/foo.*'), - 'path/\\[\\*\\]/subdir' - ); - assert.strictEqual( - base('path/\\[foo bar\\]/subdir/foo.*'), - 'path/\\[foo bar\\]/subdir' - ); + assert.strictEqual(base('path/\\*\\*/subdir/foo.*'), 'path/\\*\\*/subdir'); + assert.strictEqual(base('path/\\[\\*\\]/subdir/foo.*'), 'path/\\[\\*\\]/subdir'); + assert.strictEqual(base('path/\\[foo bar\\]/subdir/foo.*'), 'path/\\[foo bar\\]/subdir'); assert.strictEqual(base('path/\\[bar]/'), 'path/\\[bar]/'); assert.strictEqual(base('path/\\[bar]'), 'path/\\[bar]'); assert.strictEqual(base('[bar]'), ''); @@ -385,17 +368,7 @@ describe('picomatch', () => { assertParts('a/**@(/x|/z)/*.md', ['a', '**@(/x|/z)', '*.md']); assertParts('foo/(bar|baz)/*.js', ['foo', '(bar|baz)', '*.js']); - assertParts('XXX/*/*/12/*/*/m/*/*', [ - 'XXX', - '*', - '*', - '12', - '*', - '*', - 'm', - '*', - '*' - ]); + assertParts('XXX/*/*/12/*/*/m/*/*', ['XXX', '*', '*', '12', '*', '*', 'm', '*', '*']); assertParts('foo/\\"**\\"/bar', ['foo', '\\"**\\"', 'bar']); assertParts('[0-9]/[0-9]', ['[0-9]', '[0-9]']); @@ -436,45 +409,21 @@ describe('picomatch', () => { assert.strictEqual(base('a/(b c)', { noparen: true }), 'a/(b c)'); assert.strictEqual(base('a/(b c)/', { noparen: true }), 'a/(b c)/'); assert.strictEqual(base('a/(b c)/d', { noparen: true }), 'a/(b c)/d'); - assert.strictEqual( - base('foo/(b c)/baz', { noparen: true }), - 'foo/(b c)/baz' - ); - assert.strictEqual( - base('path/(foo bar)/subdir/foo.*', { noparen: true }), - 'path/(foo bar)/subdir' - ); - assert.strictEqual( - base('a/\\(b c)'), - 'a/\\(b c)', - 'parens must be escaped' - ); - assert.strictEqual( - base('a/\\+\\(b c)/foo'), - 'a/\\+\\(b c)/foo', - 'parens must be escaped' - ); + assert.strictEqual(base('foo/(b c)/baz', { noparen: true }), 'foo/(b c)/baz'); + assert.strictEqual(base('path/(foo bar)/subdir/foo.*', { noparen: true }), 'path/(foo bar)/subdir'); + assert.strictEqual(base('a/\\(b c)'), 'a/\\(b c)', 'parens must be escaped'); + assert.strictEqual(base('a/\\+\\(b c)/foo'), 'a/\\+\\(b c)/foo', 'parens must be escaped'); assert.strictEqual(base('js/t(wo|est)/*.js'), 'js'); assert.strictEqual(base('js/t/(wo|est)/*.js'), 'js/t'); - assert.strictEqual( - base('path/(foo bar)/subdir/foo.*'), - 'path', - 'parens must be escaped' - ); + assert.strictEqual(base('path/(foo bar)/subdir/foo.*'), 'path', 'parens must be escaped'); assert.strictEqual(base('path/(foo/bar|baz)'), 'path'); assert.strictEqual(base('path/(foo/bar|baz)/'), 'path'); assert.strictEqual(base('path/(to|from)'), 'path'); - assert.strictEqual( - base('path/\\(foo/bar|baz)/'), - 'path/\\(foo/bar|baz)/' - ); + assert.strictEqual(base('path/\\(foo/bar|baz)/'), 'path/\\(foo/bar|baz)/'); assert.strictEqual(base('path/\\*(a|b)'), 'path'); assert.strictEqual(base('path/\\*(a|b)/subdir/foo.*'), 'path'); assert.strictEqual(base('path/\\*/(a|b)/subdir/foo.*'), 'path/\\*'); - assert.strictEqual( - base('path/\\*\\(a\\|b\\)/subdir/foo.*'), - 'path/\\*\\(a\\|b\\)/subdir' - ); + assert.strictEqual(base('path/\\*\\(a\\|b\\)/subdir/foo.*'), 'path/\\*\\(a\\|b\\)/subdir'); }); }); @@ -509,22 +458,13 @@ describe('picomatch', () => { assert.deepStrictEqual(both('*'), ['', '*']); assert.deepStrictEqual(both('a/**/j/**/z/*.md'), ['a', '**/j/**/z/*.md']); assert.deepStrictEqual(both('a/**/z/*.md'), ['a', '**/z/*.md']); - assert.deepStrictEqual(both('node_modules/*-glob/**/*.js'), [ - 'node_modules', - '*-glob/**/*.js' - ]); - assert.deepStrictEqual(both('{a/b/{c,/foo.js}/e.f.g}'), [ - '', - '{a/b/{c,/foo.js}/e.f.g}' - ]); + assert.deepStrictEqual(both('node_modules/*-glob/**/*.js'), ['node_modules', '*-glob/**/*.js']); + assert.deepStrictEqual(both('{a/b/{c,/foo.js}/e.f.g}'), ['', '{a/b/{c,/foo.js}/e.f.g}']); assert.deepStrictEqual(both('.a*'), ['', '.a*']); assert.deepStrictEqual(both('.b*'), ['', '.b*']); assert.deepStrictEqual(both('/*'), ['/', '*']); assert.deepStrictEqual(both('a/***'), ['a', '***']); - assert.deepStrictEqual(both('a/**/b/*.{foo,bar}'), [ - 'a', - '**/b/*.{foo,bar}' - ]); + assert.deepStrictEqual(both('a/**/b/*.{foo,bar}'), ['a', '**/b/*.{foo,bar}']); assert.deepStrictEqual(both('a/**/c/*'), ['a', '**/c/*']); assert.deepStrictEqual(both('a/**/c/*.md'), ['a', '**/c/*.md']); assert.deepStrictEqual(both('a/**/e'), ['a', '**/e']); @@ -534,10 +474,7 @@ describe('picomatch', () => { assert.deepStrictEqual(both('a/**c/*'), ['a', '**c/*']); assert.deepStrictEqual(both('a/*/*/e'), ['a', '*/*/e']); assert.deepStrictEqual(both('a/*/c/*.md'), ['a', '*/c/*.md']); - assert.deepStrictEqual(both('a/b/**/c{d,e}/**/xyz.md'), [ - 'a/b', - '**/c{d,e}/**/xyz.md' - ]); + assert.deepStrictEqual(both('a/b/**/c{d,e}/**/xyz.md'), ['a/b', '**/c{d,e}/**/xyz.md']); assert.deepStrictEqual(both('a/b/**/e'), ['a/b', '**/e']); assert.deepStrictEqual(both('a/b/*.{foo,bar}'), ['a/b', '*.{foo,bar}']); assert.deepStrictEqual(both('a/b/*/e'), ['a/b', '*/e']); @@ -545,20 +482,11 @@ describe('picomatch', () => { assert.deepStrictEqual(both('a/b/.git/**'), ['a/b/.git', '**']); assert.deepStrictEqual(both('a/b/.{foo,bar}'), ['a/b', '.{foo,bar}']); assert.deepStrictEqual(both('a/b/c/*'), ['a/b/c', '*']); - assert.deepStrictEqual(both('a/b/c/**/*.min.js'), [ - 'a/b/c', - '**/*.min.js' - ]); + assert.deepStrictEqual(both('a/b/c/**/*.min.js'), ['a/b/c', '**/*.min.js']); assert.deepStrictEqual(both('a/b/c/*.md'), ['a/b/c', '*.md']); assert.deepStrictEqual(both('a/b/c/.*.md'), ['a/b/c', '.*.md']); - assert.deepStrictEqual( - both('a/b/{c,.gitignore,{a,b}}/{a,b}/abc.foo.js'), - ['a/b', '{c,.gitignore,{a,b}}/{a,b}/abc.foo.js'] - ); - assert.deepStrictEqual(both('a/b/{c,/.gitignore}'), [ - 'a/b', - '{c,/.gitignore}' - ]); + assert.deepStrictEqual(both('a/b/{c,.gitignore,{a,b}}/{a,b}/abc.foo.js'), ['a/b', '{c,.gitignore,{a,b}}/{a,b}/abc.foo.js']); + assert.deepStrictEqual(both('a/b/{c,/.gitignore}'), ['a/b', '{c,/.gitignore}']); assert.deepStrictEqual(both('a/b/{c,d}/'), ['a/b', '{c,d}/']); assert.deepStrictEqual(both('a/b/{c,d}/e/f.g'), ['a/b', '{c,d}/e/f.g']); assert.deepStrictEqual(both('b/*/*/*'), ['b', '*/*/*']); @@ -572,30 +500,15 @@ describe('picomatch', () => { assert.deepStrictEqual(both('!*.min.js'), ['', '*.min.js']); assert.deepStrictEqual(both('!foo'), ['foo', '']); assert.deepStrictEqual(both('!foo/*.js'), ['foo', '*.js']); - assert.deepStrictEqual(both('!foo/(a|b).min.js'), [ - 'foo', - '(a|b).min.js' - ]); - assert.deepStrictEqual(both('!foo/[a-b].min.js'), [ - 'foo', - '[a-b].min.js' - ]); - assert.deepStrictEqual(both('!foo/{a,b}.min.js'), [ - 'foo', - '{a,b}.min.js' - ]); + assert.deepStrictEqual(both('!foo/(a|b).min.js'), ['foo', '(a|b).min.js']); + assert.deepStrictEqual(both('!foo/[a-b].min.js'), ['foo', '[a-b].min.js']); + assert.deepStrictEqual(both('!foo/{a,b}.min.js'), ['foo', '{a,b}.min.js']); assert.deepStrictEqual(both('a/b/c/!foo'), ['a/b/c/!foo', '']); }); it('should support extglobs', () => { - assert.deepStrictEqual(both('/a/b/!(a|b)/e.f.g/'), [ - '/a/b', - '!(a|b)/e.f.g/' - ]); - assert.deepStrictEqual(both('/a/b/@(a|b)/e.f.g/'), [ - '/a/b', - '@(a|b)/e.f.g/' - ]); + assert.deepStrictEqual(both('/a/b/!(a|b)/e.f.g/'), ['/a/b', '!(a|b)/e.f.g/']); + assert.deepStrictEqual(both('/a/b/@(a|b)/e.f.g/'), ['/a/b', '@(a|b)/e.f.g/']); assert.deepStrictEqual(both('@(a|b)/e.f.g/'), ['', '@(a|b)/e.f.g/']); assert.strictEqual(base('path/!(to|from)'), 'path'); assert.strictEqual(base('path/*(to|from)'), 'path'); @@ -656,10 +569,7 @@ describe('picomatch', () => { assert.deepStrictEqual(both('a/.x.md'), ['a/.x.md', '']); assert.deepStrictEqual(both('a/b/.gitignore'), ['a/b/.gitignore', '']); assert.deepStrictEqual(both('a/b/c/d.md'), ['a/b/c/d.md', '']); - assert.deepStrictEqual(both('a/b/c/d.e.f/g.min.js'), [ - 'a/b/c/d.e.f/g.min.js', - '' - ]); + assert.deepStrictEqual(both('a/b/c/d.e.f/g.min.js'), ['a/b/c/d.e.f/g.min.js', '']); assert.deepStrictEqual(both('a/b/.git'), ['a/b/.git', '']); assert.deepStrictEqual(both('a/b/.git/'), ['a/b/.git/', '']); assert.deepStrictEqual(both('a/b/c'), ['a/b/c', '']); @@ -692,56 +602,23 @@ describe('picomatch', () => { it('should respect brace enclosures with embedded separators', () => { const opts = { unescape: true }; assert.strictEqual(base('path/{,/,bar/baz,qux}/', opts), 'path'); - assert.strictEqual( - base('path/\\{,/,bar/baz,qux}/', opts), - 'path/{,/,bar/baz,qux}/' - ); - assert.strictEqual( - base('path/\\{,/,bar/baz,qux\\}/', opts), - 'path/{,/,bar/baz,qux}/' - ); + assert.strictEqual(base('path/\\{,/,bar/baz,qux}/', opts), 'path/{,/,bar/baz,qux}/'); + assert.strictEqual(base('path/\\{,/,bar/baz,qux\\}/', opts), 'path/{,/,bar/baz,qux}/'); assert.strictEqual(base('/{,/,bar/baz,qux}/', opts), '/'); - assert.strictEqual( - base('/\\{,/,bar/baz,qux}/', opts), - '/{,/,bar/baz,qux}/' - ); + assert.strictEqual(base('/\\{,/,bar/baz,qux}/', opts), '/{,/,bar/baz,qux}/'); assert.strictEqual(base('{,/,bar/baz,qux}', opts), ''); - assert.strictEqual( - base('\\{,/,bar/baz,qux\\}', opts), - '{,/,bar/baz,qux}' - ); - assert.strictEqual( - base('\\{,/,bar/baz,qux}/', opts), - '{,/,bar/baz,qux}/' - ); + assert.strictEqual(base('\\{,/,bar/baz,qux\\}', opts), '{,/,bar/baz,qux}'); + assert.strictEqual(base('\\{,/,bar/baz,qux}/', opts), '{,/,bar/baz,qux}/'); }); it('should handle escaped nested braces', () => { const opts = { unescape: true }; - assert.strictEqual( - base('\\{../,./,\\{bar,/baz},qux}', opts), - '{../,./,{bar,/baz},qux}' - ); - assert.strictEqual( - base('\\{../,./,\\{bar,/baz},qux}/', opts), - '{../,./,{bar,/baz},qux}/' - ); - assert.strictEqual( - base('path/\\{,/,bar/{baz,qux}}/', opts), - 'path/{,/,bar/{baz,qux}}/' - ); - assert.strictEqual( - base('path/\\{../,./,\\{bar,/baz},qux}/', opts), - 'path/{../,./,{bar,/baz},qux}/' - ); - assert.strictEqual( - base('path/\\{../,./,\\{bar,/baz},qux}/', opts), - 'path/{../,./,{bar,/baz},qux}/' - ); - assert.strictEqual( - base('path/\\{../,./,{bar,/baz},qux}/', opts), - 'path/{../,./,{bar,/baz},qux}/' - ); + assert.strictEqual(base('\\{../,./,\\{bar,/baz},qux}', opts), '{../,./,{bar,/baz},qux}'); + assert.strictEqual(base('\\{../,./,\\{bar,/baz},qux}/', opts), '{../,./,{bar,/baz},qux}/'); + assert.strictEqual(base('path/\\{,/,bar/{baz,qux}}/', opts), 'path/{,/,bar/{baz,qux}}/'); + assert.strictEqual(base('path/\\{../,./,\\{bar,/baz},qux}/', opts), 'path/{../,./,{bar,/baz},qux}/'); + assert.strictEqual(base('path/\\{../,./,\\{bar,/baz},qux}/', opts), 'path/{../,./,{bar,/baz},qux}/'); + assert.strictEqual(base('path/\\{../,./,{bar,/baz},qux}/', opts), 'path/{../,./,{bar,/baz},qux}/'); assert.strictEqual(base('path/{,/,bar/\\{baz,qux}}/', opts), 'path'); }); @@ -760,90 +637,39 @@ describe('picomatch', () => { }); it('should support braces: no path', () => { - assert.deepStrictEqual(both('/a/b/{c,/foo.js}/e.f.g/'), [ - '/a/b', - '{c,/foo.js}/e.f.g/' - ]); - assert.deepStrictEqual(both('{a/b/c.js,/a/b/{c,/foo.js}/e.f.g/}'), [ - '', - '{a/b/c.js,/a/b/{c,/foo.js}/e.f.g/}' - ]); + assert.deepStrictEqual(both('/a/b/{c,/foo.js}/e.f.g/'), ['/a/b', '{c,/foo.js}/e.f.g/']); + assert.deepStrictEqual(both('{a/b/c.js,/a/b/{c,/foo.js}/e.f.g/}'), ['', '{a/b/c.js,/a/b/{c,/foo.js}/e.f.g/}']); assert.deepStrictEqual(both('/a/b/{c,d}/'), ['/a/b', '{c,d}/']); assert.deepStrictEqual(both('/a/b/{c,d}/*.js'), ['/a/b', '{c,d}/*.js']); - assert.deepStrictEqual(both('/a/b/{c,d}/*.min.js'), [ - '/a/b', - '{c,d}/*.min.js' - ]); - assert.deepStrictEqual(both('/a/b/{c,d}/e.f.g/'), [ - '/a/b', - '{c,d}/e.f.g/' - ]); + assert.deepStrictEqual(both('/a/b/{c,d}/*.min.js'), ['/a/b', '{c,d}/*.min.js']); + assert.deepStrictEqual(both('/a/b/{c,d}/e.f.g/'), ['/a/b', '{c,d}/e.f.g/']); assert.deepStrictEqual(both('{.,*}'), ['', '{.,*}']); }); it('should support braces in filename', () => { - assert.deepStrictEqual(both('a/b/.{c,.gitignore}'), [ - 'a/b', - '.{c,.gitignore}' - ]); - assert.deepStrictEqual(both('a/b/.{c,/.gitignore}'), [ - 'a/b', - '.{c,/.gitignore}' - ]); + assert.deepStrictEqual(both('a/b/.{c,.gitignore}'), ['a/b', '.{c,.gitignore}']); + assert.deepStrictEqual(both('a/b/.{c,/.gitignore}'), ['a/b', '.{c,/.gitignore}']); assert.deepStrictEqual(both('a/b/.{foo,bar}'), ['a/b', '.{foo,bar}']); - assert.deepStrictEqual(both('a/b/{c,.gitignore}'), [ - 'a/b', - '{c,.gitignore}' - ]); - assert.deepStrictEqual(both('a/b/{c,/.gitignore}'), [ - 'a/b', - '{c,/.gitignore}' - ]); - assert.deepStrictEqual(both('a/b/{c,/gitignore}'), [ - 'a/b', - '{c,/gitignore}' - ]); + assert.deepStrictEqual(both('a/b/{c,.gitignore}'), ['a/b', '{c,.gitignore}']); + assert.deepStrictEqual(both('a/b/{c,/.gitignore}'), ['a/b', '{c,/.gitignore}']); + assert.deepStrictEqual(both('a/b/{c,/gitignore}'), ['a/b', '{c,/gitignore}']); assert.deepStrictEqual(both('a/b/{c,d}'), ['a/b', '{c,d}']); }); it('should support braces in dirname', () => { - assert.deepStrictEqual(both('a/b/{c,./d}/e/f.g'), [ - 'a/b', - '{c,./d}/e/f.g' - ]); - assert.deepStrictEqual(both('a/b/{c,./d}/e/f.min.g'), [ - 'a/b', - '{c,./d}/e/f.min.g' - ]); - assert.deepStrictEqual( - both('a/b/{c,.gitignore,{a,./b}}/{a,b}/abc.foo.js'), - ['a/b', '{c,.gitignore,{a,./b}}/{a,b}/abc.foo.js'] - ); - assert.deepStrictEqual(both('a/b/{c,.gitignore,{a,b}}/{a,b}/*.foo.js'), [ - 'a/b', - '{c,.gitignore,{a,b}}/{a,b}/*.foo.js' - ]); - assert.deepStrictEqual( - both('a/b/{c,.gitignore,{a,b}}/{a,b}/abc.foo.js'), - ['a/b', '{c,.gitignore,{a,b}}/{a,b}/abc.foo.js'] - ); + assert.deepStrictEqual(both('a/b/{c,./d}/e/f.g'), ['a/b', '{c,./d}/e/f.g']); + assert.deepStrictEqual(both('a/b/{c,./d}/e/f.min.g'), ['a/b', '{c,./d}/e/f.min.g']); + assert.deepStrictEqual(both('a/b/{c,.gitignore,{a,./b}}/{a,b}/abc.foo.js'), ['a/b', '{c,.gitignore,{a,./b}}/{a,b}/abc.foo.js']); + assert.deepStrictEqual(both('a/b/{c,.gitignore,{a,b}}/{a,b}/*.foo.js'), ['a/b', '{c,.gitignore,{a,b}}/{a,b}/*.foo.js']); + assert.deepStrictEqual(both('a/b/{c,.gitignore,{a,b}}/{a,b}/abc.foo.js'), ['a/b', '{c,.gitignore,{a,b}}/{a,b}/abc.foo.js']); assert.deepStrictEqual(both('a/b/{c,/d}/e/f.g'), ['a/b', '{c,/d}/e/f.g']); - assert.deepStrictEqual(both('a/b/{c,/d}/e/f.min.g'), [ - 'a/b', - '{c,/d}/e/f.min.g' - ]); + assert.deepStrictEqual(both('a/b/{c,/d}/e/f.min.g'), ['a/b', '{c,/d}/e/f.min.g']); assert.deepStrictEqual(both('a/b/{c,d}/'), ['a/b', '{c,d}/']); assert.deepStrictEqual(both('a/b/{c,d}/*.js'), ['a/b', '{c,d}/*.js']); - assert.deepStrictEqual(both('a/b/{c,d}/*.min.js'), [ - 'a/b', - '{c,d}/*.min.js' - ]); + assert.deepStrictEqual(both('a/b/{c,d}/*.min.js'), ['a/b', '{c,d}/*.min.js']); assert.deepStrictEqual(both('a/b/{c,d}/e.f.g/'), ['a/b', '{c,d}/e.f.g/']); assert.deepStrictEqual(both('a/b/{c,d}/e/f.g'), ['a/b', '{c,d}/e/f.g']); - assert.deepStrictEqual(both('a/b/{c,d}/e/f.min.g'), [ - 'a/b', - '{c,d}/e/f.min.g' - ]); + assert.deepStrictEqual(both('a/b/{c,d}/e/f.min.g'), ['a/b', '{c,d}/e/f.min.g']); assert.deepStrictEqual(both('foo/{a,b}.min.js'), ['foo', '{a,b}.min.js']); }); }); diff --git a/test/bash.js b/test/bash.js index 73eec859..2ef4bb1a 100644 --- a/test/bash.js +++ b/test/bash.js @@ -208,7 +208,7 @@ describe('from the Bash 4.3 spec/unit tests', () => { assert(!isMatch('d', "'***'")); assert(!isMatch('dd', "'***'")); assert(!isMatch('de', "'***'")); - assert(isMatch("'***'", "'***'")); + assert(isMatch('\'***\'', "'***'")); assert(!isMatch('*', '"***"')); assert(!isMatch('**', '"***"')); diff --git a/test/braces.js b/test/braces.js index 574e5664..a343c316 100644 --- a/test/braces.js +++ b/test/braces.js @@ -7,19 +7,9 @@ const { isMatch } = require('..'); describe('braces', () => { it('should not match with brace patterns when disabled', () => { - assert.deepStrictEqual(match(['a', 'b', 'c'], '{a,b,c,d}'), [ - 'a', - 'b', - 'c' - ]); - assert.deepStrictEqual( - match(['a', 'b', 'c'], '{a,b,c,d}', { nobrace: true }), - [] - ); - assert.deepStrictEqual( - match(['1', '2', '3'], '{1..2}', { nobrace: true }), - [] - ); + assert.deepStrictEqual(match(['a', 'b', 'c'], '{a,b,c,d}'), ['a', 'b', 'c']); + assert.deepStrictEqual(match(['a', 'b', 'c'], '{a,b,c,d}', { nobrace: true }), []); + assert.deepStrictEqual(match(['1', '2', '3'], '{1..2}', { nobrace: true }), []); assert(!isMatch('a/a', 'a/{a,b}', { nobrace: true })); assert(!isMatch('a/b', 'a/{a,b}', { nobrace: true })); assert(!isMatch('a/c', 'a/{a,b}', { nobrace: true })); @@ -203,35 +193,21 @@ describe('braces', () => { const expandRange = (a, b) => `(${fill(a, b, { toRegex: true })})`; assert(!isMatch('foo/bar - 1', '*/* {4..10}', { expandRange })); - assert( - !isMatch('foo/bar - copy (1)', '*/* - * \\({4..10}\\)', { expandRange }) - ); + assert(!isMatch('foo/bar - copy (1)', '*/* - * \\({4..10}\\)', { expandRange })); assert(!isMatch('foo/bar (1)', '*/* \\({4..10}\\)', { expandRange })); assert(isMatch('foo/bar (4)', '*/* \\({4..10}\\)', { expandRange })); assert(isMatch('foo/bar (7)', '*/* \\({4..10}\\)', { expandRange })); assert(!isMatch('foo/bar (42)', '*/* \\({4..10}\\)', { expandRange })); assert(isMatch('foo/bar (42)', '*/* \\({4..43}\\)', { expandRange })); assert(isMatch('foo/bar - copy [1]', '*/* \\[{0..5}\\]', { expandRange })); - assert( - isMatch('foo/bar - foo + bar - copy [1]', '*/* \\[{0..5}\\]', { - expandRange - }) - ); + assert(isMatch('foo/bar - foo + bar - copy [1]', '*/* \\[{0..5}\\]', { expandRange })); assert(!isMatch('foo/bar - 1', '*/* \\({4..10}\\)', { expandRange })); - assert( - !isMatch('foo/bar - copy (1)', '*/* \\({4..10}\\)', { expandRange }) - ); + assert(!isMatch('foo/bar - copy (1)', '*/* \\({4..10}\\)', { expandRange })); assert(!isMatch('foo/bar (1)', '*/* \\({4..10}\\)', { expandRange })); assert(isMatch('foo/bar (4)', '*/* \\({4..10}\\)', { expandRange })); assert(isMatch('foo/bar (7)', '*/* \\({4..10}\\)', { expandRange })); assert(!isMatch('foo/bar (42)', '*/* \\({4..10}\\)', { expandRange })); - assert( - !isMatch('foo/bar - copy [1]', '*/* \\({4..10}\\)', { expandRange }) - ); - assert( - !isMatch('foo/bar - foo + bar - copy [1]', '*/* \\({4..10}\\)', { - expandRange - }) - ); + assert(!isMatch('foo/bar - copy [1]', '*/* \\({4..10}\\)', { expandRange })); + assert(!isMatch('foo/bar - foo + bar - copy [1]', '*/* \\({4..10}\\)', { expandRange })); }); }); diff --git a/test/dotfiles.js b/test/dotfiles.js index 973d9d1f..f90abb88 100644 --- a/test/dotfiles.js +++ b/test/dotfiles.js @@ -10,154 +10,74 @@ describe('dotfiles', () => { assert.deepStrictEqual(match(['.dotfile'], '*'), []); assert.deepStrictEqual(match(['.dotfile'], '**'), []); assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '*.md'), []); - assert.deepStrictEqual(match(['a/b', 'a/.b', '.a/b', '.a/.b'], '**'), [ - 'a/b' - ]); + assert.deepStrictEqual(match(['a/b', 'a/.b', '.a/b', '.a/.b'], '**'), ['a/b']); assert.deepStrictEqual(match(['a/b/c/.dotfile'], '*.*'), []); }); }); describe('leading dot', () => { it('should match dotfiles when a leading dot is defined in the path:', () => { - assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '**/.*'), [ - 'a/b/c/.dotfile.md' - ]); - assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '**/.*.md'), [ - 'a/b/c/.dotfile.md' - ]); + assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '**/.*'), ['a/b/c/.dotfile.md']); + assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '**/.*.md'), ['a/b/c/.dotfile.md']); }); it('should use negation patterns on dotfiles:', () => { - assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!.*'), [ - 'c', - 'c.md' - ]); - assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!.b'), [ - '.a', - 'c', - 'c.md' - ]); + assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!.*'), ['c', 'c.md']); + assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!.b'), ['.a', 'c', 'c.md']); }); it('should match dotfiles when there is a leading dot:', () => { const opts = { dot: true }; assert.deepStrictEqual(match(['.dotfile'], '*', opts), ['.dotfile']); assert.deepStrictEqual(match(['.dotfile'], '**', opts), ['.dotfile']); - assert.deepStrictEqual( - match(['a/b', 'a/.b', '.a/b', '.a/.b'], '**', opts), - ['a/b', 'a/.b', '.a/b', '.a/.b'] - ); - assert.deepStrictEqual( - match(['a/b', 'a/.b', 'a/.b', '.a/.b'], 'a/{.*,**}', opts), - ['a/b', 'a/.b'] - ); - assert.deepStrictEqual( - match(['a/b', 'a/.b', 'a/.b', '.a/.b'], '{.*,**}', {}), - ['a/b'] - ); - assert.deepStrictEqual( - match(['a/b', 'a/.b', 'a/.b', '.a/.b'], '{.*,**}', opts), - ['a/b', 'a/.b', '.a/.b'] - ); - assert.deepStrictEqual(match(['.dotfile'], '.dotfile', opts), [ - '.dotfile' - ]); - assert.deepStrictEqual(match(['.dotfile.md'], '.*.md', opts), [ - '.dotfile.md' - ]); + assert.deepStrictEqual(match(['a/b', 'a/.b', '.a/b', '.a/.b'], '**', opts), ['a/b', 'a/.b', '.a/b', '.a/.b']); + assert.deepStrictEqual(match(['a/b', 'a/.b', 'a/.b', '.a/.b'], 'a/{.*,**}', opts), ['a/b', 'a/.b']); + assert.deepStrictEqual(match(['a/b', 'a/.b', 'a/.b', '.a/.b'], '{.*,**}', {}), ['a/b']); + assert.deepStrictEqual(match(['a/b', 'a/.b', 'a/.b', '.a/.b'], '{.*,**}', opts), ['a/b', 'a/.b', '.a/.b']); + assert.deepStrictEqual(match(['.dotfile'], '.dotfile', opts), ['.dotfile']); + assert.deepStrictEqual(match(['.dotfile.md'], '.*.md', opts), ['.dotfile.md']); }); it('should match dotfiles when there is not a leading dot:', () => { const opts = { dot: true }; assert.deepStrictEqual(match(['.dotfile'], '*.*', opts), ['.dotfile']); - assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '*.*', opts), [ - '.a', - '.b', - 'c.md' - ]); + assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '*.*', opts), ['.a', '.b', 'c.md']); assert.deepStrictEqual(match(['.dotfile'], '*.md', opts), []); assert.deepStrictEqual(match(['.verb.txt'], '*.md', opts), []); assert.deepStrictEqual(match(['a/b/c/.dotfile'], '*.md', opts), []); assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '*.md', opts), []); - assert.deepStrictEqual(match(['a/b/c/.verb.md'], '**/*.md', opts), [ - 'a/b/c/.verb.md' - ]); + assert.deepStrictEqual(match(['a/b/c/.verb.md'], '**/*.md', opts), ['a/b/c/.verb.md']); assert.deepStrictEqual(match(['foo.md'], '*.md', opts), ['foo.md']); }); it('should use negation patterns on dotfiles:', () => { - assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!.*'), [ - 'c', - 'c.md' - ]); - assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!(.*)'), [ - 'c', - 'c.md' - ]); - assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!(.*)*'), [ - 'c', - 'c.md' - ]); - assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!*.*'), [ - '.a', - '.b', - 'c' - ]); + assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!.*'), ['c', 'c.md']); + assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!(.*)'), ['c', 'c.md']); + assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!(.*)*'), ['c', 'c.md']); + assert.deepStrictEqual(match(['.a', '.b', 'c', 'c.md'], '!*.*'), ['.a', '.b', 'c']); }); }); describe('options.dot', () => { it('should match dotfiles when `options.dot` is true:', () => { const fixtures = ['a/./b', 'a/../b', 'a/c/b', 'a/.d/b']; - assert.deepStrictEqual(match(['.dotfile'], '*.*', { dot: true }), [ - '.dotfile' - ]); + assert.deepStrictEqual(match(['.dotfile'], '*.*', { dot: true }), ['.dotfile']); assert.deepStrictEqual(match(['.dotfile'], '*.md', { dot: true }), []); - assert.deepStrictEqual(match(['.dotfile'], '.dotfile', { dot: true }), [ - '.dotfile' - ]); - assert.deepStrictEqual(match(['.dotfile.md'], '.*.md', { dot: true }), [ - '.dotfile.md' - ]); + assert.deepStrictEqual(match(['.dotfile'], '.dotfile', { dot: true }), ['.dotfile']); + assert.deepStrictEqual(match(['.dotfile.md'], '.*.md', { dot: true }), ['.dotfile.md']); assert.deepStrictEqual(match(['.verb.txt'], '*.md', { dot: true }), []); assert.deepStrictEqual(match(['.verb.txt'], '*.md', { dot: true }), []); - assert.deepStrictEqual( - match(['a/b/c/.dotfile'], '*.md', { dot: true }), - [] - ); - assert.deepStrictEqual( - match(['a/b/c/.dotfile.md'], '**/*.md', { dot: true }), - ['a/b/c/.dotfile.md'] - ); - assert.deepStrictEqual( - match(['a/b/c/.dotfile.md'], '**/.*', { dot: false }), - ['a/b/c/.dotfile.md'] - ); - assert.deepStrictEqual( - match(['a/b/c/.dotfile.md'], '**/.*.md', { dot: false }), - ['a/b/c/.dotfile.md'] - ); - assert.deepStrictEqual( - match(['a/b/c/.dotfile.md'], '*.md', { dot: false }), - [] - ); - assert.deepStrictEqual( - match(['a/b/c/.dotfile.md'], '*.md', { dot: true }), - [] - ); - assert.deepStrictEqual( - match(['a/b/c/.verb.md'], '**/*.md', { dot: true }), - ['a/b/c/.verb.md'] - ); + assert.deepStrictEqual(match(['a/b/c/.dotfile'], '*.md', { dot: true }), []); + assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '**/*.md', { dot: true }), ['a/b/c/.dotfile.md']); + assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '**/.*', { dot: false }), ['a/b/c/.dotfile.md']); + assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '**/.*.md', { dot: false }), ['a/b/c/.dotfile.md']); + assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '*.md', { dot: false }), []); + assert.deepStrictEqual(match(['a/b/c/.dotfile.md'], '*.md', { dot: true }), []); + assert.deepStrictEqual(match(['a/b/c/.verb.md'], '**/*.md', { dot: true }), ['a/b/c/.verb.md']); assert.deepStrictEqual(match(['d.md'], '*.md', { dot: true }), ['d.md']); - assert.deepStrictEqual(match(fixtures, 'a/*/b', { dot: true }), [ - 'a/c/b', - 'a/.d/b' - ]); + assert.deepStrictEqual(match(fixtures, 'a/*/b', { dot: true }), ['a/c/b', 'a/.d/b']); assert.deepStrictEqual(match(fixtures, 'a/.*/b'), ['a/.d/b']); - assert.deepStrictEqual(match(fixtures, 'a/.*/b', { dot: true }), [ - 'a/.d/b' - ]); + assert.deepStrictEqual(match(fixtures, 'a/.*/b', { dot: true }), ['a/.d/b']); }); it('should match dotfiles when `options.dot` is true', () => { diff --git a/test/dots-invalid.js b/test/dots-invalid.js index 8d657403..ff730a89 100644 --- a/test/dots-invalid.js +++ b/test/dots-invalid.js @@ -398,9 +398,7 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../abc/../', '**/**/**/**', { dot: true })); assert(!isMatch('abc/../abc/../', '**/**/**/**/', { dot: true })); - assert( - !isMatch('abc/../abc/abc/../', '**/**/**/**/**', { dot: true }) - ); + assert(!isMatch('abc/../abc/abc/../', '**/**/**/**/**', { dot: true })); }); it('with dot + globstar', () => { @@ -414,9 +412,7 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../abc/../', '**/.**/**/.**', { dot: true })); assert(!isMatch('abc/../abc/../', '**/.**/**/.**/', { dot: true })); - assert( - !isMatch('abc/../abc/abc/../', '**/.**/**/.**/**', { dot: true }) - ); + assert(!isMatch('abc/../abc/abc/../', '**/.**/**/.**/**', { dot: true })); }); it('with globstar + dot + globstar', () => { @@ -428,15 +424,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '**/**.**/', { dot: true })); assert(!isMatch('abc/../', '**/**.**/**', { dot: true })); - assert( - !isMatch('abc/../abc/../', '**/**.**/**/**.**', { dot: true }) - ); - assert( - !isMatch('abc/../abc/../', '**/**.**/**/**.**/', { dot: true }) - ); - assert( - !isMatch('abc/../abc/abc/../', '**/**.**/**/.**/**', { dot: true }) - ); + assert(!isMatch('abc/../abc/../', '**/**.**/**/**.**', { dot: true })); + assert(!isMatch('abc/../abc/../', '**/**.**/**/**.**/', { dot: true })); + assert(!isMatch('abc/../abc/abc/../', '**/**.**/**/.**/**', { dot: true })); }); it('with globstar + dot', () => { @@ -450,9 +440,7 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../abc/../', '**/**./**/**.', { dot: true })); assert(!isMatch('abc/../abc/../', '**/**./**/**./', { dot: true })); - assert( - !isMatch('abc/../abc/abc/../', '**/**./**/**./**', { dot: true }) - ); + assert(!isMatch('abc/../abc/abc/../', '**/**./**/**./**', { dot: true })); }); }); }); @@ -490,9 +478,7 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('../abc', '**/abc/**/**', { strictSlashes: true })); assert(!isMatch('../abc', '**/**/abc/**', { strictSlashes: true })); - assert( - !isMatch('../abc', '**/**/abc/**/**', { strictSlashes: true }) - ); + assert(!isMatch('../abc', '**/**/abc/**/**', { strictSlashes: true })); }); it('with dot + globstar', () => { @@ -519,9 +505,7 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('/../abc', '*/*/*', { strictSlashes: true })); assert(!isMatch('abc/../abc', '*/*/*', { strictSlashes: true })); - assert( - !isMatch('abc/../abc/abc', '*/*/*/*', { strictSlashes: true }) - ); + assert(!isMatch('abc/../abc/abc', '*/*/*/*', { strictSlashes: true })); }); it('with dot + star', () => { @@ -546,9 +530,7 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('/../abc', '**/**/**', { strictSlashes: true })); assert(!isMatch('abc/../abc', '**/**/**', { strictSlashes: true })); - assert( - !isMatch('abc/../abc/abc', '**/**/**/**', { strictSlashes: true }) - ); + assert(!isMatch('abc/../abc/abc', '**/**/**/**', { strictSlashes: true })); }); it('with dot + globstar', () => { @@ -574,9 +556,7 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('/../abc', '/**.**/**', { strictSlashes: true })); assert(!isMatch('/../abc', '/*.*/**', { strictSlashes: true })); - assert( - !isMatch('abc/../abc', '**/**.**/**', { strictSlashes: true }) - ); + assert(!isMatch('abc/../abc', '**/**.**/**', { strictSlashes: true })); assert(!isMatch('abc/../abc', '**/*.*/**', { strictSlashes: true })); assert(!isMatch('abc/../abc', '/**.**/**', { strictSlashes: true })); @@ -594,15 +574,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '*/*/', { strictSlashes: true })); assert(!isMatch('abc/../', '*/*/*', { strictSlashes: true })); - assert( - !isMatch('abc/../abc/../', '*/*/*/*', { strictSlashes: true }) - ); - assert( - !isMatch('abc/../abc/../', '*/*/*/*/', { strictSlashes: true }) - ); - assert( - !isMatch('abc/../abc/abc/../', '*/*/*/*/*', { strictSlashes: true }) - ); + assert(!isMatch('abc/../abc/../', '*/*/*/*', { strictSlashes: true })); + assert(!isMatch('abc/../abc/../', '*/*/*/*/', { strictSlashes: true })); + assert(!isMatch('abc/../abc/abc/../', '*/*/*/*/*', { strictSlashes: true })); }); it('with dot + star', () => { @@ -614,17 +588,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '*/.*/', { strictSlashes: true })); assert(!isMatch('abc/../', '*/.*/*', { strictSlashes: true })); - assert( - !isMatch('abc/../abc/../', '*/.*/*/.*', { strictSlashes: true }) - ); - assert( - !isMatch('abc/../abc/../', '*/.*/*/.*/', { strictSlashes: true }) - ); - assert( - !isMatch('abc/../abc/abc/../', '*/.*/*/.*/*', { - strictSlashes: true - }) - ); + assert(!isMatch('abc/../abc/../', '*/.*/*/.*', { strictSlashes: true })); + assert(!isMatch('abc/../abc/../', '*/.*/*/.*/', { strictSlashes: true })); + assert(!isMatch('abc/../abc/abc/../', '*/.*/*/.*/*', { strictSlashes: true })); }); it('with star + dot', () => { @@ -636,17 +602,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '*/*./', { strictSlashes: true })); assert(!isMatch('abc/../', '*/*./*', { strictSlashes: true })); - assert( - !isMatch('abc/../abc/../', '*/*./*/*.', { strictSlashes: true }) - ); - assert( - !isMatch('abc/../abc/../', '*/*./*/*./', { strictSlashes: true }) - ); - assert( - !isMatch('abc/../abc/abc/../', '*/*./*/*./*', { - strictSlashes: true - }) - ); + assert(!isMatch('abc/../abc/../', '*/*./*/*.', { strictSlashes: true })); + assert(!isMatch('abc/../abc/../', '*/*./*/*./', { strictSlashes: true })); + assert(!isMatch('abc/../abc/abc/../', '*/*./*/*./*', { strictSlashes: true })); }); it('with globstar', () => { @@ -658,17 +616,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '**/**/', { strictSlashes: true })); assert(!isMatch('abc/../', '**/**/**', { strictSlashes: true })); - assert( - !isMatch('abc/../abc/../', '**/**/**/**', { strictSlashes: true }) - ); - assert( - !isMatch('abc/../abc/../', '**/**/**/**/', { strictSlashes: true }) - ); - assert( - !isMatch('abc/../abc/abc/../', '**/**/**/**/**', { - strictSlashes: true - }) - ); + assert(!isMatch('abc/../abc/../', '**/**/**/**', { strictSlashes: true })); + assert(!isMatch('abc/../abc/../', '**/**/**/**/', { strictSlashes: true })); + assert(!isMatch('abc/../abc/abc/../', '**/**/**/**/**', { strictSlashes: true })); }); it('with dot + globstar', () => { @@ -680,19 +630,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '**/.**/', { strictSlashes: true })); assert(!isMatch('abc/../', '**/.**/**', { strictSlashes: true })); - assert( - !isMatch('abc/../abc/../', '**/.**/**/.**', { strictSlashes: true }) - ); - assert( - !isMatch('abc/../abc/../', '**/.**/**/.**/', { - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/abc/../', '**/.**/**/.**/**', { - strictSlashes: true - }) - ); + assert(!isMatch('abc/../abc/../', '**/.**/**/.**', { strictSlashes: true })); + assert(!isMatch('abc/../abc/../', '**/.**/**/.**/', { strictSlashes: true })); + assert(!isMatch('abc/../abc/abc/../', '**/.**/**/.**/**', { strictSlashes: true })); }); it('with globstar + dot + globstar', () => { @@ -704,21 +644,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '**/**.**/', { strictSlashes: true })); assert(!isMatch('abc/../', '**/**.**/**', { strictSlashes: true })); - assert( - !isMatch('abc/../abc/../', '**/**.**/**/**.**', { - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/../', '**/**.**/**/**.**/', { - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/abc/../', '**/**.**/**/.**/**', { - strictSlashes: true - }) - ); + assert(!isMatch('abc/../abc/../', '**/**.**/**/**.**', { strictSlashes: true })); + assert(!isMatch('abc/../abc/../', '**/**.**/**/**.**/', { strictSlashes: true })); + assert(!isMatch('abc/../abc/abc/../', '**/**.**/**/.**/**', { strictSlashes: true })); }); it('with globstar + dot', () => { @@ -730,19 +658,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/../', '**/**./', { strictSlashes: true })); assert(!isMatch('abc/../', '**/**./**', { strictSlashes: true })); - assert( - !isMatch('abc/../abc/../', '**/**./**/**.', { strictSlashes: true }) - ); - assert( - !isMatch('abc/../abc/../', '**/**./**/**./', { - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/abc/../', '**/**./**/**./**', { - strictSlashes: true - }) - ); + assert(!isMatch('abc/../abc/../', '**/**./**/**.', { strictSlashes: true })); + assert(!isMatch('abc/../abc/../', '**/**./**/**./', { strictSlashes: true })); + assert(!isMatch('abc/../abc/abc/../', '**/**./**/**./**', { strictSlashes: true })); }); }); }); @@ -751,580 +669,218 @@ describe('invalid (exclusive) dots', () => { describe('should not match leading double-dots', () => { it('with single star', () => { assert(!isMatch('../abc', '*/*', { dot: true, strictSlashes: true })); - assert( - !isMatch('../abc', '*/abc', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('../abc', '*/abc/*', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('../abc', '*/abc', { dot: true, strictSlashes: true })); + assert(!isMatch('../abc', '*/abc/*', { dot: true, strictSlashes: true })); }); it('with dot + single star', () => { - assert( - !isMatch('../abc', '.*/*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('../abc', '.*/abc', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('../abc', '.*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('../abc', '.*/abc', { dot: true, strictSlashes: true })); - assert( - !isMatch('../abc', '*./*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('../abc', '*./abc', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('../abc', '*./*', { dot: true, strictSlashes: true })); + assert(!isMatch('../abc', '*./abc', { dot: true, strictSlashes: true })); }); it('with globstar', () => { assert(!isMatch('../abc', '**', { dot: true, strictSlashes: true })); - assert( - !isMatch('../abc', '**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('../abc', '**/**/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('../abc', '**/abc', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('../abc', '**/abc/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('../abc', 'abc/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('../abc', 'abc/**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('../abc', 'abc/**/**/**', { - dot: true, - strictSlashes: true - }) - ); - - assert( - !isMatch('../abc', '**/abc', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('../abc', '**/abc/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('../abc', '**/abc/**/**', { - dot: true, - strictSlashes: true - }) - ); - - assert( - !isMatch('../abc', '**/**/abc/**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('../abc', '**/**/abc/**/**', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('../abc', '**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('../abc', '**/**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('../abc', '**/abc', { dot: true, strictSlashes: true })); + assert(!isMatch('../abc', '**/abc/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('../abc', 'abc/**', { dot: true, strictSlashes: true })); + assert(!isMatch('../abc', 'abc/**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('../abc', 'abc/**/**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('../abc', '**/abc', { dot: true, strictSlashes: true })); + assert(!isMatch('../abc', '**/abc/**', { dot: true, strictSlashes: true })); + assert(!isMatch('../abc', '**/abc/**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('../abc', '**/**/abc/**', { dot: true, strictSlashes: true })); + assert(!isMatch('../abc', '**/**/abc/**/**', { dot: true, strictSlashes: true })); }); it('with dot + globstar', () => { assert(!isMatch('../abc', '.**', { dot: true, strictSlashes: true })); - assert( - !isMatch('../abc', '.**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('../abc', '.**/abc', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('../abc', '.**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('../abc', '.**/abc', { dot: true, strictSlashes: true })); }); it('with globstar + dot + globstar', () => { - assert( - !isMatch('../abc', '*.*/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('../abc', '*.*/abc', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('../abc', '*.*/**', { dot: true, strictSlashes: true })); + assert(!isMatch('../abc', '*.*/abc', { dot: true, strictSlashes: true })); }); it('with globstar + dot', () => { - assert( - !isMatch('../abc', '**./**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('../abc', '**./abc', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('../abc', '**./**', { dot: true, strictSlashes: true })); + assert(!isMatch('../abc', '**./abc', { dot: true, strictSlashes: true })); }); }); describe('should not match nested double-dots', () => { it('with star', () => { - assert( - !isMatch('/../abc', '*/*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/../abc', '/*/*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/../abc', '*/*/*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../abc', '*/*/*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../abc/abc', '*/*/*/*', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('/../abc', '*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('/../abc', '/*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('/../abc', '*/*/*', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../abc', '*/*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/abc', '*/*/*/*', { dot: true, strictSlashes: true })); }); it('with dot + star', () => { - assert( - !isMatch('/../abc', '*/.*/*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/../abc', '/.*/*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('/../abc', '*/*.*/*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/../abc', '/*.*/*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('/../abc', '*/*./*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/../abc', '/*./*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../abc', '*/.*/*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../abc', '*/*.*/*', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc', '*/*./*', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('/../abc', '*/.*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('/../abc', '/.*/*', { dot: true, strictSlashes: true })); + + assert(!isMatch('/../abc', '*/*.*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('/../abc', '/*.*/*', { dot: true, strictSlashes: true })); + + assert(!isMatch('/../abc', '*/*./*', { dot: true, strictSlashes: true })); + assert(!isMatch('/../abc', '/*./*', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../abc', '*/.*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc', '*/*.*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc', '*/*./*', { dot: true, strictSlashes: true })); }); it('with globstar', () => { assert(!isMatch('/../abc', '**', { dot: true, strictSlashes: true })); - assert( - !isMatch('/../abc', '**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/../abc', '/**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/../abc', '**/**/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../abc', '**/**/**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/abc', '**/**/**/**', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('/../abc', '**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('/../abc', '/**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('/../abc', '**/**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../abc', '**/**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/abc', '**/**/**/**', { dot: true, strictSlashes: true })); }); it('with dot + globstar', () => { - assert( - !isMatch('/../abc', '**/.**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/../abc', '/.**/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../abc', '**/.**/**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc', '/.**/**', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('/../abc', '**/.**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('/../abc', '/.**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../abc', '**/.**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc', '/.**/**', { dot: true, strictSlashes: true })); }); it('with globstar + dot', () => { - assert( - !isMatch('/../abc', '**/**./**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/../abc', '/**./**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../abc', '**/**./**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc', '/**./**', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('/../abc', '**/**./**', { dot: true, strictSlashes: true })); + assert(!isMatch('/../abc', '/**./**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../abc', '**/**./**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc', '/**./**', { dot: true, strictSlashes: true })); }); it('with globstar + dot + globstar', () => { - assert( - !isMatch('/../abc', '**/**.**/**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('/../abc', '**/*.*/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('/../abc', '/**.**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/../abc', '/*.*/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../abc', '**/**.**/**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc', '**/*.*/**', { - dot: true, - strictSlashes: true - }) - ); - - assert( - !isMatch('abc/../abc', '/**.**/**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc', '/*.*/**', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('/../abc', '**/**.**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('/../abc', '**/*.*/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('/../abc', '/**.**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('/../abc', '/*.*/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../abc', '**/**.**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc', '**/*.*/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../abc', '/**.**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc', '/*.*/**', { dot: true, strictSlashes: true })); }); }); describe('should not match trailing double-dots', () => { it('with single star', () => { assert(!isMatch('abc/..', '*/*', { dot: true, strictSlashes: true })); - assert( - !isMatch('abc/..', '*/*/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/..', '*/*/*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../', '*/*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../', '*/*/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../', '*/*/*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../abc/../', '*/*/*/*', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/../', '*/*/*/*/', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/abc/../', '*/*/*/*/*', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('abc/..', '*/*/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/..', '*/*/*', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../', '*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../', '*/*/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../', '*/*/*', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../abc/../', '*/*/*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/../', '*/*/*/*/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/abc/../', '*/*/*/*/*', { dot: true, strictSlashes: true })); }); it('with dot + star', () => { - assert( - !isMatch('abc/..', '*/.*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/..', '*/.*/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/..', '*/.*/*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../', '*/.*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../', '*/.*/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../', '*/.*/*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../abc/../', '*/.*/*/.*', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/../', '*/.*/*/.*/', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/abc/../', '*/.*/*/.*/*', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('abc/..', '*/.*', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/..', '*/.*/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/..', '*/.*/*', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../', '*/.*', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../', '*/.*/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../', '*/.*/*', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../abc/../', '*/.*/*/.*', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/../', '*/.*/*/.*/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/abc/../', '*/.*/*/.*/*', { dot: true, strictSlashes: true })); }); it('with star + dot', () => { - assert( - !isMatch('abc/..', '*/*.', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/..', '*/*./', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/..', '*/*./*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../', '*/*.', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../', '*/*./', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../', '*/*./*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../abc/../', '*/*./*/*.', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/../', '*/*./*/*./', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/abc/../', '*/*./*/*./*', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('abc/..', '*/*.', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/..', '*/*./', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/..', '*/*./*', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../', '*/*.', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../', '*/*./', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../', '*/*./*', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../abc/../', '*/*./*/*.', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/../', '*/*./*/*./', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/abc/../', '*/*./*/*./*', { dot: true, strictSlashes: true })); }); it('with globstar', () => { - assert( - !isMatch('abc/..', '**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/..', '**/**/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/..', '**/**/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../', '**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../', '**/**/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../', '**/**/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../abc/../', '**/**/**/**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/../', '**/**/**/**/', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/abc/../', '**/**/**/**/**', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('abc/..', '**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/..', '**/**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/..', '**/**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../', '**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../', '**/**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../', '**/**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../abc/../', '**/**/**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/../', '**/**/**/**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/abc/../', '**/**/**/**/**', { dot: true, strictSlashes: true })); }); it('with dot + globstar', () => { - assert( - !isMatch('abc/..', '**/.**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/..', '**/.**/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/..', '**/.**/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../', '**/.**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../', '**/.**/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../', '**/.**/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../abc/../', '**/.**/**/.**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/../', '**/.**/**/.**/', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/abc/../', '**/.**/**/.**/**', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('abc/..', '**/.**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/..', '**/.**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/..', '**/.**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../', '**/.**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../', '**/.**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../', '**/.**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../abc/../', '**/.**/**/.**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/../', '**/.**/**/.**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/abc/../', '**/.**/**/.**/**', { dot: true, strictSlashes: true })); }); it('with globstar + dot + globstar', () => { - assert( - !isMatch('abc/..', '**/**.**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/..', '**/**.**/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/..', '**/**.**/**', { - dot: true, - strictSlashes: true - }) - ); - - assert( - !isMatch('abc/../', '**/**.**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../', '**/**.**/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../', '**/**.**/**', { - dot: true, - strictSlashes: true - }) - ); - - assert( - !isMatch('abc/../abc/../', '**/**.**/**/**.**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/../', '**/**.**/**/**.**/', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/abc/../', '**/**.**/**/.**/**', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('abc/..', '**/**.**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/..', '**/**.**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/..', '**/**.**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../', '**/**.**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../', '**/**.**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../', '**/**.**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../abc/../', '**/**.**/**/**.**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/../', '**/**.**/**/**.**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/abc/../', '**/**.**/**/.**/**', { dot: true, strictSlashes: true })); }); it('with globstar + dot', () => { - assert( - !isMatch('abc/..', '**/**.', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/..', '**/**./', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/..', '**/**./**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../', '**/**.', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../', '**/**./', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/../', '**/**./**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/../abc/../', '**/**./**/**.', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/../', '**/**./**/**./', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/../abc/abc/../', '**/**./**/**./**', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('abc/..', '**/**.', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/..', '**/**./', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/..', '**/**./**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../', '**/**.', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../', '**/**./', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../', '**/**./**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/../abc/../', '**/**./**/**.', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/../', '**/**./**/**./', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/../abc/abc/../', '**/**./**/**./**', { dot: true, strictSlashes: true })); }); }); }); @@ -1739,9 +1295,7 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./abc/./', '**/.**/**/.**', { dot: true })); assert(!isMatch('abc/./abc/./', '**/.**/**/.**/', { dot: true })); - assert( - !isMatch('abc/./abc/abc/./', '**/.**/**/.**/**', { dot: true }) - ); + assert(!isMatch('abc/./abc/abc/./', '**/.**/**/.**/**', { dot: true })); }); it('with globstar + dot + globstar', () => { @@ -1755,9 +1309,7 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./abc/./', '**/**.**/**/**.**', { dot: true })); assert(!isMatch('abc/./abc/./', '**/**.**/**/**.**/', { dot: true })); - assert( - !isMatch('abc/./abc/abc/./', '**/**.**/**/.**/**', { dot: true }) - ); + assert(!isMatch('abc/./abc/abc/./', '**/**.**/**/.**/**', { dot: true })); }); it('with globstar + dot', () => { @@ -1771,9 +1323,7 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./abc/./', '**/**./**/**.', { dot: true })); assert(!isMatch('abc/./abc/./', '**/**./**/**./', { dot: true })); - assert( - !isMatch('abc/./abc/abc/./', '**/**./**/**./**', { dot: true }) - ); + assert(!isMatch('abc/./abc/abc/./', '**/**./**/**./**', { dot: true })); }); }); }); @@ -1863,9 +1413,7 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('/./abc', '**/**/**', { strictSlashes: true })); assert(!isMatch('abc/./abc', '**/**/**', { strictSlashes: true })); - assert( - !isMatch('abc/./abc/abc', '**/**/**/**', { strictSlashes: true }) - ); + assert(!isMatch('abc/./abc/abc', '**/**/**/**', { strictSlashes: true })); }); it('with dot + globstar', () => { @@ -1911,9 +1459,7 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./abc/./', '*/*/*/*', { strictSlashes: true })); assert(!isMatch('abc/./abc/./', '*/*/*/*/', { strictSlashes: true })); - assert( - !isMatch('abc/./abc/abc/./', '*/*/*/*/*', { strictSlashes: true }) - ); + assert(!isMatch('abc/./abc/abc/./', '*/*/*/*/*', { strictSlashes: true })); }); it('with dot + star', () => { @@ -1925,15 +1471,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./', '*/.*/', { strictSlashes: true })); assert(!isMatch('abc/./', '*/.*/*', { strictSlashes: true })); - assert( - !isMatch('abc/./abc/./', '*/.*/*/.*', { strictSlashes: true }) - ); - assert( - !isMatch('abc/./abc/./', '*/.*/*/.*/', { strictSlashes: true }) - ); - assert( - !isMatch('abc/./abc/abc/./', '*/.*/*/.*/*', { strictSlashes: true }) - ); + assert(!isMatch('abc/./abc/./', '*/.*/*/.*', { strictSlashes: true })); + assert(!isMatch('abc/./abc/./', '*/.*/*/.*/', { strictSlashes: true })); + assert(!isMatch('abc/./abc/abc/./', '*/.*/*/.*/*', { strictSlashes: true })); }); it('with star + dot', () => { @@ -1945,15 +1485,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./', '*/*./', { strictSlashes: true })); assert(!isMatch('abc/./', '*/*./*', { strictSlashes: true })); - assert( - !isMatch('abc/./abc/./', '*/*./*/*.', { strictSlashes: true }) - ); - assert( - !isMatch('abc/./abc/./', '*/*./*/*./', { strictSlashes: true }) - ); - assert( - !isMatch('abc/./abc/abc/./', '*/*./*/*./*', { strictSlashes: true }) - ); + assert(!isMatch('abc/./abc/./', '*/*./*/*.', { strictSlashes: true })); + assert(!isMatch('abc/./abc/./', '*/*./*/*./', { strictSlashes: true })); + assert(!isMatch('abc/./abc/abc/./', '*/*./*/*./*', { strictSlashes: true })); }); it('with globstar', () => { @@ -1965,17 +1499,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./', '**/**/', { strictSlashes: true })); assert(!isMatch('abc/./', '**/**/**', { strictSlashes: true })); - assert( - !isMatch('abc/./abc/./', '**/**/**/**', { strictSlashes: true }) - ); - assert( - !isMatch('abc/./abc/./', '**/**/**/**/', { strictSlashes: true }) - ); - assert( - !isMatch('abc/./abc/abc/./', '**/**/**/**/**', { - strictSlashes: true - }) - ); + assert(!isMatch('abc/./abc/./', '**/**/**/**', { strictSlashes: true })); + assert(!isMatch('abc/./abc/./', '**/**/**/**/', { strictSlashes: true })); + assert(!isMatch('abc/./abc/abc/./', '**/**/**/**/**', { strictSlashes: true })); }); it('with dot + globstar', () => { @@ -1987,17 +1513,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./', '**/.**/', { strictSlashes: true })); assert(!isMatch('abc/./', '**/.**/**', { strictSlashes: true })); - assert( - !isMatch('abc/./abc/./', '**/.**/**/.**', { strictSlashes: true }) - ); - assert( - !isMatch('abc/./abc/./', '**/.**/**/.**/', { strictSlashes: true }) - ); - assert( - !isMatch('abc/./abc/abc/./', '**/.**/**/.**/**', { - strictSlashes: true - }) - ); + assert(!isMatch('abc/./abc/./', '**/.**/**/.**', { strictSlashes: true })); + assert(!isMatch('abc/./abc/./', '**/.**/**/.**/', { strictSlashes: true })); + assert(!isMatch('abc/./abc/abc/./', '**/.**/**/.**/**', { strictSlashes: true })); }); it('with globstar + dot + globstar', () => { @@ -2009,21 +1527,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./', '**/**.**/', { strictSlashes: true })); assert(!isMatch('abc/./', '**/**.**/**', { strictSlashes: true })); - assert( - !isMatch('abc/./abc/./', '**/**.**/**/**.**', { - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/./', '**/**.**/**/**.**/', { - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/abc/./', '**/**.**/**/.**/**', { - strictSlashes: true - }) - ); + assert(!isMatch('abc/./abc/./', '**/**.**/**/**.**', { strictSlashes: true })); + assert(!isMatch('abc/./abc/./', '**/**.**/**/**.**/', { strictSlashes: true })); + assert(!isMatch('abc/./abc/abc/./', '**/**.**/**/.**/**', { strictSlashes: true })); }); it('with globstar + dot', () => { @@ -2035,17 +1541,9 @@ describe('invalid (exclusive) dots', () => { assert(!isMatch('abc/./', '**/**./', { strictSlashes: true })); assert(!isMatch('abc/./', '**/**./**', { strictSlashes: true })); - assert( - !isMatch('abc/./abc/./', '**/**./**/**.', { strictSlashes: true }) - ); - assert( - !isMatch('abc/./abc/./', '**/**./**/**./', { strictSlashes: true }) - ); - assert( - !isMatch('abc/./abc/abc/./', '**/**./**/**./**', { - strictSlashes: true - }) - ); + assert(!isMatch('abc/./abc/./', '**/**./**/**.', { strictSlashes: true })); + assert(!isMatch('abc/./abc/./', '**/**./**/**./', { strictSlashes: true })); + assert(!isMatch('abc/./abc/abc/./', '**/**./**/**./**', { strictSlashes: true })); }); }); }); @@ -2054,269 +1552,118 @@ describe('invalid (exclusive) dots', () => { describe('should not match leading single-dots', () => { it('with single star', () => { assert(!isMatch('./abc', '*/*', { dot: true, strictSlashes: true })); - assert( - !isMatch('./abc', '*/abc', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('./abc', '*/abc/*', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('./abc', '*/abc', { dot: true, strictSlashes: true })); + assert(!isMatch('./abc', '*/abc/*', { dot: true, strictSlashes: true })); }); it('with dot + single star', () => { assert(!isMatch('./abc', '.*/*', { dot: true, strictSlashes: true })); - assert( - !isMatch('./abc', '.*/abc', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('./abc', '.*/abc', { dot: true, strictSlashes: true })); assert(!isMatch('./abc', '*./*', { dot: true, strictSlashes: true })); - assert( - !isMatch('./abc', '*./abc', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('./abc', '*./abc', { dot: true, strictSlashes: true })); }); it('with globstar', () => { assert(!isMatch('./abc', '**', { dot: true, strictSlashes: true })); - assert( - !isMatch('./abc', '**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('./abc', '**/**/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('./abc', '**/abc', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('./abc', '**/abc/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('./abc', 'abc/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('./abc', 'abc/**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('./abc', 'abc/**/**/**', { - dot: true, - strictSlashes: true - }) - ); - - assert( - !isMatch('./abc', '**/abc', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('./abc', '**/abc/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('./abc', '**/abc/**/**', { - dot: true, - strictSlashes: true - }) - ); - - assert( - !isMatch('./abc', '**/**/abc/**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('./abc', '**/**/abc/**/**', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('./abc', '**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('./abc', '**/**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('./abc', '**/abc', { dot: true, strictSlashes: true })); + assert(!isMatch('./abc', '**/abc/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('./abc', 'abc/**', { dot: true, strictSlashes: true })); + assert(!isMatch('./abc', 'abc/**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('./abc', 'abc/**/**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('./abc', '**/abc', { dot: true, strictSlashes: true })); + assert(!isMatch('./abc', '**/abc/**', { dot: true, strictSlashes: true })); + assert(!isMatch('./abc', '**/abc/**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('./abc', '**/**/abc/**', { dot: true, strictSlashes: true })); + assert(!isMatch('./abc', '**/**/abc/**/**', { dot: true, strictSlashes: true })); }); it('with dot + globstar', () => { assert(!isMatch('./abc', '.**', { dot: true, strictSlashes: true })); - assert( - !isMatch('./abc', '.**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('./abc', '.**/abc', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('./abc', '.**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('./abc', '.**/abc', { dot: true, strictSlashes: true })); }); it('with globstar + dot + globstar', () => { - assert( - !isMatch('./abc', '*.*/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('./abc', '*.*/abc', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('./abc', '*.*/**', { dot: true, strictSlashes: true })); + assert(!isMatch('./abc', '*.*/abc', { dot: true, strictSlashes: true })); }); it('with globstar + dot', () => { - assert( - !isMatch('./abc', '**./**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('./abc', '**./abc', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('./abc', '**./**', { dot: true, strictSlashes: true })); + assert(!isMatch('./abc', '**./abc', { dot: true, strictSlashes: true })); }); }); describe('should not match nested single-dots', () => { it('with star', () => { assert(!isMatch('/./abc', '*/*', { dot: true, strictSlashes: true })); - assert( - !isMatch('/./abc', '/*/*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/./abc', '*/*/*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./abc', '*/*/*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./abc/abc', '*/*/*/*', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('/./abc', '/*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('/./abc', '*/*/*', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./abc', '*/*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/abc', '*/*/*/*', { dot: true, strictSlashes: true })); }); it('with dot + star', () => { - assert( - !isMatch('/./abc', '*/.*/*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/./abc', '/.*/*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('/./abc', '*/*.*/*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/./abc', '/*.*/*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('/./abc', '*/*./*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/./abc', '/*./*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./abc', '*/.*/*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./abc', '*/*.*/*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./abc', '*/*./*', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('/./abc', '*/.*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('/./abc', '/.*/*', { dot: true, strictSlashes: true })); + + assert(!isMatch('/./abc', '*/*.*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('/./abc', '/*.*/*', { dot: true, strictSlashes: true })); + + assert(!isMatch('/./abc', '*/*./*', { dot: true, strictSlashes: true })); + assert(!isMatch('/./abc', '/*./*', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./abc', '*/.*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc', '*/*.*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc', '*/*./*', { dot: true, strictSlashes: true })); }); it('with globstar', () => { assert(!isMatch('/./abc', '**', { dot: true, strictSlashes: true })); - assert( - !isMatch('/./abc', '**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/./abc', '/**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/./abc', '**/**/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./abc', '**/**/**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/abc', '**/**/**/**', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('/./abc', '**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('/./abc', '/**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('/./abc', '**/**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./abc', '**/**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/abc', '**/**/**/**', { dot: true, strictSlashes: true })); }); it('with dot + globstar', () => { - assert( - !isMatch('/./abc', '**/.**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/./abc', '/.**/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./abc', '**/.**/**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc', '/.**/**', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('/./abc', '**/.**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('/./abc', '/.**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./abc', '**/.**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc', '/.**/**', { dot: true, strictSlashes: true })); }); it('with globstar + dot', () => { - assert( - !isMatch('/./abc', '**/**./**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/./abc', '/**./**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./abc', '**/**./**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc', '/**./**', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('/./abc', '**/**./**', { dot: true, strictSlashes: true })); + assert(!isMatch('/./abc', '/**./**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./abc', '**/**./**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc', '/**./**', { dot: true, strictSlashes: true })); }); it('with globstar + dot + globstar', () => { - assert( - !isMatch('/./abc', '**/**.**/**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('/./abc', '**/*.*/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('/./abc', '/**.**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('/./abc', '/*.*/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./abc', '**/**.**/**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc', '**/*.*/**', { - dot: true, - strictSlashes: true - }) - ); - - assert( - !isMatch('abc/./abc', '/**.**/**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc', '/*.*/**', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('/./abc', '**/**.**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('/./abc', '**/*.*/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('/./abc', '/**.**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('/./abc', '/*.*/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./abc', '**/**.**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc', '**/*.*/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./abc', '/**.**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc', '/*.*/**', { dot: true, strictSlashes: true })); }); }); @@ -2324,281 +1671,99 @@ describe('invalid (exclusive) dots', () => { it('with single star', () => { assert(!isMatch('abc/.', '*/*', { dot: true, strictSlashes: true })); assert(!isMatch('abc/.', '*/*/', { dot: true, strictSlashes: true })); - assert( - !isMatch('abc/.', '*/*/*', { dot: true, strictSlashes: true }) - ); + assert(!isMatch('abc/.', '*/*/*', { dot: true, strictSlashes: true })); assert(!isMatch('abc/./', '*/*', { dot: true, strictSlashes: true })); - assert( - !isMatch('abc/./', '*/*/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./', '*/*/*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./abc/./', '*/*/*/*', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/./', '*/*/*/*/', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/abc/./', '*/*/*/*/*', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('abc/./', '*/*/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./', '*/*/*', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./abc/./', '*/*/*/*', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/./', '*/*/*/*/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/abc/./', '*/*/*/*/*', { dot: true, strictSlashes: true })); }); it('with dot + star', () => { assert(!isMatch('abc/.', '*/.*', { dot: true, strictSlashes: true })); - assert( - !isMatch('abc/.', '*/.*/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/.', '*/.*/*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./', '*/.*', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./', '*/.*/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./', '*/.*/*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./abc/./', '*/.*/*/.*', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/./', '*/.*/*/.*/', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/abc/./', '*/.*/*/.*/*', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('abc/.', '*/.*/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/.', '*/.*/*', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./', '*/.*', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./', '*/.*/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./', '*/.*/*', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./abc/./', '*/.*/*/.*', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/./', '*/.*/*/.*/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/abc/./', '*/.*/*/.*/*', { dot: true, strictSlashes: true })); }); it('with star + dot', () => { assert(!isMatch('abc/.', '*/*.', { dot: true, strictSlashes: true })); - assert( - !isMatch('abc/.', '*/*./', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/.', '*/*./*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./', '*/*.', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./', '*/*./', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./', '*/*./*', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./abc/./', '*/*./*/*.', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/./', '*/*./*/*./', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/abc/./', '*/*./*/*./*', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('abc/.', '*/*./', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/.', '*/*./*', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./', '*/*.', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./', '*/*./', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./', '*/*./*', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./abc/./', '*/*./*/*.', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/./', '*/*./*/*./', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/abc/./', '*/*./*/*./*', { dot: true, strictSlashes: true })); }); it('with globstar', () => { - assert( - !isMatch('abc/.', '**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/.', '**/**/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/.', '**/**/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./', '**/**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./', '**/**/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./', '**/**/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./abc/./', '**/**/**/**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/./', '**/**/**/**/', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/abc/./', '**/**/**/**/**', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('abc/.', '**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/.', '**/**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/.', '**/**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./', '**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./', '**/**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./', '**/**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./abc/./', '**/**/**/**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/./', '**/**/**/**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/abc/./', '**/**/**/**/**', { dot: true, strictSlashes: true })); }); it('with dot + globstar', () => { - assert( - !isMatch('abc/.', '**/.**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/.', '**/.**/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/.', '**/.**/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./', '**/.**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./', '**/.**/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./', '**/.**/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./abc/./', '**/.**/**/.**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/./', '**/.**/**/.**/', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/abc/./', '**/.**/**/.**/**', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('abc/.', '**/.**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/.', '**/.**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/.', '**/.**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./', '**/.**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./', '**/.**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./', '**/.**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./abc/./', '**/.**/**/.**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/./', '**/.**/**/.**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/abc/./', '**/.**/**/.**/**', { dot: true, strictSlashes: true })); }); it('with globstar + dot + globstar', () => { - assert( - !isMatch('abc/.', '**/**.**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/.', '**/**.**/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/.', '**/**.**/**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./', '**/**.**', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./', '**/**.**/', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./', '**/**.**/**', { - dot: true, - strictSlashes: true - }) - ); - - assert( - !isMatch('abc/./abc/./', '**/**.**/**/**.**', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/./', '**/**.**/**/**.**/', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/abc/./', '**/**.**/**/.**/**', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('abc/.', '**/**.**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/.', '**/**.**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/.', '**/**.**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./', '**/**.**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./', '**/**.**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./', '**/**.**/**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./abc/./', '**/**.**/**/**.**', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/./', '**/**.**/**/**.**/', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/abc/./', '**/**.**/**/.**/**', { dot: true, strictSlashes: true })); }); it('with globstar + dot', () => { - assert( - !isMatch('abc/.', '**/**.', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/.', '**/**./', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/.', '**/**./**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./', '**/**.', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./', '**/**./', { dot: true, strictSlashes: true }) - ); - assert( - !isMatch('abc/./', '**/**./**', { dot: true, strictSlashes: true }) - ); - - assert( - !isMatch('abc/./abc/./', '**/**./**/**.', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/./', '**/**./**/**./', { - dot: true, - strictSlashes: true - }) - ); - assert( - !isMatch('abc/./abc/abc/./', '**/**./**/**./**', { - dot: true, - strictSlashes: true - }) - ); + assert(!isMatch('abc/.', '**/**.', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/.', '**/**./', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/.', '**/**./**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./', '**/**.', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./', '**/**./', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./', '**/**./**', { dot: true, strictSlashes: true })); + + assert(!isMatch('abc/./abc/./', '**/**./**/**.', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/./', '**/**./**/**./', { dot: true, strictSlashes: true })); + assert(!isMatch('abc/./abc/abc/./', '**/**./**/**./**', { dot: true, strictSlashes: true })); }); }); }); diff --git a/test/extglobs-bash.js b/test/extglobs-bash.js index 835ea6f0..bea8d179 100644 --- a/test/extglobs-bash.js +++ b/test/extglobs-bash.js @@ -17,9 +17,7 @@ describe('extglobs (bash)', () => { }); it('"*(a|b[)" should not match "\\*\\(a|b\\[\\)"', () => { - assert( - !isMatch('*(a|b[)', '\\*\\(a|b\\[\\)', { bash: true, windows: true }) - ); + assert(!isMatch('*(a|b[)', '\\*\\(a|b\\[\\)', { bash: true, windows: true })); }); it('"***" should match "\\*\\*\\*"', () => { @@ -27,42 +25,19 @@ describe('extglobs (bash)', () => { }); it('"-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1" should not match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { - assert( - !isMatch( - '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1', - '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', - { bash: true, windows: true } - ) - ); + assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', { bash: true, windows: true })); }); it('"-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1" should match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { - assert( - isMatch( - '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1', - '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', - { bash: true, windows: true } - ) - ); + assert(isMatch('-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', { bash: true, windows: true })); }); it('"-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1" should not match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { - assert( - !isMatch( - '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1', - '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', - { bash: true, windows: true } - ) - ); + assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', { bash: true, windows: true })); }); it('"/dev/udp/129.22.8.102/45" should match "/dev\\/@(tcp|udp)\\/*\\/*"', () => { - assert( - isMatch('/dev/udp/129.22.8.102/45', '/dev\\/@(tcp|udp)\\/*\\/*', { - bash: true, - windows: true - }) - ); + assert(isMatch('/dev/udp/129.22.8.102/45', '/dev\\/@(tcp|udp)\\/*\\/*', { bash: true, windows: true })); }); it('"/x/y/z" should match "/x/y/z"', () => { @@ -102,9 +77,7 @@ describe('extglobs (bash)', () => { }); it('"123abc" should not match "a(b*(foo|bar))d"', () => { - assert( - !isMatch('123abc', 'a(b*(foo|bar))d', { bash: true, windows: true }) - ); + assert(!isMatch('123abc', 'a(b*(foo|bar))d', { bash: true, windows: true })); }); it('"123abc" should not match "ab*(e|f)"', () => { @@ -144,9 +117,7 @@ describe('extglobs (bash)', () => { }); it('"137577991" should match "*(0|1|3|5|7|9)"', () => { - assert( - isMatch('137577991', '*(0|1|3|5|7|9)', { bash: true, windows: true }) - ); + assert(isMatch('137577991', '*(0|1|3|5|7|9)', { bash: true, windows: true })); }); it('"2468" should not match "*(0|1|3|5|7|9)"', () => { @@ -278,9 +249,7 @@ describe('extglobs (bash)', () => { }); it('"a." should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert( - !isMatch('a.', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true }) - ); + assert(!isMatch('a.', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); }); it('"a." should not match "*.+(b|d)"', () => { @@ -328,9 +297,7 @@ describe('extglobs (bash)', () => { }); it('"a.a" should match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert( - isMatch('a.a', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true }) - ); + assert(isMatch('a.a', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); }); it('"a.a" should not match "*.+(b|d)"', () => { @@ -346,9 +313,7 @@ describe('extglobs (bash)', () => { }); it('"a.a.a" should not match "!(*[a-b].[a-b]*)"', () => { - assert( - !isMatch('a.a.a', '!(*[a-b].[a-b]*)', { bash: true, windows: true }) - ); + assert(!isMatch('a.a.a', '!(*[a-b].[a-b]*)', { bash: true, windows: true })); }); it('"a.a.a" should not match "!*.(a|b)"', () => { @@ -380,15 +345,11 @@ describe('extglobs (bash)', () => { }); it('"a.abcd" should not match "!(*.a|*.b|*.c)*"', () => { - assert( - !isMatch('a.abcd', '!(*.a|*.b|*.c)*', { bash: true, windows: true }) - ); + assert(!isMatch('a.abcd', '!(*.a|*.b|*.c)*', { bash: true, windows: true })); }); it('"a.abcd" should match "*!(*.a|*.b|*.c)*"', () => { - assert( - isMatch('a.abcd', '*!(*.a|*.b|*.c)*', { bash: true, windows: true }) - ); + assert(isMatch('a.abcd', '*!(*.a|*.b|*.c)*', { bash: true, windows: true })); }); it('"a.abcd" should match "*!(.a|.b|.c)"', () => { @@ -404,12 +365,7 @@ describe('extglobs (bash)', () => { }); it('"a.abcd" should match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert( - isMatch('a.abcd', '*.(a|b|@(ab|a*@(b))*(c)d)', { - bash: true, - windows: true - }) - ); + assert(isMatch('a.abcd', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); }); it('"a.b" should not match "!(*.*)"', () => { @@ -453,9 +409,7 @@ describe('extglobs (bash)', () => { }); it('"a.b" should match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert( - isMatch('a.b', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true }) - ); + assert(isMatch('a.b', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); }); it('"a.b" should match "*.+(b|d)"', () => { @@ -511,12 +465,7 @@ describe('extglobs (bash)', () => { }); it('"a.c" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert( - !isMatch('a.c', '*.(a|b|@(ab|a*@(b))*(c)d)', { - bash: true, - windows: true - }) - ); + assert(!isMatch('a.c', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); }); it('"a.c.d" should match "!(*.a|*.b|*.c)"', () => { @@ -532,12 +481,7 @@ describe('extglobs (bash)', () => { }); it('"a.c.d" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert( - !isMatch('a.c.d', '*.(a|b|@(ab|a*@(b))*(c)d)', { - bash: true, - windows: true - }) - ); + assert(!isMatch('a.c.d', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); }); it('"a.ccc" should match "!(*.[a-b]*)"', () => { @@ -637,48 +581,31 @@ describe('extglobs (bash)', () => { }); it('"a/b/c.txt" should not match "*/b/!(*).txt"', () => { - assert( - !isMatch('a/b/c.txt', '*/b/!(*).txt', { bash: true, windows: true }) - ); + assert(!isMatch('a/b/c.txt', '*/b/!(*).txt', { bash: true, windows: true })); }); it('"a/b/c.txt" should not match "*/b/!(c).txt"', () => { - assert( - !isMatch('a/b/c.txt', '*/b/!(c).txt', { bash: true, windows: true }) - ); + assert(!isMatch('a/b/c.txt', '*/b/!(c).txt', { bash: true, windows: true })); }); it('"a/b/c.txt" should match "*/b/!(cc).txt"', () => { - assert( - isMatch('a/b/c.txt', '*/b/!(cc).txt', { bash: true, windows: true }) - ); + assert(isMatch('a/b/c.txt', '*/b/!(cc).txt', { bash: true, windows: true })); }); it('"a/b/cc.txt" should not match "*/b/!(*).txt"', () => { - assert( - !isMatch('a/b/cc.txt', '*/b/!(*).txt', { bash: true, windows: true }) - ); + assert(!isMatch('a/b/cc.txt', '*/b/!(*).txt', { bash: true, windows: true })); }); it('"a/b/cc.txt" should not match "*/b/!(c).txt"', () => { - assert( - !isMatch('a/b/cc.txt', '*/b/!(c).txt', { bash: true, windows: true }) - ); + assert(!isMatch('a/b/cc.txt', '*/b/!(c).txt', { bash: true, windows: true })); }); it('"a/b/cc.txt" should not match "*/b/!(cc).txt"', () => { - assert( - !isMatch('a/b/cc.txt', '*/b/!(cc).txt', { bash: true, windows: true }) - ); + assert(!isMatch('a/b/cc.txt', '*/b/!(cc).txt', { bash: true, windows: true })); }); it('"a/dir/foo.txt" should match "*/dir/**/!(bar).txt"', () => { - assert( - isMatch('a/dir/foo.txt', '*/dir/**/!(bar).txt', { - bash: true, - windows: true - }) - ); + assert(isMatch('a/dir/foo.txt', '*/dir/**/!(bar).txt', { bash: true, windows: true })); }); it('"a/z" should not match "a/!(z)"', () => { @@ -911,15 +838,11 @@ describe('extglobs (bash)', () => { }); it('"ab/cXd/efXg/hi" should match "**/*X*/**/*i"', () => { - assert( - isMatch('ab/cXd/efXg/hi', '**/*X*/**/*i', { bash: true, windows: true }) - ); + assert(isMatch('ab/cXd/efXg/hi', '**/*X*/**/*i', { bash: true, windows: true })); }); it('"ab/cXd/efXg/hi" should match "*/*X*/*/*i"', () => { - assert( - isMatch('ab/cXd/efXg/hi', '*/*X*/*/*i', { bash: true, windows: true }) - ); + assert(isMatch('ab/cXd/efXg/hi', '*/*X*/*/*i', { bash: true, windows: true })); }); it('"ab/cXd/efXg/hi" should match "*X*i"', () => { @@ -1015,23 +938,11 @@ describe('extglobs (bash)', () => { }); it('"abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt" should match "**/*a*b*g*n*t"', () => { - assert( - isMatch( - 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt', - '**/*a*b*g*n*t', - { bash: true, windows: true } - ) - ); + assert(isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt', '**/*a*b*g*n*t', { bash: true, windows: true })); }); it('"abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz" should not match "**/*a*b*g*n*t"', () => { - assert( - !isMatch( - 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz', - '**/*a*b*g*n*t', - { bash: true, windows: true } - ) - ); + assert(!isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz', '**/*a*b*g*n*t', { bash: true, windows: true })); }); it('"abcdef" should match "(a+|b)*"', () => { @@ -1047,9 +958,7 @@ describe('extglobs (bash)', () => { }); it('"abcdef" should not match "a(b*(foo|bar))d"', () => { - assert( - !isMatch('abcdef', 'a(b*(foo|bar))d', { bash: true, windows: true }) - ); + assert(!isMatch('abcdef', 'a(b*(foo|bar))d', { bash: true, windows: true })); }); it('"abcdef" should not match "ab*(e|f)"', () => { @@ -1097,9 +1006,7 @@ describe('extglobs (bash)', () => { }); it('"abcfef" should not match "a(b*(foo|bar))d"', () => { - assert( - !isMatch('abcfef', 'a(b*(foo|bar))d', { bash: true, windows: true }) - ); + assert(!isMatch('abcfef', 'a(b*(foo|bar))d', { bash: true, windows: true })); }); it('"abcfef" should not match "ab*(e|f)"', () => { @@ -1147,9 +1054,7 @@ describe('extglobs (bash)', () => { }); it('"abcfefg" should not match "a(b*(foo|bar))d"', () => { - assert( - !isMatch('abcfefg', 'a(b*(foo|bar))d', { bash: true, windows: true }) - ); + assert(!isMatch('abcfefg', 'a(b*(foo|bar))d', { bash: true, windows: true })); }); it('"abcfefg" should not match "ab*(e|f)"', () => { @@ -1401,9 +1306,7 @@ describe('extglobs (bash)', () => { }); it('"accdef" should not match "a(b*(foo|bar))d"', () => { - assert( - !isMatch('accdef', 'a(b*(foo|bar))d', { bash: true, windows: true }) - ); + assert(!isMatch('accdef', 'a(b*(foo|bar))d', { bash: true, windows: true })); }); it('"accdef" should not match "ab*(e|f)"', () => { @@ -1755,12 +1658,7 @@ describe('extglobs (bash)', () => { }); it('"c.c" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert( - !isMatch('c.c', '*.(a|b|@(ab|a*@(b))*(c)d)', { - bash: true, - windows: true - }) - ); + assert(!isMatch('c.c', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); }); it('"c.ccc" should match "!(*.[a-b]*)"', () => { @@ -1936,12 +1834,7 @@ describe('extglobs (bash)', () => { }); it('"d.d" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert( - !isMatch('d.d', '*.(a|b|@(ab|a*@(b))*(c)d)', { - bash: true, - windows: true - }) - ); + assert(!isMatch('d.d', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); }); it('"d.js.d" should match "!(*.js)"', () => { @@ -1981,12 +1874,7 @@ describe('extglobs (bash)', () => { }); it('"e.e" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert( - !isMatch('e.e', '*.(a|b|@(ab|a*@(b))*(c)d)', { - bash: true, - windows: true - }) - ); + assert(!isMatch('e.e', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); }); it('"ef" should match "()ef"', () => { @@ -1994,48 +1882,23 @@ describe('extglobs (bash)', () => { }); it('"effgz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { - assert( - isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { - bash: true, - windows: true - }) - ); + assert(isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { bash: true, windows: true })); }); it('"efgz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { - assert( - isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { - bash: true, - windows: true - }) - ); + assert(isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { bash: true, windows: true })); }); it('"egz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { - assert( - isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { - bash: true, - windows: true - }) - ); + assert(isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { bash: true, windows: true })); }); it('"egz" should not match "@(b+(c)d|e+(f)g?|?(h)i@(j|k))"', () => { - assert( - !isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))', { - bash: true, - windows: true - }) - ); + assert(!isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))', { bash: true, windows: true })); }); it('"egzefffgzbcdij" should match "*(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { - assert( - isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { - bash: true, - windows: true - }) - ); + assert(isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { bash: true, windows: true })); }); it('"f" should not match "!(f!(o))"', () => { @@ -2083,12 +1946,7 @@ describe('extglobs (bash)', () => { }); it('"f.f" should not match "*.(a|b|@(ab|a*@(b))*(c)d)"', () => { - assert( - !isMatch('f.f', '*.(a|b|@(ab|a*@(b))*(c)d)', { - bash: true, - windows: true - }) - ); + assert(!isMatch('f.f', '*.(a|b|@(ab|a*@(b))*(c)d)', { bash: true, windows: true })); }); it('"fa" should not match "!(f!(o))"', () => { @@ -2120,12 +1978,7 @@ describe('extglobs (bash)', () => { }); it('"fffooofoooooffoofffooofff" should match "*(*(f)*(o))"', () => { - assert( - isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { - bash: true, - windows: true - }) - ); + assert(isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { bash: true, windows: true })); }); it('"ffo" should match "*(f*(o))"', () => { @@ -2161,15 +2014,11 @@ describe('extglobs (bash)', () => { }); it('"fofoofoofofoo" should match "*(fo|foo)"', () => { - assert( - isMatch('fofoofoofofoo', '*(fo|foo)', { bash: true, windows: true }) - ); + assert(isMatch('fofoofoofofoo', '*(fo|foo)', { bash: true, windows: true })); }); it('"fofoofoofofoo" should match "*(fo|foo)"', () => { - assert( - isMatch('fofoofoofofoo', '*(fo|foo)', { bash: true, windows: true }) - ); + assert(isMatch('fofoofoofofoo', '*(fo|foo)', { bash: true, windows: true })); }); it('"foo" should match "!(!(foo))"', () => { @@ -2305,9 +2154,7 @@ describe('extglobs (bash)', () => { }); it('"foo.js.js" should not match "*.!(js)*.!(js)"', () => { - assert( - !isMatch('foo.js.js', '*.!(js)*.!(js)', { bash: true, windows: true }) - ); + assert(!isMatch('foo.js.js', '*.!(js)*.!(js)', { bash: true, windows: true })); }); it('"foo.js.js" should not match "*.!(js)+"', () => { @@ -2343,21 +2190,11 @@ describe('extglobs (bash)', () => { }); it('"foo/bar/baz.jsx" should match "foo/bar/**/*.+(js|jsx)"', () => { - assert( - isMatch('foo/bar/baz.jsx', 'foo/bar/**/*.+(js|jsx)', { - bash: true, - windows: true - }) - ); + assert(isMatch('foo/bar/baz.jsx', 'foo/bar/**/*.+(js|jsx)', { bash: true, windows: true })); }); it('"foo/bar/baz.jsx" should match "foo/bar/*.+(js|jsx)"', () => { - assert( - isMatch('foo/bar/baz.jsx', 'foo/bar/*.+(js|jsx)', { - bash: true, - windows: true - }) - ); + assert(isMatch('foo/bar/baz.jsx', 'foo/bar/*.+(js|jsx)', { bash: true, windows: true })); }); it('"foo/bb/aa/rr" should match "**/**/**"', () => { @@ -2453,21 +2290,11 @@ describe('extglobs (bash)', () => { }); it('"foofoofo" should match "@(foo|f|fo)*(f|of+(o))"', () => { - assert( - isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))', { - bash: true, - windows: true - }) - ); + assert(isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))', { bash: true, windows: true })); }); it('"foofoofo" should match "@(foo|f|fo)*(f|of+(o))"', () => { - assert( - isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))', { - bash: true, - windows: true - }) - ); + assert(isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))', { bash: true, windows: true })); }); it('"fooofoofofooo" should match "*(f*(o))"', () => { @@ -2491,21 +2318,15 @@ describe('extglobs (bash)', () => { }); it('"foooxfooxfoxfooox" should match "*(f*(o)x)"', () => { - assert( - isMatch('foooxfooxfoxfooox', '*(f*(o)x)', { bash: true, windows: true }) - ); + assert(isMatch('foooxfooxfoxfooox', '*(f*(o)x)', { bash: true, windows: true })); }); it('"foooxfooxfxfooox" should match "*(f*(o)x)"', () => { - assert( - isMatch('foooxfooxfxfooox', '*(f*(o)x)', { bash: true, windows: true }) - ); + assert(isMatch('foooxfooxfxfooox', '*(f*(o)x)', { bash: true, windows: true })); }); it('"foooxfooxofoxfooox" should not match "*(f*(o)x)"', () => { - assert( - !isMatch('foooxfooxofoxfooox', '*(f*(o)x)', { bash: true, windows: true }) - ); + assert(!isMatch('foooxfooxofoxfooox', '*(f*(o)x)', { bash: true, windows: true })); }); it('"foot" should match "@(!(z*)|*x)"', () => { @@ -2541,9 +2362,7 @@ describe('extglobs (bash)', () => { }); it('"mad.moo.cow" should not match "!(*.*).!(*.*)"', () => { - assert( - !isMatch('mad.moo.cow', '!(*.*).!(*.*)', { bash: true, windows: true }) - ); + assert(!isMatch('mad.moo.cow', '!(*.*).!(*.*)', { bash: true, windows: true })); }); it('"mad.moo.cow" should not match ".!(*.*)"', () => { @@ -2551,21 +2370,11 @@ describe('extglobs (bash)', () => { }); it('"Makefile" should match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert( - isMatch('Makefile', '!(*.c|*.h|Makefile.in|config*|README)', { - bash: true, - windows: true - }) - ); + assert(isMatch('Makefile', '!(*.c|*.h|Makefile.in|config*|README)', { bash: true, windows: true })); }); it('"Makefile.in" should not match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert( - !isMatch('Makefile.in', '!(*.c|*.h|Makefile.in|config*|README)', { - bash: true, - windows: true - }) - ); + assert(!isMatch('Makefile.in', '!(*.c|*.h|Makefile.in|config*|README)', { bash: true, windows: true })); }); it('"moo" should match "!(*.*)"', () => { @@ -2593,12 +2402,7 @@ describe('extglobs (bash)', () => { }); it('"mucca.pazza" should not match "mu!(*(c))?.pa!(*(z))?"', () => { - assert( - !isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?', { - bash: true, - windows: true - }) - ); + assert(!isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?', { bash: true, windows: true })); }); it('"ofoofo" should match "*(of+(o))"', () => { @@ -2610,57 +2414,31 @@ describe('extglobs (bash)', () => { }); it('"ofooofoofofooo" should not match "*(f*(o))"', () => { - assert( - !isMatch('ofooofoofofooo', '*(f*(o))', { bash: true, windows: true }) - ); + assert(!isMatch('ofooofoofofooo', '*(f*(o))', { bash: true, windows: true })); }); it('"ofoooxoofxo" should match "*(*(of*(o)x)o)"', () => { - assert( - isMatch('ofoooxoofxo', '*(*(of*(o)x)o)', { bash: true, windows: true }) - ); + assert(isMatch('ofoooxoofxo', '*(*(of*(o)x)o)', { bash: true, windows: true })); }); it('"ofoooxoofxoofoooxoofxo" should match "*(*(of*(o)x)o)"', () => { - assert( - isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { - bash: true, - windows: true - }) - ); + assert(isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { bash: true, windows: true })); }); it('"ofoooxoofxoofoooxoofxofo" should not match "*(*(of*(o)x)o)"', () => { - assert( - !isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { - bash: true, - windows: true - }) - ); + assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { bash: true, windows: true })); }); it('"ofoooxoofxoofoooxoofxoo" should match "*(*(of*(o)x)o)"', () => { - assert( - isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { - bash: true, - windows: true - }) - ); + assert(isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { bash: true, windows: true })); }); it('"ofoooxoofxoofoooxoofxooofxofxo" should match "*(*(of*(o)x)o)"', () => { - assert( - isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { - bash: true, - windows: true - }) - ); + assert(isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { bash: true, windows: true })); }); it('"ofxoofxo" should match "*(*(of*(o)x)o)"', () => { - assert( - isMatch('ofxoofxo', '*(*(of*(o)x)o)', { bash: true, windows: true }) - ); + assert(isMatch('ofxoofxo', '*(*(of*(o)x)o)', { bash: true, windows: true })); }); it('"oofooofo" should match "*(of|oof+(o))"', () => { @@ -2696,30 +2474,19 @@ describe('extglobs (bash)', () => { }); it('"para.38" should match "para!(*.[00-09])"', () => { - assert( - isMatch('para.38', 'para!(*.[00-09])', { bash: true, windows: true }) - ); + assert(isMatch('para.38', 'para!(*.[00-09])', { bash: true, windows: true })); }); it('"para.graph" should match "para!(*.[0-9])"', () => { - assert( - isMatch('para.graph', 'para!(*.[0-9])', { bash: true, windows: true }) - ); + assert(isMatch('para.graph', 'para!(*.[0-9])', { bash: true, windows: true })); }); it('"para13829383746592" should match "para*([0-9])"', () => { - assert( - isMatch('para13829383746592', 'para*([0-9])', { - bash: true, - windows: true - }) - ); + assert(isMatch('para13829383746592', 'para*([0-9])', { bash: true, windows: true })); }); it('"para381" should not match "para?([345]|99)1"', () => { - assert( - !isMatch('para381', 'para?([345]|99)1', { bash: true, windows: true }) - ); + assert(!isMatch('para381', 'para?([345]|99)1', { bash: true, windows: true })); }); it('"para39" should match "para!(*.[0-9])"', () => { @@ -2727,105 +2494,63 @@ describe('extglobs (bash)', () => { }); it('"para987346523" should match "para+([0-9])"', () => { - assert( - isMatch('para987346523', 'para+([0-9])', { bash: true, windows: true }) - ); + assert(isMatch('para987346523', 'para+([0-9])', { bash: true, windows: true })); }); it('"para991" should match "para?([345]|99)1"', () => { - assert( - isMatch('para991', 'para?([345]|99)1', { bash: true, windows: true }) - ); + assert(isMatch('para991', 'para?([345]|99)1', { bash: true, windows: true })); }); it('"paragraph" should match "para!(*.[0-9])"', () => { - assert( - isMatch('paragraph', 'para!(*.[0-9])', { bash: true, windows: true }) - ); + assert(isMatch('paragraph', 'para!(*.[0-9])', { bash: true, windows: true })); }); it('"paragraph" should not match "para*([0-9])"', () => { - assert( - !isMatch('paragraph', 'para*([0-9])', { bash: true, windows: true }) - ); + assert(!isMatch('paragraph', 'para*([0-9])', { bash: true, windows: true })); }); it('"paragraph" should match "para@(chute|graph)"', () => { - assert( - isMatch('paragraph', 'para@(chute|graph)', { bash: true, windows: true }) - ); + assert(isMatch('paragraph', 'para@(chute|graph)', { bash: true, windows: true })); }); it('"paramour" should not match "para@(chute|graph)"', () => { - assert( - !isMatch('paramour', 'para@(chute|graph)', { bash: true, windows: true }) - ); + assert(!isMatch('paramour', 'para@(chute|graph)', { bash: true, windows: true })); }); it('"parse.y" should match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert( - isMatch('parse.y', '!(*.c|*.h|Makefile.in|config*|README)', { - bash: true, - windows: true - }) - ); + assert(isMatch('parse.y', '!(*.c|*.h|Makefile.in|config*|README)', { bash: true, windows: true })); }); it('"shell.c" should not match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert( - !isMatch('shell.c', '!(*.c|*.h|Makefile.in|config*|README)', { - bash: true, - windows: true - }) - ); + assert(!isMatch('shell.c', '!(*.c|*.h|Makefile.in|config*|README)', { bash: true, windows: true })); }); it('"VMS.FILE;" should not match "*\\;[1-9]*([0-9])"', () => { - assert( - !isMatch('VMS.FILE;', '*\\;[1-9]*([0-9])', { bash: true, windows: true }) - ); + assert(!isMatch('VMS.FILE;', '*\\;[1-9]*([0-9])', { bash: true, windows: true })); }); it('"VMS.FILE;0" should not match "*\\;[1-9]*([0-9])"', () => { - assert( - !isMatch('VMS.FILE;0', '*\\;[1-9]*([0-9])', { bash: true, windows: true }) - ); + assert(!isMatch('VMS.FILE;0', '*\\;[1-9]*([0-9])', { bash: true, windows: true })); }); it('"VMS.FILE;9" should match "*\\;[1-9]*([0-9])"', () => { - assert( - isMatch('VMS.FILE;9', '*\\;[1-9]*([0-9])', { bash: true, windows: true }) - ); + assert(isMatch('VMS.FILE;9', '*\\;[1-9]*([0-9])', { bash: true, windows: true })); }); it('"VMS.FILE;1" should match "*\\;[1-9]*([0-9])"', () => { - assert( - isMatch('VMS.FILE;1', '*\\;[1-9]*([0-9])', { bash: true, windows: true }) - ); + assert(isMatch('VMS.FILE;1', '*\\;[1-9]*([0-9])', { bash: true, windows: true })); }); it('"VMS.FILE;1" should match "*;[1-9]*([0-9])"', () => { - assert( - isMatch('VMS.FILE;1', '*;[1-9]*([0-9])', { bash: true, windows: true }) - ); + assert(isMatch('VMS.FILE;1', '*;[1-9]*([0-9])', { bash: true, windows: true })); }); it('"VMS.FILE;139" should match "*\\;[1-9]*([0-9])"', () => { - assert( - isMatch('VMS.FILE;139', '*\\;[1-9]*([0-9])', { - bash: true, - windows: true - }) - ); + assert(isMatch('VMS.FILE;139', '*\\;[1-9]*([0-9])', { bash: true, windows: true })); }); it('"VMS.FILE;1N" should not match "*\\;[1-9]*([0-9])"', () => { - assert( - !isMatch('VMS.FILE;1N', '*\\;[1-9]*([0-9])', { - bash: true, - windows: true - }) - ); + assert(!isMatch('VMS.FILE;1N', '*\\;[1-9]*([0-9])', { bash: true, windows: true })); }); it('"xfoooofof" should not match "*(f*(o))"', () => { @@ -2833,23 +2558,11 @@ describe('extglobs (bash)', () => { }); it('"XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1" should match "XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*"', () => { - assert( - isMatch( - 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1', - 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', - { bash: true, windows: false } - ) - ); + assert(isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', { bash: true, windows: false })); }); it('"XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1" should not match "XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*"', () => { - assert( - !isMatch( - 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1', - 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', - { bash: true, windows: true } - ) - ); + assert(!isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', { bash: true, windows: true })); }); it('"z" should match "*(z)"', () => { @@ -2888,3 +2601,4 @@ describe('extglobs (bash)', () => { assert(!isMatch('zz', '(a+|b)*', { bash: true, windows: true })); }); }); + diff --git a/test/extglobs-minimatch.js b/test/extglobs-minimatch.js index ad528ae2..4d480803 100644 --- a/test/extglobs-minimatch.js +++ b/test/extglobs-minimatch.js @@ -25,41 +25,19 @@ describe('extglobs (minimatch)', () => { }); it('"-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1" should not match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { - assert( - !isMatch( - '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1', - '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', - { windows: true } - ) - ); + assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', { windows: true })); }); it('"-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1" should match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { - assert( - isMatch( - '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1', - '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', - { windows: true } - ) - ); + assert(isMatch('-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', { windows: true })); }); it('"-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1" should not match "-*-*-*-*-*-*-12-*-*-*-m-*-*-*"', () => { - assert( - !isMatch( - '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1', - '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', - { windows: true } - ) - ); + assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*', { windows: true })); }); it('"/dev/udp/129.22.8.102/45" should match "/dev\\/@(tcp|udp)\\/*\\/*"', () => { - assert( - isMatch('/dev/udp/129.22.8.102/45', '/dev\\/@(tcp|udp)\\/*\\/*', { - windows: true - }) - ); + assert(isMatch('/dev/udp/129.22.8.102/45', '/dev\\/@(tcp|udp)\\/*\\/*', { windows: true })); }); it('"/x/y/z" should match "/x/y/z"', () => { @@ -955,23 +933,11 @@ describe('extglobs (minimatch)', () => { }); it('"abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt" should match "**/*a*b*g*n*t"', () => { - assert( - isMatch( - 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt', - '**/*a*b*g*n*t', - { windows: true } - ) - ); + assert(isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt', '**/*a*b*g*n*t', { windows: true })); }); it('"abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz" should not match "**/*a*b*g*n*t"', () => { - assert( - !isMatch( - 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz', - '**/*a*b*g*n*t', - { windows: true } - ) - ); + assert(!isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz', '**/*a*b*g*n*t', { windows: true })); }); it('"abcdef" should match "(a+|b)*"', () => { @@ -1903,9 +1869,7 @@ describe('extglobs (minimatch)', () => { }); it('"effgz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { - assert( - isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true }) - ); + assert(isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); }); it('"efgz" should match "@(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { @@ -1921,11 +1885,7 @@ describe('extglobs (minimatch)', () => { }); it('"egzefffgzbcdij" should match "*(b+(c)d|e*(f)g?|?(h)i@(j|k))"', () => { - assert( - isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { - windows: true - }) - ); + assert(isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); }); it('"f" should not match "!(f!(o))"', () => { @@ -2005,9 +1965,7 @@ describe('extglobs (minimatch)', () => { }); it('"fffooofoooooffoofffooofff" should match "*(*(f)*(o))"', () => { - assert( - isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { windows: true }) - ); + assert(isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { windows: true })); }); it('"ffo" should match "*(f*(o))"', () => { @@ -2219,15 +2177,11 @@ describe('extglobs (minimatch)', () => { }); it('"foo/bar/baz.jsx" should match "foo/bar/**/*.+(js|jsx)"', () => { - assert( - isMatch('foo/bar/baz.jsx', 'foo/bar/**/*.+(js|jsx)', { windows: true }) - ); + assert(isMatch('foo/bar/baz.jsx', 'foo/bar/**/*.+(js|jsx)', { windows: true })); }); it('"foo/bar/baz.jsx" should match "foo/bar/*.+(js|jsx)"', () => { - assert( - isMatch('foo/bar/baz.jsx', 'foo/bar/*.+(js|jsx)', { windows: true }) - ); + assert(isMatch('foo/bar/baz.jsx', 'foo/bar/*.+(js|jsx)', { windows: true })); }); it('"foo/bb/aa/rr" should match "**/**/**"', () => { @@ -2395,19 +2349,11 @@ describe('extglobs (minimatch)', () => { }); it('"Makefile" should match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert( - isMatch('Makefile', '!(*.c|*.h|Makefile.in|config*|README)', { - windows: true - }) - ); + assert(isMatch('Makefile', '!(*.c|*.h|Makefile.in|config*|README)', { windows: true })); }); it('"Makefile.in" should not match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert( - !isMatch('Makefile.in', '!(*.c|*.h|Makefile.in|config*|README)', { - windows: true - }) - ); + assert(!isMatch('Makefile.in', '!(*.c|*.h|Makefile.in|config*|README)', { windows: true })); }); it('"moo" should match "!(*.*)"', () => { @@ -2455,29 +2401,19 @@ describe('extglobs (minimatch)', () => { }); it('"ofoooxoofxoofoooxoofxo" should match "*(*(of*(o)x)o)"', () => { - assert( - isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { windows: true }) - ); + assert(isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { windows: true })); }); it('"ofoooxoofxoofoooxoofxofo" should not match "*(*(of*(o)x)o)"', () => { - assert( - !isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { windows: true }) - ); + assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { windows: true })); }); it('"ofoooxoofxoofoooxoofxoo" should match "*(*(of*(o)x)o)"', () => { - assert( - isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { windows: true }) - ); + assert(isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { windows: true })); }); it('"ofoooxoofxoofoooxoofxooofxofxo" should match "*(*(of*(o)x)o)"', () => { - assert( - isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { - windows: true - }) - ); + assert(isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { windows: true })); }); it('"ofxoofxo" should match "*(*(of*(o)x)o)"', () => { @@ -2561,19 +2497,11 @@ describe('extglobs (minimatch)', () => { }); it('"parse.y" should match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert( - isMatch('parse.y', '!(*.c|*.h|Makefile.in|config*|README)', { - windows: true - }) - ); + assert(isMatch('parse.y', '!(*.c|*.h|Makefile.in|config*|README)', { windows: true })); }); it('"shell.c" should not match "!(*.c|*.h|Makefile.in|config*|README)"', () => { - assert( - !isMatch('shell.c', '!(*.c|*.h|Makefile.in|config*|README)', { - windows: true - }) - ); + assert(!isMatch('shell.c', '!(*.c|*.h|Makefile.in|config*|README)', { windows: true })); }); it('"VMS.FILE;" should not match "*\\;[1-9]*([0-9])"', () => { @@ -2605,23 +2533,11 @@ describe('extglobs (minimatch)', () => { }); it('"XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1" should match "XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*"', () => { - assert( - isMatch( - 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1', - 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', - { windows: false } - ) - ); + assert(isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', { windows: false })); }); it('"XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1" should not match "XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*"', () => { - assert( - !isMatch( - 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1', - 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', - { windows: true } - ) - ); + assert(!isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*', { windows: true })); }); it('"z" should match "*(z)"', () => { diff --git a/test/extglobs-temp.js b/test/extglobs-temp.js index cd70d831..b62948f2 100644 --- a/test/extglobs-temp.js +++ b/test/extglobs-temp.js @@ -356,9 +356,7 @@ describe('extglobs', () => { assert(!isMatch('xx', 'foo/!(foo)', { windows: true })); assert(!isMatch('ffffffo', '(foo)bb', { windows: true })); - assert( - !isMatch('fffooofoooooffoofffooofff', '(foo)bb', { windows: true }) - ); + assert(!isMatch('fffooofoooooffoofffooofff', '(foo)bb', { windows: true })); assert(!isMatch('ffo', '(foo)bb', { windows: true })); assert(!isMatch('fofo', '(foo)bb', { windows: true })); assert(!isMatch('fofoofoofofoo', '(foo)bb', { windows: true })); @@ -379,13 +377,9 @@ describe('extglobs', () => { assert(!isMatch('ofooofoofofooo', '(foo)bb', { windows: true })); assert(!isMatch('ofoooxoofxo', '(foo)bb', { windows: true })); assert(!isMatch('ofoooxoofxoofoooxoofxo', '(foo)bb', { windows: true })); - assert( - !isMatch('ofoooxoofxoofoooxoofxofo', '(foo)bb', { windows: true }) - ); + assert(!isMatch('ofoooxoofxoofoooxoofxofo', '(foo)bb', { windows: true })); assert(!isMatch('ofoooxoofxoofoooxoofxoo', '(foo)bb', { windows: true })); - assert( - !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '(foo)bb', { windows: true }) - ); + assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '(foo)bb', { windows: true })); assert(!isMatch('ofxoofxo', '(foo)bb', { windows: true })); assert(!isMatch('oofooofo', '(foo)bb', { windows: true })); assert(!isMatch('ooo', '(foo)bb', { windows: true })); @@ -394,9 +388,7 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '(foo)bb', { windows: true })); assert(isMatch('ffffffo', '*(*(f)*(o))', { windows: true })); - assert( - isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { windows: true }) - ); + assert(isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { windows: true })); assert(isMatch('ffo', '*(*(f)*(o))', { windows: true })); assert(isMatch('fofo', '*(*(f)*(o))', { windows: true })); assert(isMatch('fofoofoofofoo', '*(*(f)*(o))', { windows: true })); @@ -416,20 +408,10 @@ describe('extglobs', () => { assert(isMatch('ofoofo', '*(*(f)*(o))', { windows: true })); assert(isMatch('ofooofoofofooo', '*(*(f)*(o))', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(*(f)*(o))', { windows: true })); - assert( - !isMatch('ofoooxoofxoofoooxoofxo', '*(*(f)*(o))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxofo', '*(*(f)*(o))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxoo', '*(*(f)*(o))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(f)*(o))', { - windows: true - }) - ); + assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(*(f)*(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(*(f)*(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(*(f)*(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(f)*(o))', { windows: true })); assert(!isMatch('ofxoofxo', '*(*(f)*(o))', { windows: true })); assert(isMatch('oofooofo', '*(*(f)*(o))', { windows: true })); assert(isMatch('ooo', '*(*(f)*(o))', { windows: true })); @@ -438,11 +420,7 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(*(f)*(o))', { windows: true })); assert(!isMatch('ffffffo', '*(*(of*(o)x)o)', { windows: true })); - assert( - !isMatch('fffooofoooooffoofffooofff', '*(*(of*(o)x)o)', { - windows: true - }) - ); + assert(!isMatch('fffooofoooooffoofffooofff', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('ffo', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('fofo', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('fofoofoofofoo', '*(*(of*(o)x)o)', { windows: true })); @@ -454,34 +432,18 @@ describe('extglobs', () => { assert(!isMatch('foooofo', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('foooofof', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('foooofofx', '*(*(of*(o)x)o)', { windows: true })); - assert( - !isMatch('foooxfooxfoxfooox', '*(*(of*(o)x)o)', { windows: true }) - ); + assert(!isMatch('foooxfooxfoxfooox', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('foooxfooxfxfooox', '*(*(of*(o)x)o)', { windows: true })); - assert( - !isMatch('foooxfooxofoxfooox', '*(*(of*(o)x)o)', { windows: true }) - ); + assert(!isMatch('foooxfooxofoxfooox', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('foot', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('foox', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('ofoofo', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('ofooofoofofooo', '*(*(of*(o)x)o)', { windows: true })); assert(isMatch('ofoooxoofxo', '*(*(of*(o)x)o)', { windows: true })); - assert( - isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { - windows: true - }) - ); - assert( - isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { windows: true }) - ); - assert( - isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { - windows: true - }) - ); + assert(isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { windows: true })); + assert(isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { windows: true })); + assert(isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { windows: true })); assert(isMatch('ofxoofxo', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('oofooofo', '*(*(of*(o)x)o)', { windows: true })); assert(isMatch('ooo', '*(*(of*(o)x)o)', { windows: true })); @@ -490,9 +452,7 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(*(of*(o)x)o)', { windows: true })); assert(isMatch('ffffffo', '*(f*(o))', { windows: true })); - assert( - isMatch('fffooofoooooffoofffooofff', '*(f*(o))', { windows: true }) - ); + assert(isMatch('fffooofoooooffoofffooofff', '*(f*(o))', { windows: true })); assert(isMatch('ffo', '*(f*(o))', { windows: true })); assert(isMatch('fofo', '*(f*(o))', { windows: true })); assert(isMatch('fofoofoofofoo', '*(f*(o))', { windows: true })); @@ -513,17 +473,9 @@ describe('extglobs', () => { assert(!isMatch('ofooofoofofooo', '*(f*(o))', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(f*(o))', { windows: true })); assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(f*(o))', { windows: true })); - assert( - !isMatch('ofoooxoofxoofoooxoofxofo', '*(f*(o))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxoo', '*(f*(o))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(f*(o))', { - windows: true - }) - ); + assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(f*(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(f*(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(f*(o))', { windows: true })); assert(!isMatch('ofxoofxo', '*(f*(o))', { windows: true })); assert(!isMatch('oofooofo', '*(f*(o))', { windows: true })); assert(!isMatch('ooo', '*(f*(o))', { windows: true })); @@ -532,9 +484,7 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(f*(o))', { windows: true })); assert(!isMatch('ffffffo', '*(f*(o)x)', { windows: true })); - assert( - !isMatch('fffooofoooooffoofffooofff', '*(f*(o)x)', { windows: true }) - ); + assert(!isMatch('fffooofoooooffoofffooofff', '*(f*(o)x)', { windows: true })); assert(!isMatch('ffo', '*(f*(o)x)', { windows: true })); assert(!isMatch('fofo', '*(f*(o)x)', { windows: true })); assert(!isMatch('fofoofoofofoo', '*(f*(o)x)', { windows: true })); @@ -554,20 +504,10 @@ describe('extglobs', () => { assert(!isMatch('ofoofo', '*(f*(o)x)', { windows: true })); assert(!isMatch('ofooofoofofooo', '*(f*(o)x)', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(f*(o)x)', { windows: true })); - assert( - !isMatch('ofoooxoofxoofoooxoofxo', '*(f*(o)x)', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxofo', '*(f*(o)x)', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxoo', '*(f*(o)x)', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(f*(o)x)', { - windows: true - }) - ); + assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(f*(o)x)', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(f*(o)x)', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(f*(o)x)', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(f*(o)x)', { windows: true })); assert(!isMatch('ofxoofxo', '*(f*(o)x)', { windows: true })); assert(!isMatch('oofooofo', '*(f*(o)x)', { windows: true })); assert(!isMatch('ooo', '*(f*(o)x)', { windows: true })); @@ -576,9 +516,7 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(f*(o)x)', { windows: true })); assert(!isMatch('ffffffo', '*(f+(o))', { windows: true })); - assert( - !isMatch('fffooofoooooffoofffooofff', '*(f+(o))', { windows: true }) - ); + assert(!isMatch('fffooofoooooffoofffooofff', '*(f+(o))', { windows: true })); assert(!isMatch('ffo', '*(f+(o))', { windows: true })); assert(isMatch('fofo', '*(f+(o))', { windows: true })); assert(isMatch('fofoofoofofoo', '*(f+(o))', { windows: true })); @@ -599,17 +537,9 @@ describe('extglobs', () => { assert(!isMatch('ofooofoofofooo', '*(f+(o))', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(f+(o))', { windows: true })); assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(f+(o))', { windows: true })); - assert( - !isMatch('ofoooxoofxoofoooxoofxofo', '*(f+(o))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxoo', '*(f+(o))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(f+(o))', { - windows: true - }) - ); + assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(f+(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(f+(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(f+(o))', { windows: true })); assert(!isMatch('ofxoofxo', '*(f+(o))', { windows: true })); assert(!isMatch('oofooofo', '*(f+(o))', { windows: true })); assert(!isMatch('ooo', '*(f+(o))', { windows: true })); @@ -618,9 +548,7 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(f+(o))', { windows: true })); assert(!isMatch('ffffffo', '*(of+(o))', { windows: true })); - assert( - !isMatch('fffooofoooooffoofffooofff', '*(of+(o))', { windows: true }) - ); + assert(!isMatch('fffooofoooooffoofffooofff', '*(of+(o))', { windows: true })); assert(!isMatch('ffo', '*(of+(o))', { windows: true })); assert(!isMatch('fofo', '*(of+(o))', { windows: true })); assert(!isMatch('fofoofoofofoo', '*(of+(o))', { windows: true })); @@ -640,20 +568,10 @@ describe('extglobs', () => { assert(isMatch('ofoofo', '*(of+(o))', { windows: true })); assert(!isMatch('ofooofoofofooo', '*(of+(o))', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(of+(o))', { windows: true })); - assert( - !isMatch('ofoooxoofxoofoooxoofxo', '*(of+(o))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxofo', '*(of+(o))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxoo', '*(of+(o))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(of+(o))', { - windows: true - }) - ); + assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(of+(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(of+(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(of+(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(of+(o))', { windows: true })); assert(!isMatch('ofxoofxo', '*(of+(o))', { windows: true })); assert(!isMatch('oofooofo', '*(of+(o))', { windows: true })); assert(!isMatch('ooo', '*(of+(o))', { windows: true })); @@ -662,9 +580,7 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(of+(o))', { windows: true })); assert(!isMatch('ffffffo', '*(of+(o)|f)', { windows: true })); - assert( - !isMatch('fffooofoooooffoofffooofff', '*(of+(o)|f)', { windows: true }) - ); + assert(!isMatch('fffooofoooooffoofffooofff', '*(of+(o)|f)', { windows: true })); assert(!isMatch('ffo', '*(of+(o)|f)', { windows: true })); assert(isMatch('fofo', '*(of+(o)|f)', { windows: true })); assert(isMatch('fofoofoofofoo', '*(of+(o)|f)', { windows: true })); @@ -684,20 +600,10 @@ describe('extglobs', () => { assert(isMatch('ofoofo', '*(of+(o)|f)', { windows: true })); assert(isMatch('ofooofoofofooo', '*(of+(o)|f)', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(of+(o)|f)', { windows: true })); - assert( - !isMatch('ofoooxoofxoofoooxoofxo', '*(of+(o)|f)', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxofo', '*(of+(o)|f)', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxoo', '*(of+(o)|f)', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(of+(o)|f)', { - windows: true - }) - ); + assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(of+(o)|f)', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(of+(o)|f)', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(of+(o)|f)', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(of+(o)|f)', { windows: true })); assert(!isMatch('ofxoofxo', '*(of+(o)|f)', { windows: true })); assert(!isMatch('oofooofo', '*(of+(o)|f)', { windows: true })); assert(!isMatch('ooo', '*(of+(o)|f)', { windows: true })); @@ -706,11 +612,7 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(of+(o)|f)', { windows: true })); assert(!isMatch('ffffffo', '*(of|oof+(o))', { windows: true })); - assert( - !isMatch('fffooofoooooffoofffooofff', '*(of|oof+(o))', { - windows: true - }) - ); + assert(!isMatch('fffooofoooooffoofffooofff', '*(of|oof+(o))', { windows: true })); assert(!isMatch('ffo', '*(of|oof+(o))', { windows: true })); assert(!isMatch('fofo', '*(of|oof+(o))', { windows: true })); assert(!isMatch('fofoofoofofoo', '*(of|oof+(o))', { windows: true })); @@ -724,28 +626,16 @@ describe('extglobs', () => { assert(!isMatch('foooofofx', '*(of|oof+(o))', { windows: true })); assert(!isMatch('foooxfooxfoxfooox', '*(of|oof+(o))', { windows: true })); assert(!isMatch('foooxfooxfxfooox', '*(of|oof+(o))', { windows: true })); - assert( - !isMatch('foooxfooxofoxfooox', '*(of|oof+(o))', { windows: true }) - ); + assert(!isMatch('foooxfooxofoxfooox', '*(of|oof+(o))', { windows: true })); assert(!isMatch('foot', '*(of|oof+(o))', { windows: true })); assert(!isMatch('foox', '*(of|oof+(o))', { windows: true })); assert(isMatch('ofoofo', '*(of|oof+(o))', { windows: true })); assert(!isMatch('ofooofoofofooo', '*(of|oof+(o))', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(of|oof+(o))', { windows: true })); - assert( - !isMatch('ofoooxoofxoofoooxoofxo', '*(of|oof+(o))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxofo', '*(of|oof+(o))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxoo', '*(of|oof+(o))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(of|oof+(o))', { - windows: true - }) - ); + assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(of|oof+(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(of|oof+(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(of|oof+(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(of|oof+(o))', { windows: true })); assert(!isMatch('ofxoofxo', '*(of|oof+(o))', { windows: true })); assert(isMatch('oofooofo', '*(of|oof+(o))', { windows: true })); assert(!isMatch('ooo', '*(of|oof+(o))', { windows: true })); @@ -754,9 +644,7 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(of|oof+(o))', { windows: true })); assert(!isMatch('ffffffo', '*(oxf+(ox))', { windows: true })); - assert( - !isMatch('fffooofoooooffoofffooofff', '*(oxf+(ox))', { windows: true }) - ); + assert(!isMatch('fffooofoooooffoofffooofff', '*(oxf+(ox))', { windows: true })); assert(!isMatch('ffo', '*(oxf+(ox))', { windows: true })); assert(!isMatch('fofo', '*(oxf+(ox))', { windows: true })); assert(!isMatch('fofoofoofofoo', '*(oxf+(ox))', { windows: true })); @@ -776,20 +664,10 @@ describe('extglobs', () => { assert(!isMatch('ofoofo', '*(oxf+(ox))', { windows: true })); assert(!isMatch('ofooofoofofooo', '*(oxf+(ox))', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(oxf+(ox))', { windows: true })); - assert( - !isMatch('ofoooxoofxoofoooxoofxo', '*(oxf+(ox))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxofo', '*(oxf+(ox))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxoo', '*(oxf+(ox))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(oxf+(ox))', { - windows: true - }) - ); + assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(oxf+(ox))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(oxf+(ox))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(oxf+(ox))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(oxf+(ox))', { windows: true })); assert(!isMatch('ofxoofxo', '*(oxf+(ox))', { windows: true })); assert(!isMatch('oofooofo', '*(oxf+(ox))', { windows: true })); assert(!isMatch('ooo', '*(oxf+(ox))', { windows: true })); @@ -798,9 +676,7 @@ describe('extglobs', () => { assert(!isMatch('xfoooofof', '*(oxf+(ox))', { windows: true })); assert(isMatch('ffffffo', '@(!(z*)|*x)', { windows: true })); - assert( - isMatch('fffooofoooooffoofffooofff', '@(!(z*)|*x)', { windows: true }) - ); + assert(isMatch('fffooofoooooffoofffooofff', '@(!(z*)|*x)', { windows: true })); assert(isMatch('ffo', '@(!(z*)|*x)', { windows: true })); assert(isMatch('fofo', '@(!(z*)|*x)', { windows: true })); assert(isMatch('fofoofoofofoo', '@(!(z*)|*x)', { windows: true })); @@ -820,20 +696,10 @@ describe('extglobs', () => { assert(isMatch('ofoofo', '@(!(z*)|*x)', { windows: true })); assert(isMatch('ofooofoofofooo', '@(!(z*)|*x)', { windows: true })); assert(isMatch('ofoooxoofxo', '@(!(z*)|*x)', { windows: true })); - assert( - isMatch('ofoooxoofxoofoooxoofxo', '@(!(z*)|*x)', { windows: true }) - ); - assert( - isMatch('ofoooxoofxoofoooxoofxofo', '@(!(z*)|*x)', { windows: true }) - ); - assert( - isMatch('ofoooxoofxoofoooxoofxoo', '@(!(z*)|*x)', { windows: true }) - ); - assert( - isMatch('ofoooxoofxoofoooxoofxooofxofxo', '@(!(z*)|*x)', { - windows: true - }) - ); + assert(isMatch('ofoooxoofxoofoooxoofxo', '@(!(z*)|*x)', { windows: true })); + assert(isMatch('ofoooxoofxoofoooxoofxofo', '@(!(z*)|*x)', { windows: true })); + assert(isMatch('ofoooxoofxoofoooxoofxoo', '@(!(z*)|*x)', { windows: true })); + assert(isMatch('ofoooxoofxoofoooxoofxooofxofxo', '@(!(z*)|*x)', { windows: true })); assert(isMatch('ofxoofxo', '@(!(z*)|*x)', { windows: true })); assert(isMatch('oofooofo', '@(!(z*)|*x)', { windows: true })); assert(isMatch('ooo', '@(!(z*)|*x)', { windows: true })); @@ -842,82 +708,36 @@ describe('extglobs', () => { assert(isMatch('xfoooofof', '@(!(z*)|*x)', { windows: true })); assert(!isMatch('ffffffo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert( - !isMatch('fffooofoooooffoofffooofff', '@(foo|f|fo)*(f|of+(o))', { - windows: true - }) - ); + assert(!isMatch('fffooofoooooffoofffooofff', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('ffo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(isMatch('fofo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert( - isMatch('fofoofoofofoo', '@(foo|f|fo)*(f|of+(o))', { windows: true }) - ); + assert(isMatch('fofoofoofofoo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(isMatch('foo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('foob', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('foobb', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert( - isMatch('fooofoofofooo', '@(foo|f|fo)*(f|of+(o))', { windows: true }) - ); + assert(isMatch('fooofoofofooo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('foooofo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('foooofof', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert( - !isMatch('foooofofx', '@(foo|f|fo)*(f|of+(o))', { windows: true }) - ); - assert( - !isMatch('foooxfooxfoxfooox', '@(foo|f|fo)*(f|of+(o))', { - windows: true - }) - ); - assert( - !isMatch('foooxfooxfxfooox', '@(foo|f|fo)*(f|of+(o))', { - windows: true - }) - ); - assert( - !isMatch('foooxfooxofoxfooox', '@(foo|f|fo)*(f|of+(o))', { - windows: true - }) - ); + assert(!isMatch('foooofofx', '@(foo|f|fo)*(f|of+(o))', { windows: true })); + assert(!isMatch('foooxfooxfoxfooox', '@(foo|f|fo)*(f|of+(o))', { windows: true })); + assert(!isMatch('foooxfooxfxfooox', '@(foo|f|fo)*(f|of+(o))', { windows: true })); + assert(!isMatch('foooxfooxofoxfooox', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('foot', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('foox', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('ofoofo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert( - !isMatch('ofooofoofofooo', '@(foo|f|fo)*(f|of+(o))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxo', '@(foo|f|fo)*(f|of+(o))', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxo', '@(foo|f|fo)*(f|of+(o))', { - windows: true - }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxofo', '@(foo|f|fo)*(f|of+(o))', { - windows: true - }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxoo', '@(foo|f|fo)*(f|of+(o))', { - windows: true - }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '@(foo|f|fo)*(f|of+(o))', { - windows: true - }) - ); + assert(!isMatch('ofooofoofofooo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); + assert(!isMatch('ofoooxoofxo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxofo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxoo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('ofxoofxo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('oofooofo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('ooo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(!isMatch('oxfoxfox', '@(foo|f|fo)*(f|of+(o))', { windows: true })); - assert( - !isMatch('oxfoxoxfox', '@(foo|f|fo)*(f|of+(o))', { windows: true }) - ); - assert( - !isMatch('xfoooofof', '@(foo|f|fo)*(f|of+(o))', { windows: true }) - ); + assert(!isMatch('oxfoxoxfox', '@(foo|f|fo)*(f|of+(o))', { windows: true })); + assert(!isMatch('xfoooofof', '@(foo|f|fo)*(f|of+(o))', { windows: true })); assert(isMatch('aaac', '*(@(a))a@(c)', { windows: true })); assert(isMatch('aac', '*(@(a))a@(c)', { windows: true })); @@ -961,15 +781,14 @@ describe('extglobs', () => { assert(!isMatch('aac', '*(@(a))b@(c)', { windows: true })); }); + }); describe('other', () => { it('should support backtracking in alternation matches', () => { assert(isMatch('fofoofoofofoo', '*(fo|foo)', { windows: true })); assert(!isMatch('ffffffo', '*(fo|foo)', { windows: true })); - assert( - !isMatch('fffooofoooooffoofffooofff', '*(fo|foo)', { windows: true }) - ); + assert(!isMatch('fffooofoooooffoofffooofff', '*(fo|foo)', { windows: true })); assert(!isMatch('ffo', '*(fo|foo)', { windows: true })); assert(isMatch('fofo', '*(fo|foo)', { windows: true })); assert(isMatch('fofoofoofofoo', '*(fo|foo)', { windows: true })); @@ -989,20 +808,10 @@ describe('extglobs', () => { assert(!isMatch('ofoofo', '*(fo|foo)', { windows: true })); assert(!isMatch('ofooofoofofooo', '*(fo|foo)', { windows: true })); assert(!isMatch('ofoooxoofxo', '*(fo|foo)', { windows: true })); - assert( - !isMatch('ofoooxoofxoofoooxoofxo', '*(fo|foo)', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxofo', '*(fo|foo)', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxoo', '*(fo|foo)', { windows: true }) - ); - assert( - !isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(fo|foo)', { - windows: true - }) - ); + assert(!isMatch('ofoooxoofxoofoooxoofxo', '*(fo|foo)', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(fo|foo)', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxoo', '*(fo|foo)', { windows: true })); + assert(!isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(fo|foo)', { windows: true })); assert(!isMatch('ofxoofxo', '*(fo|foo)', { windows: true })); assert(!isMatch('oofooofo', '*(fo|foo)', { windows: true })); assert(!isMatch('ooo', '*(fo|foo)', { windows: true })); @@ -1047,35 +856,17 @@ describe('extglobs', () => { assert(!isMatch('moo', '.!(*.*)', { windows: true })); assert(!isMatch('cow', '.!(*.*)', { windows: true })); - assert( - !isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?', { windows: true }) - ); - - assert( - isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true }) - ); - assert( - isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true }) - ); - assert( - isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true }) - ); - assert( - !isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))', { windows: true }) - ); - assert( - isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { - windows: true - }) - ); + assert(!isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?', { windows: true })); + + assert(isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); + assert(isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); + assert(isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); + assert(!isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))', { windows: true })); + assert(isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); }); it('valid numbers', () => { - assert( - isMatch('/dev/udp/129.22.8.102/45', '/dev/@(tcp|udp)/*/*', { - windows: true - }) - ); + assert(isMatch('/dev/udp/129.22.8.102/45', '/dev/@(tcp|udp)/*/*', { windows: true })); assert(!isMatch('0', '[1-6]([0-9])', { windows: true })); assert(isMatch('12', '[1-6]([0-9])', { windows: true })); @@ -1135,11 +926,7 @@ describe('extglobs', () => { }); it('More tests derived from a bug report (in bash) concerning extended glob patterns following a *', () => { - assert( - isMatch('/dev/udp/129.22.8.102/45', '/dev\\/@(tcp|udp)\\/*\\/*', { - windows: true - }) - ); + assert(isMatch('/dev/udp/129.22.8.102/45', '/dev\\/@(tcp|udp)\\/*\\/*', { windows: true })); assert(!isMatch('123abc', '(a+|b)*', { windows: true })); assert(isMatch('ab', '(a+|b)*', { windows: true })); assert(isMatch('abab', '(a+|b)*', { windows: true })); @@ -1347,12 +1134,8 @@ describe('extglobs', () => { assert(isMatch('a.c', '+([[:alpha:].])+([[:alpha:].])', opts)); assert(isMatch('a.c', '*([[:alpha:].])', opts)); assert(isMatch('a.c', '*([[:alpha:].])*([[:alpha:].])', opts)); - assert( - isMatch('a.c', '?([[:alpha:].])?([[:alpha:].])?([[:alpha:].])', opts) - ); - assert( - isMatch('a.c', '@([[:alpha:].])@([[:alpha:].])@([[:alpha:].])', opts) - ); + assert(isMatch('a.c', '?([[:alpha:].])?([[:alpha:].])?([[:alpha:].])', opts)); + assert(isMatch('a.c', '@([[:alpha:].])@([[:alpha:].])@([[:alpha:].])', opts)); assert(!isMatch('.', '!(\\.)', opts)); assert(!isMatch('.', '!([[:alpha:].])', opts)); assert(isMatch('.', '?([[:alpha:].])', opts)); @@ -1363,18 +1146,12 @@ describe('extglobs', () => { it('should pass extglob2 tests', () => { assert(!isMatch('baaac', '*(@(a))a@(c)', { windows: true })); assert(!isMatch('c', '*(@(a))a@(c)', { windows: true })); - assert( - !isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))', { windows: true }) - ); + assert(!isMatch('egz', '@(b+(c)d|e+(f)g?|?(h)i@(j|k))', { windows: true })); assert(!isMatch('foooofof', '*(f+(o))', { windows: true })); assert(!isMatch('foooofofx', '*(f*(o))', { windows: true })); assert(!isMatch('foooxfooxofoxfooox', '*(f*(o)x)', { windows: true })); assert(!isMatch('ofooofoofofooo', '*(f*(o))', { windows: true })); - assert( - !isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { - windows: true - }) - ); + assert(!isMatch('ofoooxoofxoofoooxoofxofo', '*(*(of*(o)x)o)', { windows: true })); assert(!isMatch('oxfoxfox', '*(oxf+(ox))', { windows: true })); assert(!isMatch('xfoooofof', '*(f*(o))', { windows: true })); assert(isMatch('aaac', '*(@(a))a@(c)', { windows: true })); @@ -1384,23 +1161,11 @@ describe('extglobs', () => { assert(isMatch('abcd', '@(ab|a*@(b))*(c)d', { windows: true })); assert(isMatch('ac', '*(@(a))a@(c)', { windows: true })); assert(isMatch('acd', '@(ab|a*(b))*(c)d', { windows: true })); - assert( - isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true }) - ); - assert( - isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true }) - ); - assert( - isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true }) - ); - assert( - isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { - windows: true - }) - ); - assert( - isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { windows: true }) - ); + assert(isMatch('effgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); + assert(isMatch('efgz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); + assert(isMatch('egz', '@(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); + assert(isMatch('egzefffgzbcdij', '*(b+(c)d|e*(f)g?|?(h)i@(j|k))', { windows: true })); + assert(isMatch('fffooofoooooffoofffooofff', '*(*(f)*(o))', { windows: true })); assert(isMatch('ffo', '*(f*(o))', { windows: true })); assert(isMatch('fofo', '*(f*(o))', { windows: true })); assert(isMatch('foofoofo', '@(foo|f|fo)*(f|of+(o))', { windows: true })); @@ -1412,17 +1177,9 @@ describe('extglobs', () => { assert(isMatch('ofoofo', '*(of+(o))', { windows: true })); assert(isMatch('ofoofo', '*(of+(o)|f)', { windows: true })); assert(isMatch('ofoooxoofxo', '*(*(of*(o)x)o)', { windows: true })); - assert( - isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { windows: true }) - ); - assert( - isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { windows: true }) - ); - assert( - isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { - windows: true - }) - ); + assert(isMatch('ofoooxoofxoofoooxoofxo', '*(*(of*(o)x)o)', { windows: true })); + assert(isMatch('ofoooxoofxoofoooxoofxoo', '*(*(of*(o)x)o)', { windows: true })); + assert(isMatch('ofoooxoofxoofoooxoofxooofxofxo', '*(*(of*(o)x)o)', { windows: true })); assert(isMatch('ofxoofxo', '*(*(of*(o)x)o)', { windows: true })); assert(isMatch('oofooofo', '*(of|oof+(o))', { windows: true })); assert(isMatch('oxfoxoxfox', '*(oxf+(ox))', { windows: true })); @@ -1435,9 +1192,7 @@ describe('extglobs', () => { assert(!isMatch('foo', '!(foo)', { windows: true })); assert(!isMatch('foob', '!(foo)b*', { windows: true })); assert(!isMatch('mad.moo.cow', '!(*.*).!(*.*)', { windows: true })); - assert( - !isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?', { windows: true }) - ); + assert(!isMatch('mucca.pazza', 'mu!(*(c))?.pa!(*(z))?', { windows: true })); assert(!isMatch('zoot', '@(!(z*)|*x)', { windows: true })); assert(isMatch('fff', '!(f)', { windows: true })); assert(isMatch('fff', '*(!(f))', { windows: true })); @@ -1457,3 +1212,4 @@ describe('extglobs', () => { }); }); }); + diff --git a/test/extglobs.js b/test/extglobs.js index 2dc40a02..ea436d1f 100644 --- a/test/extglobs.js +++ b/test/extglobs.js @@ -137,31 +137,31 @@ describe('extglobs', () => { }); it('should support negation extglobs following !', () => { - assert(isMatch('abc', '!!(abc)')); + assert(isMatch('abc', '!!(abc)')); assert(!isMatch('abc', '!!!(abc)')); - assert(isMatch('abc', '!!!!(abc)')); + assert(isMatch('abc', '!!!!(abc)')); assert(!isMatch('abc', '!!!!!(abc)')); - assert(isMatch('abc', '!!!!!!(abc)')); + assert(isMatch('abc', '!!!!!!(abc)')); assert(!isMatch('abc', '!!!!!!!(abc)')); - assert(isMatch('abc', '!!!!!!!!(abc)')); + assert(isMatch('abc', '!!!!!!!!(abc)')); }); it('should support nested negation extglobs', () => { - assert(isMatch('abc', '!(!(abc))')); + assert(isMatch('abc', '!(!(abc))')); assert(!isMatch('abc', '!(!(!(abc)))')); - assert(isMatch('abc', '!(!(!(!(abc))))')); + assert(isMatch('abc', '!(!(!(!(abc))))')); assert(!isMatch('abc', '!(!(!(!(!(abc)))))')); - assert(isMatch('abc', '!(!(!(!(!(!(abc))))))')); + assert(isMatch('abc', '!(!(!(!(!(!(abc))))))')); assert(!isMatch('abc', '!(!(!(!(!(!(!(abc)))))))')); - assert(isMatch('abc', '!(!(!(!(!(!(!(!(abc))))))))')); + assert(isMatch('abc', '!(!(!(!(!(!(!(!(abc))))))))')); - assert(isMatch('foo/abc', 'foo/!(!(abc))')); + assert(isMatch('foo/abc', 'foo/!(!(abc))')); assert(!isMatch('foo/abc', 'foo/!(!(!(abc)))')); - assert(isMatch('foo/abc', 'foo/!(!(!(!(abc))))')); + assert(isMatch('foo/abc', 'foo/!(!(!(!(abc))))')); assert(!isMatch('foo/abc', 'foo/!(!(!(!(!(abc)))))')); - assert(isMatch('foo/abc', 'foo/!(!(!(!(!(!(abc))))))')); + assert(isMatch('foo/abc', 'foo/!(!(!(!(!(!(abc))))))')); assert(!isMatch('foo/abc', 'foo/!(!(!(!(!(!(!(abc)))))))')); - assert(isMatch('foo/abc', 'foo/!(!(!(!(!(!(!(!(abc))))))))')); + assert(isMatch('foo/abc', 'foo/!(!(!(!(!(!(!(!(abc))))))))')); }); it('should support multiple !(...) extglobs in a pattern', () => { @@ -473,7 +473,7 @@ describe('extglobs', () => { assert(isMatch('b.a', '@(b|a).@(a)')); }); - it("should pass tests from rosenblatt's korn shell book", () => { + it('should pass tests from rosenblatt\'s korn shell book', () => { // This one is the only difference, since picomatch does not match empty strings. assert(!isMatch('', '*(0|1|3|5|7|9)')); @@ -550,7 +550,7 @@ describe('extglobs', () => { assert(!isMatch('acd', 'a[b*(foo|bar)]d')); }); - it("stuff from korn's book", () => { + it('stuff from korn\'s book', () => { assert(!isMatch('para', 'para+([0-9])')); assert(!isMatch('para381', 'para?([345]|99)1')); assert(!isMatch('paragraph', 'para*([0-9])')); @@ -748,23 +748,7 @@ describe('extglobs', () => { // these are not extglobs, and do not need to pass, but they are included // to test integration with other features it('should support regex characters', () => { - const fixtures = [ - 'a c', - 'a.c', - 'a.xy.zc', - 'a.zc', - 'a123c', - 'a1c', - 'abbbbc', - 'abbbc', - 'abbc', - 'abc', - 'abq', - 'axy zc', - 'axy', - 'axy.zc', - 'axyzc' - ]; + const fixtures = ['a c', 'a.c', 'a.xy.zc', 'a.zc', 'a123c', 'a1c', 'abbbbc', 'abbbc', 'abbc', 'abc', 'abq', 'axy zc', 'axy', 'axy.zc', 'axyzc']; if (process.platform !== 'win32') { assert.deepStrictEqual(match(['a\\b', 'a/b', 'ab'], 'a/b'), ['a/b']); @@ -772,63 +756,18 @@ describe('extglobs', () => { assert.deepStrictEqual(match(['a/b', 'ab'], 'a/b'), ['a/b']); assert.deepStrictEqual(match(fixtures, 'ab?bc'), ['abbbc']); - assert.deepStrictEqual(match(fixtures, 'ab*c'), [ - 'abbbbc', - 'abbbc', - 'abbc', - 'abc' - ]); - assert.deepStrictEqual(match(fixtures, 'a+(b)bc'), [ - 'abbbbc', - 'abbbc', - 'abbc' - ]); + assert.deepStrictEqual(match(fixtures, 'ab*c'), ['abbbbc', 'abbbc', 'abbc', 'abc']); + assert.deepStrictEqual(match(fixtures, 'a+(b)bc'), ['abbbbc', 'abbbc', 'abbc']); assert.deepStrictEqual(match(fixtures, '^abc$'), []); assert.deepStrictEqual(match(fixtures, 'a.c'), ['a.c']); assert.deepStrictEqual(match(fixtures, 'a.*c'), ['a.c', 'a.xy.zc', 'a.zc']); - assert.deepStrictEqual(match(fixtures, 'a*c'), [ - 'a c', - 'a.c', - 'a.xy.zc', - 'a.zc', - 'a123c', - 'a1c', - 'abbbbc', - 'abbbc', - 'abbc', - 'abc', - 'axy zc', - 'axy.zc', - 'axyzc' - ]); - assert.deepStrictEqual( - match(fixtures, 'a[\\w]+c'), - ['a123c', 'a1c', 'abbbbc', 'abbbc', 'abbc', 'abc', 'axyzc'], - 'Should match word characters' - ); - assert.deepStrictEqual( - match(fixtures, 'a[\\W]+c'), - ['a c', 'a.c'], - 'Should match non-word characters' - ); - assert.deepStrictEqual( - match(fixtures, 'a[\\d]+c'), - ['a123c', 'a1c'], - 'Should match numbers' - ); - assert.deepStrictEqual( - match(['foo@#$%123ASD #$$%^&', 'foo!@#$asdfl;', '123'], '[\\d]+'), - ['123'] - ); - assert.deepStrictEqual( - match(['a123c', 'abbbc'], 'a[\\D]+c'), - ['abbbc'], - 'Should match non-numbers' - ); - assert.deepStrictEqual( - match(['foo', ' foo '], '(f|o)+\\b'), - ['foo'], - 'Should match word boundaries' - ); + assert.deepStrictEqual(match(fixtures, 'a*c'), ['a c', 'a.c', 'a.xy.zc', 'a.zc', 'a123c', 'a1c', 'abbbbc', 'abbbc', 'abbc', 'abc', 'axy zc', 'axy.zc', 'axyzc']); + assert.deepStrictEqual(match(fixtures, 'a[\\w]+c'), ['a123c', 'a1c', 'abbbbc', 'abbbc', 'abbc', 'abc', 'axyzc'], 'Should match word characters'); + assert.deepStrictEqual(match(fixtures, 'a[\\W]+c'), ['a c', 'a.c'], 'Should match non-word characters'); + assert.deepStrictEqual(match(fixtures, 'a[\\d]+c'), ['a123c', 'a1c'], 'Should match numbers'); + assert.deepStrictEqual(match(['foo@#$%123ASD #$$%^&', 'foo!@#$asdfl;', '123'], '[\\d]+'), ['123']); + assert.deepStrictEqual(match(['a123c', 'abbbc'], 'a[\\D]+c'), ['abbbc'], 'Should match non-numbers'); + assert.deepStrictEqual(match(['foo', ' foo '], '(f|o)+\\b'), ['foo'], 'Should match word boundaries'); }); }); + diff --git a/test/globstars.js b/test/globstars.js index 0a640d2b..9d101344 100644 --- a/test/globstars.js +++ b/test/globstars.js @@ -14,33 +14,7 @@ describe('stars', () => { }); it('should regard non-exclusive double-stars as single stars', () => { - const fixtures = [ - 'a', - 'a/', - 'a/a', - 'a/a/', - 'a/a/a', - 'a/a/a/', - 'a/a/a/a', - 'a/a/a/a/', - 'a/a/a/a/a', - 'a/a/a/a/a/', - 'a/a/b', - 'a/a/b/', - 'a/b', - 'a/b/', - 'a/b/c/.d/e/', - 'a/c', - 'a/c/', - 'a/b', - 'a/x/', - 'b', - 'b/', - 'x/y', - 'x/y/', - 'z/z', - 'z/z/' - ]; + const fixtures = ['a', 'a/', 'a/a', 'a/a/', 'a/a/a', 'a/a/a/', 'a/a/a/a', 'a/a/a/a/', 'a/a/a/a/a', 'a/a/a/a/a/', 'a/a/b', 'a/a/b/', 'a/b', 'a/b/', 'a/b/c/.d/e/', 'a/c', 'a/c/', 'a/b', 'a/x/', 'b', 'b/', 'x/y', 'x/y/', 'z/z', 'z/z/']; assert.deepStrictEqual(match(fixtures, '**a/a/*/'), ['a/a/a/', 'a/a/b/']); assert(!isMatch('aaa/bba/ccc', 'aaa/**ccc')); @@ -78,97 +52,31 @@ describe('stars', () => { }); it('should match file extensions:', () => { - assert.deepStrictEqual( - match(['.md', 'a.md', 'a/b/c.md', '.txt'], '**/*.md'), - ['a.md', 'a/b/c.md'] - ); - assert.deepStrictEqual( - match(['.md/.md', '.md', 'a/.md', 'a/b/.md'], '**/.md'), - ['.md', 'a/.md', 'a/b/.md'] - ); - assert.deepStrictEqual( - match( - ['.md/.md', '.md/foo/.md', '.md', 'a/.md', 'a/b/.md'], - '.md/**/.md' - ), - ['.md/.md', '.md/foo/.md'] - ); + assert.deepStrictEqual(match(['.md', 'a.md', 'a/b/c.md', '.txt'], '**/*.md'), ['a.md', 'a/b/c.md']); + assert.deepStrictEqual(match(['.md/.md', '.md', 'a/.md', 'a/b/.md'], '**/.md'), ['.md', 'a/.md', 'a/b/.md']); + assert.deepStrictEqual(match(['.md/.md', '.md/foo/.md', '.md', 'a/.md', 'a/b/.md'], '.md/**/.md'), ['.md/.md', '.md/foo/.md']); }); it('should respect trailing slashes on paterns', () => { - const fixtures = [ - 'a', - 'a/', - 'a/a', - 'a/a/', - 'a/a/a', - 'a/a/a/', - 'a/a/a/a', - 'a/a/a/a/', - 'a/a/a/a/a', - 'a/a/a/a/a/', - 'a/a/b', - 'a/a/b/', - 'a/b', - 'a/b/', - 'a/b/c/.d/e/', - 'a/c', - 'a/c/', - 'a/b', - 'a/x/', - 'b', - 'b/', - 'x/y', - 'x/y/', - 'z/z', - 'z/z/' - ]; + const fixtures = ['a', 'a/', 'a/a', 'a/a/', 'a/a/a', 'a/a/a/', 'a/a/a/a', 'a/a/a/a/', 'a/a/a/a/a', 'a/a/a/a/a/', 'a/a/b', 'a/a/b/', 'a/b', 'a/b/', 'a/b/c/.d/e/', 'a/c', 'a/c/', 'a/b', 'a/x/', 'b', 'b/', 'x/y', 'x/y/', 'z/z', 'z/z/']; - assert.deepStrictEqual(match(fixtures, '**/*/a/'), [ - 'a/a/', - 'a/a/a/', - 'a/a/a/a/', - 'a/a/a/a/a/' - ]); - assert.deepStrictEqual(match(fixtures, '**/*/a/*/'), [ - 'a/a/a/', - 'a/a/a/a/', - 'a/a/a/a/a/', - 'a/a/b/' - ]); + assert.deepStrictEqual(match(fixtures, '**/*/a/'), ['a/a/', 'a/a/a/', 'a/a/a/a/', 'a/a/a/a/a/']); + assert.deepStrictEqual(match(fixtures, '**/*/a/*/'), ['a/a/a/', 'a/a/a/a/', 'a/a/a/a/a/', 'a/a/b/']); assert.deepStrictEqual(match(fixtures, '**/*/x/'), ['a/x/']); - assert.deepStrictEqual(match(fixtures, '**/*/*/*/*/'), [ - 'a/a/a/a/', - 'a/a/a/a/a/' - ]); + assert.deepStrictEqual(match(fixtures, '**/*/*/*/*/'), ['a/a/a/a/', 'a/a/a/a/a/']); assert.deepStrictEqual(match(fixtures, '**/*/*/*/*/*/'), ['a/a/a/a/a/']); assert.deepStrictEqual(match(fixtures, '*a/a/*/'), ['a/a/a/', 'a/a/b/']); assert.deepStrictEqual(match(fixtures, '**a/a/*/'), ['a/a/a/', 'a/a/b/']); - assert.deepStrictEqual(match(fixtures, '**/a/*/*/'), [ - 'a/a/a/', - 'a/a/a/a/', - 'a/a/a/a/a/', - 'a/a/b/' - ]); - assert.deepStrictEqual(match(fixtures, '**/a/*/*/*/'), [ - 'a/a/a/a/', - 'a/a/a/a/a/' - ]); + assert.deepStrictEqual(match(fixtures, '**/a/*/*/'), ['a/a/a/', 'a/a/a/a/', 'a/a/a/a/a/', 'a/a/b/']); + assert.deepStrictEqual(match(fixtures, '**/a/*/*/*/'), ['a/a/a/a/', 'a/a/a/a/a/']); assert.deepStrictEqual(match(fixtures, '**/a/*/*/*/*/'), ['a/a/a/a/a/']); - assert.deepStrictEqual(match(fixtures, '**/a/*/a/'), [ - 'a/a/a/', - 'a/a/a/a/', - 'a/a/a/a/a/' - ]); + assert.deepStrictEqual(match(fixtures, '**/a/*/a/'), ['a/a/a/', 'a/a/a/a/', 'a/a/a/a/a/']); assert.deepStrictEqual(match(fixtures, '**/a/*/b/'), ['a/a/b/']); }); it('should match literal globstars when stars are escaped', () => { const fixtures = ['.md', '**a.md', '**.md', '.md', '**']; - assert.deepStrictEqual(match(fixtures, '\\*\\**.md'), [ - '**a.md', - '**.md' - ]); + assert.deepStrictEqual(match(fixtures, '\\*\\**.md'), ['**a.md', '**.md']); assert.deepStrictEqual(match(fixtures, '\\*\\*.md'), ['**.md']); }); @@ -401,13 +309,7 @@ describe('stars', () => { }); it('should match leading dots when defined in pattern', () => { - const fixtures = [ - '.gitignore', - 'a/b/z/.dotfile', - 'a/b/z/.dotfile.md', - 'a/b/z/.dotfile.md', - 'a/b/z/.dotfile.md' - ]; + const fixtures = ['.gitignore', 'a/b/z/.dotfile', 'a/b/z/.dotfile.md', 'a/b/z/.dotfile.md', 'a/b/z/.dotfile.md']; assert(!isMatch('.gitignore', 'a/**/z/*.md')); assert(!isMatch('a/b/z/.dotfile', 'a/**/z/*.md')); assert(!isMatch('a/b/z/.dotfile.md', '**/c/.*.md')); @@ -415,32 +317,16 @@ describe('stars', () => { assert(isMatch('a/b/z/.a', 'a/*/z/.a')); assert(isMatch('a/b/z/.dotfile.md', '**/.*.md')); assert(isMatch('a/b/z/.dotfile.md', 'a/**/z/.*.md')); - assert.deepStrictEqual( - match(['.md', 'a.md', 'a/b/c.md', '.txt'], '**/*.md'), - ['a.md', 'a/b/c.md'] - ); - assert.deepStrictEqual( - match(['.md/.md', '.md', 'a/.md', 'a/b/.md'], '**/.md'), - ['.md', 'a/.md', 'a/b/.md'] - ); - assert.deepStrictEqual( - match( - ['.md/.md', '.md/foo/.md', '.md', 'a/.md', 'a/b/.md'], - '.md/**/.md' - ), - ['.md/.md', '.md/foo/.md'] - ); - assert.deepStrictEqual(match(fixtures, 'a/**/z/.*.md'), [ - 'a/b/z/.dotfile.md' - ]); + assert.deepStrictEqual(match(['.md', 'a.md', 'a/b/c.md', '.txt'], '**/*.md'), ['a.md', 'a/b/c.md']); + assert.deepStrictEqual(match(['.md/.md', '.md', 'a/.md', 'a/b/.md'], '**/.md'), ['.md', 'a/.md', 'a/b/.md']); + assert.deepStrictEqual(match(['.md/.md', '.md/foo/.md', '.md', 'a/.md', 'a/b/.md'], '.md/**/.md'), ['.md/.md', '.md/foo/.md']); + assert.deepStrictEqual(match(fixtures, 'a/**/z/.*.md'), ['a/b/z/.dotfile.md']); }); it('todo... (micromatch/#24)', () => { assert(isMatch('foo/bar/baz/one/image.png', 'foo/bar/**/one/**/*.*')); assert(isMatch('foo/bar/baz/one/two/image.png', 'foo/bar/**/one/**/*.*')); - assert( - isMatch('foo/bar/baz/one/two/three/image.png', 'foo/bar/**/one/**/*.*') - ); + assert(isMatch('foo/bar/baz/one/two/three/image.png', 'foo/bar/**/one/**/*.*')); assert(!isMatch('a/b/c/d/', 'a/b/**/f')); assert(isMatch('a', 'a/**')); assert(isMatch('a', '**')); diff --git a/test/issue-related.js b/test/issue-related.js index 3b27eec4..f85b3e62 100644 --- a/test/issue-related.js +++ b/test/issue-related.js @@ -5,12 +5,8 @@ const { isMatch } = require('..'); describe('issue-related tests', () => { it('should match with braces (see picomatch/issues#8)', () => { - assert( - isMatch('directory/.test.txt', '{file.txt,directory/**/*}', { dot: true }) - ); - assert( - isMatch('directory/test.txt', '{file.txt,directory/**/*}', { dot: true }) - ); + assert(isMatch('directory/.test.txt', '{file.txt,directory/**/*}', { dot: true })); + assert(isMatch('directory/test.txt', '{file.txt,directory/**/*}', { dot: true })); assert(!isMatch('directory/.test.txt', '{file.txt,directory/**/*}')); assert(isMatch('directory/test.txt', '{file.txt,directory/**/*}')); }); diff --git a/test/malicious.js b/test/malicious.js index d11e3cf5..82a7d2c9 100644 --- a/test/malicious.js +++ b/test/malicious.js @@ -11,30 +11,15 @@ const repeat = n => '\\'.repeat(n); describe('handling of potential regex exploits', () => { it('should support long escape sequences', () => { if (process.platform !== 'win32') { - assert( - isMatch('\\A', `${repeat(65500)}A`), - 'within the limits, and valid match' - ); + assert(isMatch('\\A', `${repeat(65500)}A`), 'within the limits, and valid match'); } - assert( - isMatch('A', `!${repeat(65500)}A`), - 'within the limits, and valid match' - ); - assert( - isMatch('A', `!(${repeat(65500)}A)`), - 'within the limits, and valid match' - ); - assert( - !isMatch('A', `[!(${repeat(65500)}A`), - 'within the limits, but invalid regex' - ); + assert(isMatch('A', `!${repeat(65500)}A`), 'within the limits, and valid match'); + assert(isMatch('A', `!(${repeat(65500)}A)`), 'within the limits, and valid match'); + assert(!isMatch('A', `[!(${repeat(65500)}A`), 'within the limits, but invalid regex'); }); it('should throw an error when the pattern is too long', () => { - assert.throws( - () => isMatch('foo', '*'.repeat(65537)), - /exceeds maximum allowed/ - ); + assert.throws(() => isMatch('foo', '*'.repeat(65537)), /exceeds maximum allowed/); assert.throws(() => { assert(!isMatch('A', `!(${repeat(65536)}A)`)); }, /Input length: 65540, exceeds maximum allowed length: 65536/); diff --git a/test/minimatch.js b/test/minimatch.js index 5f612f63..853e120a 100644 --- a/test/minimatch.js +++ b/test/minimatch.js @@ -26,17 +26,13 @@ describe('minimatch parity:', () => { it('https://github.com/isaacs/minimatch/issues/50', () => { assert(isMatch('foo/bar-[ABC].txt', 'foo/**/*-\\[ABC\\].txt')); assert(!isMatch('foo/bar-[ABC].txt', 'foo/**/*-\\[abc\\].txt')); - assert( - isMatch('foo/bar-[ABC].txt', 'foo/**/*-\\[abc\\].txt', { nocase: true }) - ); + assert(isMatch('foo/bar-[ABC].txt', 'foo/**/*-\\[abc\\].txt', { nocase: true })); }); it('https://github.com/isaacs/minimatch/issues/67 (should work consistently with `makeRe` and matcher functions)', () => { const re = makeRe('node_modules/foobar/**/*.bar'); assert(re.test('node_modules/foobar/foo.bar')); - assert( - isMatch('node_modules/foobar/foo.bar', 'node_modules/foobar/**/*.bar') - ); + assert(isMatch('node_modules/foobar/foo.bar', 'node_modules/foobar/**/*.bar')); }); it('https://github.com/isaacs/minimatch/issues/75', () => { diff --git a/test/negation.js b/test/negation.js index 792ca65e..a3a6a832 100644 --- a/test/negation.js +++ b/test/negation.js @@ -49,24 +49,24 @@ describe('negation patterns - "!"', () => { it('should support multiple leading ! to toggle negation', () => { assert(!isMatch('abc', '!abc')); - assert(isMatch('abc', '!!abc')); + assert(isMatch('abc', '!!abc')); assert(!isMatch('abc', '!!!abc')); - assert(isMatch('abc', '!!!!abc')); + assert(isMatch('abc', '!!!!abc')); assert(!isMatch('abc', '!!!!!abc')); - assert(isMatch('abc', '!!!!!!abc')); + assert(isMatch('abc', '!!!!!!abc')); assert(!isMatch('abc', '!!!!!!!abc')); - assert(isMatch('abc', '!!!!!!!!abc')); + assert(isMatch('abc', '!!!!!!!!abc')); }); it('should support negation extglobs after leading !', () => { assert(!isMatch('abc', '!(abc)')); - assert(isMatch('abc', '!!(abc)')); + assert(isMatch('abc', '!!(abc)')); assert(!isMatch('abc', '!!!(abc)')); - assert(isMatch('abc', '!!!!(abc)')); + assert(isMatch('abc', '!!!!(abc)')); assert(!isMatch('abc', '!!!!!(abc)')); - assert(isMatch('abc', '!!!!!!(abc)')); + assert(isMatch('abc', '!!!!!!(abc)')); assert(!isMatch('abc', '!!!!!!!(abc)')); - assert(isMatch('abc', '!!!!!!!!(abc)')); + assert(isMatch('abc', '!!!!!!!!(abc)')); }); it('should support negation with globs', () => { diff --git a/test/options.expandRange.js b/test/options.expandRange.js index 72b33d40..0eb05fc3 100644 --- a/test/options.expandRange.js +++ b/test/options.expandRange.js @@ -6,18 +6,12 @@ const { isMatch } = require('..'); describe('options.expandRange', () => { it('should support a custom function for expanding ranges in brace patterns', () => { - assert( - isMatch('a/c', 'a/{a..c}', { expandRange: (a, b) => `([${a}-${b}])` }) - ); - assert( - !isMatch('a/z', 'a/{a..c}', { expandRange: (a, b) => `([${a}-${b}])` }) - ); - assert( - isMatch('a/99', 'a/{1..100}', { - expandRange(a, b) { - return `(${fill(a, b, { toRegex: true })})`; - } - }) - ); + assert(isMatch('a/c', 'a/{a..c}', { expandRange: (a, b) => `([${a}-${b}])` })); + assert(!isMatch('a/z', 'a/{a..c}', { expandRange: (a, b) => `([${a}-${b}])` })); + assert(isMatch('a/99', 'a/{1..100}', { + expandRange(a, b) { + return `(${fill(a, b, { toRegex: true })})`; + } + })); }); }); diff --git a/test/options.format.js b/test/options.format.js index 3fb4b683..b4f3444d 100644 --- a/test/options.format.js +++ b/test/options.format.js @@ -5,35 +5,15 @@ const match = require('./support/match'); const { isMatch } = require('..'); const equal = (actual, expected, msg) => { - assert.deepStrictEqual( - [].concat(actual).sort(), - [].concat(expected).sort(), - msg - ); + assert.deepStrictEqual([].concat(actual).sort(), [].concat(expected).sort(), msg); }; describe('options.format', () => { + // see https://github.com/isaacs/minimatch/issues/30 it('should match the string returned by options.format', () => { - const opts = { - format: str => str.replace(/\\/g, '/').replace(/^\.\//, ''), - strictSlashes: true - }; - const fixtures = [ - 'a', - './a', - 'b', - 'a/a', - './a/b', - 'a/c', - './a/x', - './a/a/a', - 'a/a/b', - './a/a/a/a', - './a/a/a/a/a', - 'x/y', - './z/z' - ]; + const opts = { format: str => str.replace(/\\/g, '/').replace(/^\.\//, ''), strictSlashes: true }; + const fixtures = ['a', './a', 'b', 'a/a', './a/b', 'a/c', './a/x', './a/a/a', 'a/a/b', './a/a/a/a', './a/a/a/a/a', 'x/y', './z/z']; assert(!isMatch('./.a', '*.a', opts)); assert(!isMatch('./.a', './*.a', opts)); @@ -63,38 +43,13 @@ describe('options.format', () => { assert(isMatch('.\\foo\\bar.js', '**/foo/**', { ...opts, windows: false })); assert(isMatch('.\\foo\\bar.js', './**/foo/**', opts)); equal(match(fixtures, '*', opts), ['a', 'b']); - equal(match(fixtures, '**/a/**', opts), [ - 'a/a', - 'a/c', - 'a/b', - 'a/x', - 'a/a/a', - 'a/a/b', - 'a/a/a/a', - 'a/a/a/a/a' - ]); - equal(match(fixtures, '*/*', opts), [ - 'a/a', - 'a/b', - 'a/c', - 'a/x', - 'x/y', - 'z/z' - ]); + equal(match(fixtures, '**/a/**', opts), ['a/a', 'a/c', 'a/b', 'a/x', 'a/a/a', 'a/a/b', 'a/a/a/a', 'a/a/a/a/a']); + equal(match(fixtures, '*/*', opts), ['a/a', 'a/b', 'a/c', 'a/x', 'x/y', 'z/z']); equal(match(fixtures, '*/*/*', opts), ['a/a/a', 'a/a/b']); equal(match(fixtures, '*/*/*/*', opts), ['a/a/a/a']); equal(match(fixtures, '*/*/*/*/*', opts), ['a/a/a/a/a']); equal(match(fixtures, '*', opts), ['a', 'b']); - equal(match(fixtures, '**/a/**', opts), [ - 'a/a', - 'a/c', - 'a/b', - 'a/x', - 'a/a/a', - 'a/a/b', - 'a/a/a/a', - 'a/a/a/a/a' - ]); + equal(match(fixtures, '**/a/**', opts), ['a/a', 'a/c', 'a/b', 'a/x', 'a/a/a', 'a/a/b', 'a/a/a/a', 'a/a/a/a/a']); equal(match(fixtures, 'a/*/a', opts), ['a/a/a']); equal(match(fixtures, 'a/*', opts), ['a/a', 'a/b', 'a/c', 'a/x']); equal(match(fixtures, 'a/*/*', opts), ['a/a/a', 'a/a/b']); diff --git a/test/options.ignore.js b/test/options.ignore.js index 4f6814b4..e8cc6285 100644 --- a/test/options.ignore.js +++ b/test/options.ignore.js @@ -6,134 +6,50 @@ const { isMatch } = require('..'); describe('options.ignore', () => { it('should not match ignored patterns', () => { - assert( - isMatch('a+b/src/glimini.js', 'a+b/src/*.js', { ignore: ['**/f*'] }) - ); - assert( - !isMatch('a+b/src/glimini.js', 'a+b/src/*.js', { ignore: ['**/g*'] }) - ); + assert(isMatch('a+b/src/glimini.js', 'a+b/src/*.js', { ignore: ['**/f*'] })); + assert(!isMatch('a+b/src/glimini.js', 'a+b/src/*.js', { ignore: ['**/g*'] })); assert(isMatch('+b/src/glimini.md', '+b/src/*', { ignore: ['**/*.js'] })); assert(!isMatch('+b/src/glimini.js', '+b/src/*', { ignore: ['**/*.js'] })); }); const negations = ['a/a', 'a/b', 'a/c', 'a/d', 'a/e', 'b/a', 'b/b', 'b/c']; - const globs = [ - '.a', - '.a/a', - '.a/a/a', - '.a/a/a/a', - 'a', - 'a/.a', - 'a/a', - 'a/a/.a', - 'a/a/a', - 'a/a/a/a', - 'a/a/a/a/a', - 'a/a/b', - 'a/b', - 'a/b/c', - 'a/c', - 'a/x', - 'b', - 'b/b/b', - 'b/b/c', - 'c/c/c', - 'e/f/g', - 'h/i/a', - 'x/x/x', - 'x/y', - 'z/z', - 'z/z/z' - ].sort(); + const globs = ['.a', '.a/a', '.a/a/a', '.a/a/a/a', 'a', 'a/.a', 'a/a', 'a/a/.a', 'a/a/a', 'a/a/a/a', 'a/a/a/a/a', 'a/a/b', 'a/b', 'a/b/c', 'a/c', 'a/x', 'b', 'b/b/b', 'b/b/c', 'c/c/c', 'e/f/g', 'h/i/a', 'x/x/x', 'x/y', 'z/z', 'z/z/z'].sort(); it('should filter out ignored patterns', () => { const opts = { ignore: ['a/**'], strictSlashes: true }; const dotOpts = { ...opts, dot: true }; assert.deepStrictEqual(match(globs, '*', opts), ['a', 'b']); - assert.deepStrictEqual( - match(globs, '*', { ...opts, strictSlashes: false }), - ['b'] - ); + assert.deepStrictEqual(match(globs, '*', { ...opts, strictSlashes: false }), ['b']); assert.deepStrictEqual(match(globs, '*', { ignore: '**/a' }), ['b']); assert.deepStrictEqual(match(globs, '*/*', opts), ['x/y', 'z/z']); - assert.deepStrictEqual(match(globs, '*/*/*', opts), [ - 'b/b/b', - 'b/b/c', - 'c/c/c', - 'e/f/g', - 'h/i/a', - 'x/x/x', - 'z/z/z' - ]); + assert.deepStrictEqual(match(globs, '*/*/*', opts), ['b/b/b', 'b/b/c', 'c/c/c', 'e/f/g', 'h/i/a', 'x/x/x', 'z/z/z']); assert.deepStrictEqual(match(globs, '*/*/*/*', opts), []); assert.deepStrictEqual(match(globs, '*/*/*/*/*', opts), []); assert.deepStrictEqual(match(globs, 'a/*', opts), []); assert.deepStrictEqual(match(globs, '**/*/x', opts), ['x/x/x']); - assert.deepStrictEqual(match(globs, '**/*/[b-z]', opts), [ - 'b/b/b', - 'b/b/c', - 'c/c/c', - 'e/f/g', - 'x/x/x', - 'x/y', - 'z/z', - 'z/z/z' - ]); + assert.deepStrictEqual(match(globs, '**/*/[b-z]', opts), ['b/b/b', 'b/b/c', 'c/c/c', 'e/f/g', 'x/x/x', 'x/y', 'z/z', 'z/z/z']); - assert.deepStrictEqual(match(globs, '*', { ignore: '**/a', dot: true }), [ - '.a', - 'b' - ]); + assert.deepStrictEqual(match(globs, '*', { ignore: '**/a', dot: true }), ['.a', 'b']); assert.deepStrictEqual(match(globs, '*', dotOpts), ['.a', 'a', 'b']); - assert.deepStrictEqual( - match(globs, '*/*', dotOpts), - ['.a/a', 'x/y', 'z/z'].sort() - ); - assert.deepStrictEqual( - match(globs, '*/*/*', dotOpts), - [ - '.a/a/a', - 'b/b/b', - 'b/b/c', - 'c/c/c', - 'e/f/g', - 'h/i/a', - 'x/x/x', - 'z/z/z' - ].sort() - ); + assert.deepStrictEqual(match(globs, '*/*', dotOpts), ['.a/a', 'x/y', 'z/z'].sort()); + assert.deepStrictEqual(match(globs, '*/*/*', dotOpts), ['.a/a/a', 'b/b/b', 'b/b/c', 'c/c/c', 'e/f/g', 'h/i/a', 'x/x/x', 'z/z/z'].sort()); assert.deepStrictEqual(match(globs, '*/*/*/*', dotOpts), ['.a/a/a/a']); assert.deepStrictEqual(match(globs, '*/*/*/*/*', dotOpts), []); assert.deepStrictEqual(match(globs, 'a/*', dotOpts), []); assert.deepStrictEqual(match(globs, '**/*/x', dotOpts), ['x/x/x']); // see https://github.com/jonschlinkert/micromatch/issues/79 - assert.deepStrictEqual(match(['foo.js', 'a/foo.js'], '**/foo.js'), [ - 'foo.js', - 'a/foo.js' - ]); - assert.deepStrictEqual( - match(['foo.js', 'a/foo.js'], '**/foo.js', { dot: true }), - ['foo.js', 'a/foo.js'] - ); + assert.deepStrictEqual(match(['foo.js', 'a/foo.js'], '**/foo.js'), ['foo.js', 'a/foo.js']); + assert.deepStrictEqual(match(['foo.js', 'a/foo.js'], '**/foo.js', { dot: true }), ['foo.js', 'a/foo.js']); assert.deepStrictEqual(match(negations, '!b/a', opts), ['b/b', 'b/c']); assert.deepStrictEqual(match(negations, '!b/(a)', opts), ['b/b', 'b/c']); assert.deepStrictEqual(match(negations, '!(b/(a))', opts), ['b/b', 'b/c']); assert.deepStrictEqual(match(negations, '!(b/a)', opts), ['b/b', 'b/c']); - assert.deepStrictEqual( - match(negations, '**'), - negations, - 'nothing is ignored' - ); - assert.deepStrictEqual(match(negations, '**', { ignore: ['*/b', '*/a'] }), [ - 'a/c', - 'a/d', - 'a/e', - 'b/c' - ]); + assert.deepStrictEqual(match(negations, '**'), negations, 'nothing is ignored'); + assert.deepStrictEqual(match(negations, '**', { ignore: ['*/b', '*/a'] }), ['a/c', 'a/d', 'a/e', 'b/c']); assert.deepStrictEqual(match(negations, '**', { ignore: ['**'] }), []); }); }); diff --git a/test/options.js b/test/options.js index d2b6c828..8993d181 100644 --- a/test/options.js +++ b/test/options.js @@ -7,118 +7,49 @@ const { isMatch } = require('..'); describe('options', () => { describe('options.matchBase', () => { it('should match the basename of file paths when `options.matchBase` is true', () => { - assert.deepStrictEqual( - match(['a/b/c/d.md'], '*.md', { windows: true }), - [], - 'should not match multiple levels' - ); - assert.deepStrictEqual( - match(['a/b/c/foo.md'], '*.md', { windows: true }), - [], - 'should not match multiple levels' - ); - assert.deepStrictEqual( - match(['ab', 'acb', 'acb/', 'acb/d/e', 'x/y/acb', 'x/y/acb/d'], 'a?b', { - windows: true - }), - ['acb'], - 'should not match multiple levels' - ); - assert.deepStrictEqual( - match(['a/b/c/d.md'], '*.md', { matchBase: true, windows: true }), - ['a/b/c/d.md'] - ); - assert.deepStrictEqual( - match(['a/b/c/foo.md'], '*.md', { matchBase: true, windows: true }), - ['a/b/c/foo.md'] - ); - assert.deepStrictEqual( - match(['x/y/acb', 'acb/', 'acb/d/e', 'x/y/acb/d'], 'a?b', { - matchBase: true, - windows: true - }), - ['x/y/acb', 'acb/'] - ); + assert.deepStrictEqual(match(['a/b/c/d.md'], '*.md', { windows: true }), [], 'should not match multiple levels'); + assert.deepStrictEqual(match(['a/b/c/foo.md'], '*.md', { windows: true }), [], 'should not match multiple levels'); + assert.deepStrictEqual(match(['ab', 'acb', 'acb/', 'acb/d/e', 'x/y/acb', 'x/y/acb/d'], 'a?b', { windows: true }), ['acb'], 'should not match multiple levels'); + assert.deepStrictEqual(match(['a/b/c/d.md'], '*.md', { matchBase: true, windows: true }), ['a/b/c/d.md']); + assert.deepStrictEqual(match(['a/b/c/foo.md'], '*.md', { matchBase: true, windows: true }), ['a/b/c/foo.md']); + assert.deepStrictEqual(match(['x/y/acb', 'acb/', 'acb/d/e', 'x/y/acb/d'], 'a?b', { matchBase: true, windows: true }), ['x/y/acb', 'acb/']); }); it('should work with negation patterns', () => { assert(isMatch('./x/y.js', '*.js', { matchBase: true, windows: true })); assert(!isMatch('./x/y.js', '!*.js', { matchBase: true, windows: true })); - assert( - isMatch('./x/y.js', '**/*.js', { matchBase: true, windows: true }) - ); - assert( - !isMatch('./x/y.js', '!**/*.js', { matchBase: true, windows: true }) - ); + assert(isMatch('./x/y.js', '**/*.js', { matchBase: true, windows: true })); + assert(!isMatch('./x/y.js', '!**/*.js', { matchBase: true, windows: true })); }); }); describe('options.flags', () => { it('should be case-sensitive by default', () => { - assert.deepStrictEqual( - match(['a/b/d/e.md'], 'a/b/D/*.md', { windows: true }), - [], - 'should not match a dirname' - ); - assert.deepStrictEqual( - match(['a/b/c/e.md'], 'A/b/*/E.md', { windows: true }), - [], - 'should not match a basename' - ); - assert.deepStrictEqual( - match(['a/b/c/e.md'], 'A/b/C/*.MD', { windows: true }), - [], - 'should not match a file extension' - ); + assert.deepStrictEqual(match(['a/b/d/e.md'], 'a/b/D/*.md', { windows: true }), [], 'should not match a dirname'); + assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/*/E.md', { windows: true }), [], 'should not match a basename'); + assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/C/*.MD', { windows: true }), [], 'should not match a file extension'); }); it('should not be case-sensitive when `i` is set on `options.flags`', () => { - assert.deepStrictEqual( - match(['a/b/d/e.md'], 'a/b/D/*.md', { flags: 'i', windows: true }), - ['a/b/d/e.md'] - ); - assert.deepStrictEqual( - match(['a/b/c/e.md'], 'A/b/*/E.md', { flags: 'i', windows: true }), - ['a/b/c/e.md'] - ); - assert.deepStrictEqual( - match(['a/b/c/e.md'], 'A/b/C/*.MD', { flags: 'i', windows: true }), - ['a/b/c/e.md'] - ); + assert.deepStrictEqual(match(['a/b/d/e.md'], 'a/b/D/*.md', { flags: 'i', windows: true }), ['a/b/d/e.md']); + assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/*/E.md', { flags: 'i', windows: true }), ['a/b/c/e.md']); + assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/C/*.MD', { flags: 'i', windows: true }), ['a/b/c/e.md']); }); }); describe('options.nocase', () => { it('should not be case-sensitive when `options.nocase` is true', () => { - assert.deepStrictEqual( - match(['a/b/c/e.md'], 'A/b/*/E.md', { nocase: true, windows: true }), - ['a/b/c/e.md'] - ); - assert.deepStrictEqual( - match(['a/b/c/e.md'], 'A/b/C/*.MD', { nocase: true, windows: true }), - ['a/b/c/e.md'] - ); - assert.deepStrictEqual( - match(['a/b/c/e.md'], 'A/b/C/*.md', { nocase: true, windows: true }), - ['a/b/c/e.md'] - ); - assert.deepStrictEqual( - match(['a/b/d/e.md'], 'a/b/D/*.md', { nocase: true, windows: true }), - ['a/b/d/e.md'] - ); + assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/*/E.md', { nocase: true, windows: true }), ['a/b/c/e.md']); + assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/C/*.MD', { nocase: true, windows: true }), ['a/b/c/e.md']); + assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/C/*.md', { nocase: true, windows: true }), ['a/b/c/e.md']); + assert.deepStrictEqual(match(['a/b/d/e.md'], 'a/b/D/*.md', { nocase: true, windows: true }), ['a/b/d/e.md']); }); it('should not double-set `i` when both `nocase` and the `i` flag are set', () => { const opts = { nocase: true, flags: 'i', windows: true }; - assert.deepStrictEqual(match(['a/b/d/e.md'], 'a/b/D/*.md', opts), [ - 'a/b/d/e.md' - ]); - assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/*/E.md', opts), [ - 'a/b/c/e.md' - ]); - assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/C/*.MD', opts), [ - 'a/b/c/e.md' - ]); + assert.deepStrictEqual(match(['a/b/d/e.md'], 'a/b/D/*.md', opts), ['a/b/d/e.md']); + assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/*/E.md', opts), ['a/b/c/e.md']); + assert.deepStrictEqual(match(['a/b/c/e.md'], 'A/b/C/*.MD', opts), ['a/b/c/e.md']); }); }); @@ -129,370 +60,102 @@ describe('options', () => { it('should not match extglobs when noextglob is true', () => { assert(!isMatch('ax', '?(a*|b)', { noextglob: true, windows: true })); - assert.deepStrictEqual( - match(['a.j.js', 'a.md.js'], '*.*(j).js', { - noextglob: true, - windows: true - }), - ['a.j.js'] - ); - assert.deepStrictEqual( - match(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)', { - noextglob: true, - windows: true - }), - ['a/!(z)'] - ); - assert.deepStrictEqual( - match(['a/z', 'a/b'], 'a/!(z)', { noextglob: true, windows: true }), - [] - ); - assert.deepStrictEqual( - match(['c/a/v'], 'c/!(z)/v', { noextglob: true, windows: true }), - [] - ); - assert.deepStrictEqual( - match(['c/z/v', 'c/a/v'], 'c/!(z)/v', { - noextglob: true, - windows: true - }), - [] - ); - assert.deepStrictEqual( - match(['c/z/v', 'c/a/v'], 'c/@(z)/v', { - noextglob: true, - windows: true - }), - [] - ); - assert.deepStrictEqual( - match(['c/z/v', 'c/a/v'], 'c/+(z)/v', { - noextglob: true, - windows: true - }), - [] - ); - assert.deepStrictEqual( - match(['c/z/v', 'c/a/v'], 'c/*(z)/v', { - noextglob: true, - windows: true - }), - ['c/z/v'] - ); - assert.deepStrictEqual( - match(['c/z/v', 'z', 'zf', 'fz'], '?(z)', { - noextglob: true, - windows: true - }), - ['fz'] - ); - assert.deepStrictEqual( - match(['c/z/v', 'z', 'zf', 'fz'], '+(z)', { - noextglob: true, - windows: true - }), - [] - ); - assert.deepStrictEqual( - match(['c/z/v', 'z', 'zf', 'fz'], '*(z)', { - noextglob: true, - windows: true - }), - ['z', 'fz'] - ); - assert.deepStrictEqual( - match(['cz', 'abz', 'az'], 'a@(z)', { noextglob: true, windows: true }), - [] - ); - assert.deepStrictEqual( - match(['cz', 'abz', 'az'], 'a*@(z)', { - noextglob: true, - windows: true - }), - [] - ); - assert.deepStrictEqual( - match(['cz', 'abz', 'az'], 'a!(z)', { noextglob: true, windows: true }), - [] - ); - assert.deepStrictEqual( - match(['cz', 'abz', 'az', 'azz'], 'a?(z)', { - noextglob: true, - windows: true - }), - ['abz', 'azz'] - ); - assert.deepStrictEqual( - match(['cz', 'abz', 'az', 'azz', 'a+z'], 'a+(z)', { - noextglob: true, - windows: true - }), - ['a+z'] - ); - assert.deepStrictEqual( - match(['cz', 'abz', 'az'], 'a*(z)', { noextglob: true, windows: true }), - ['abz', 'az'] - ); - assert.deepStrictEqual( - match(['cz', 'abz', 'az'], 'a**(z)', { - noextglob: true, - windows: true - }), - ['abz', 'az'] - ); - assert.deepStrictEqual( - match(['cz', 'abz', 'az'], 'a*!(z)', { - noextglob: true, - windows: true - }), - [] - ); + assert.deepStrictEqual(match(['a.j.js', 'a.md.js'], '*.*(j).js', { noextglob: true, windows: true }), ['a.j.js']); + assert.deepStrictEqual(match(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)', { noextglob: true, windows: true }), ['a/!(z)']); + assert.deepStrictEqual(match(['a/z', 'a/b'], 'a/!(z)', { noextglob: true, windows: true }), []); + assert.deepStrictEqual(match(['c/a/v'], 'c/!(z)/v', { noextglob: true, windows: true }), []); + assert.deepStrictEqual(match(['c/z/v', 'c/a/v'], 'c/!(z)/v', { noextglob: true, windows: true }), []); + assert.deepStrictEqual(match(['c/z/v', 'c/a/v'], 'c/@(z)/v', { noextglob: true, windows: true }), []); + assert.deepStrictEqual(match(['c/z/v', 'c/a/v'], 'c/+(z)/v', { noextglob: true, windows: true }), []); + assert.deepStrictEqual(match(['c/z/v', 'c/a/v'], 'c/*(z)/v', { noextglob: true, windows: true }), ['c/z/v']); + assert.deepStrictEqual(match(['c/z/v', 'z', 'zf', 'fz'], '?(z)', { noextglob: true, windows: true }), ['fz']); + assert.deepStrictEqual(match(['c/z/v', 'z', 'zf', 'fz'], '+(z)', { noextglob: true, windows: true }), []); + assert.deepStrictEqual(match(['c/z/v', 'z', 'zf', 'fz'], '*(z)', { noextglob: true, windows: true }), ['z', 'fz']); + assert.deepStrictEqual(match(['cz', 'abz', 'az'], 'a@(z)', { noextglob: true, windows: true }), []); + assert.deepStrictEqual(match(['cz', 'abz', 'az'], 'a*@(z)', { noextglob: true, windows: true }), []); + assert.deepStrictEqual(match(['cz', 'abz', 'az'], 'a!(z)', { noextglob: true, windows: true }), []); + assert.deepStrictEqual(match(['cz', 'abz', 'az', 'azz'], 'a?(z)', { noextglob: true, windows: true }), ['abz', 'azz']); + assert.deepStrictEqual(match(['cz', 'abz', 'az', 'azz', 'a+z'], 'a+(z)', { noextglob: true, windows: true }), ['a+z']); + assert.deepStrictEqual(match(['cz', 'abz', 'az'], 'a*(z)', { noextglob: true, windows: true }), ['abz', 'az']); + assert.deepStrictEqual(match(['cz', 'abz', 'az'], 'a**(z)', { noextglob: true, windows: true }), ['abz', 'az']); + assert.deepStrictEqual(match(['cz', 'abz', 'az'], 'a*!(z)', { noextglob: true, windows: true }), []); }); }); describe('options.unescape', () => { it('should remove backslashes in glob patterns:', () => { const fixtures = ['abc', '/a/b/c', '\\a\\b\\c']; - assert.deepStrictEqual(match(fixtures, '\\a\\b\\c', { windows: true }), [ - '/a/b/c' - ]); - assert.deepStrictEqual( - match(fixtures, '\\a\\b\\c', { unescape: true, windows: true }), - ['abc', '/a/b/c'] - ); - assert.deepStrictEqual( - match(fixtures, '\\a\\b\\c', { unescape: false, windows: true }), - ['/a/b/c'] - ); + assert.deepStrictEqual(match(fixtures, '\\a\\b\\c', { windows: true }), ['/a/b/c']); + assert.deepStrictEqual(match(fixtures, '\\a\\b\\c', { unescape: true, windows: true }), ['abc', '/a/b/c']); + assert.deepStrictEqual(match(fixtures, '\\a\\b\\c', { unescape: false, windows: true }), ['/a/b/c']); }); }); describe('options.nonegate', () => { it('should support the `nonegate` option:', () => { - assert.deepStrictEqual( - match(['a/a/a', 'a/b/a', 'b/b/a', 'c/c/a', 'c/c/b'], '!**/a', { - windows: true - }), - ['c/c/b'] - ); - assert.deepStrictEqual( - match(['a.md', '!a.md', 'a.txt'], '!*.md', { - nonegate: true, - windows: true - }), - ['!a.md'] - ); - assert.deepStrictEqual( - match(['!a/a/a', '!a/a', 'a/b/a', 'b/b/a', '!c/c/a', '!c/a'], '!**/a', { - nonegate: true, - windows: true - }), - ['!a/a', '!c/a'] - ); - assert.deepStrictEqual( - match(['!*.md', '.dotfile.txt', 'a/b/.dotfile'], '!*.md', { - nonegate: true, - windows: true - }), - ['!*.md'] - ); + assert.deepStrictEqual(match(['a/a/a', 'a/b/a', 'b/b/a', 'c/c/a', 'c/c/b'], '!**/a', { windows: true }), ['c/c/b']); + assert.deepStrictEqual(match(['a.md', '!a.md', 'a.txt'], '!*.md', { nonegate: true, windows: true }), ['!a.md']); + assert.deepStrictEqual(match(['!a/a/a', '!a/a', 'a/b/a', 'b/b/a', '!c/c/a', '!c/a'], '!**/a', { nonegate: true, windows: true }), ['!a/a', '!c/a']); + assert.deepStrictEqual(match(['!*.md', '.dotfile.txt', 'a/b/.dotfile'], '!*.md', { nonegate: true, windows: true }), ['!*.md']); }); }); describe('options.windows', () => { it('should windows file paths by default', () => { - assert.deepStrictEqual( - match(['a\\b\\c.md'], '**/*.md', { windows: true }), - ['a/b/c.md'] - ); - assert.deepStrictEqual( - match(['a\\b\\c.md'], '**/*.md', { windows: false }), - ['a\\b\\c.md'] - ); + assert.deepStrictEqual(match(['a\\b\\c.md'], '**/*.md', { windows: true }), ['a/b/c.md']); + assert.deepStrictEqual(match(['a\\b\\c.md'], '**/*.md', { windows: false }), ['a\\b\\c.md']); }); it('should windows absolute paths', () => { - assert.deepStrictEqual( - match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: true }), - ['E:/a/b/c.md'] - ); - assert.deepStrictEqual( - match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: false }), - [] - ); + assert.deepStrictEqual(match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: true }), ['E:/a/b/c.md']); + assert.deepStrictEqual(match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: false }), []); }); it('should strip leading `./`', () => { - const fixtures = [ - './a', - './a/a/a', - './a/a/a/a', - './a/a/a/a/a', - './a/b', - './a/x', - './z/z', - 'a', - 'a/a', - 'a/a/b', - 'a/c', - 'b', - 'x/y' - ].sort(); + const fixtures = ['./a', './a/a/a', './a/a/a/a', './a/a/a/a/a', './a/b', './a/x', './z/z', 'a', 'a/a', 'a/a/b', 'a/c', 'b', 'x/y'].sort(); const format = str => str.replace(/^\.\//, ''); const opts = { format, windows: true }; assert.deepStrictEqual(match(fixtures, '*', opts), ['a', 'b']); - assert.deepStrictEqual(match(fixtures, '**/a/**', opts), [ - 'a', - 'a/a/a', - 'a/a/a/a', - 'a/a/a/a/a', - 'a/b', - 'a/x', - 'a/a', - 'a/a/b', - 'a/c' - ]); - assert.deepStrictEqual(match(fixtures, '*/*', opts), [ - 'a/b', - 'a/x', - 'z/z', - 'a/a', - 'a/c', - 'x/y' - ]); - assert.deepStrictEqual(match(fixtures, '*/*/*', opts), [ - 'a/a/a', - 'a/a/b' - ]); + assert.deepStrictEqual(match(fixtures, '**/a/**', opts), ['a', 'a/a/a', 'a/a/a/a', 'a/a/a/a/a', 'a/b', 'a/x', 'a/a', 'a/a/b', 'a/c']); + assert.deepStrictEqual(match(fixtures, '*/*', opts), ['a/b', 'a/x', 'z/z', 'a/a', 'a/c', 'x/y']); + assert.deepStrictEqual(match(fixtures, '*/*/*', opts), ['a/a/a', 'a/a/b']); assert.deepStrictEqual(match(fixtures, '*/*/*/*', opts), ['a/a/a/a']); assert.deepStrictEqual(match(fixtures, '*/*/*/*/*', opts), ['a/a/a/a/a']); assert.deepStrictEqual(match(fixtures, './*', opts), ['a', 'b']); - assert.deepStrictEqual(match(fixtures, './**/a/**', opts), [ - 'a', - 'a/a/a', - 'a/a/a/a', - 'a/a/a/a/a', - 'a/b', - 'a/x', - 'a/a', - 'a/a/b', - 'a/c' - ]); + assert.deepStrictEqual(match(fixtures, './**/a/**', opts), ['a', 'a/a/a', 'a/a/a/a', 'a/a/a/a/a', 'a/b', 'a/x', 'a/a', 'a/a/b', 'a/c']); assert.deepStrictEqual(match(fixtures, './a/*/a', opts), ['a/a/a']); - assert.deepStrictEqual(match(fixtures, 'a/*', opts), [ - 'a/b', - 'a/x', - 'a/a', - 'a/c' - ]); - assert.deepStrictEqual(match(fixtures, 'a/*/*', opts), [ - 'a/a/a', - 'a/a/b' - ]); + assert.deepStrictEqual(match(fixtures, 'a/*', opts), ['a/b', 'a/x', 'a/a', 'a/c']); + assert.deepStrictEqual(match(fixtures, 'a/*/*', opts), ['a/a/a', 'a/a/b']); assert.deepStrictEqual(match(fixtures, 'a/*/*/*', opts), ['a/a/a/a']); assert.deepStrictEqual(match(fixtures, 'a/*/*/*/*', opts), ['a/a/a/a/a']); assert.deepStrictEqual(match(fixtures, 'a/*/a', opts), ['a/a/a']); - assert.deepStrictEqual( - match(fixtures, '*', { ...opts, windows: false }), - ['a', 'b'] - ); - assert.deepStrictEqual( - match(fixtures, '**/a/**', { ...opts, windows: false }), - [ - 'a', - 'a/a/a', - 'a/a/a/a', - 'a/a/a/a/a', - 'a/b', - 'a/x', - 'a/a', - 'a/a/b', - 'a/c' - ] - ); - assert.deepStrictEqual( - match(fixtures, '*/*', { ...opts, windows: false }), - ['a/b', 'a/x', 'z/z', 'a/a', 'a/c', 'x/y'] - ); - assert.deepStrictEqual( - match(fixtures, '*/*/*', { ...opts, windows: false }), - ['a/a/a', 'a/a/b'] - ); - assert.deepStrictEqual( - match(fixtures, '*/*/*/*', { ...opts, windows: false }), - ['a/a/a/a'] - ); - assert.deepStrictEqual( - match(fixtures, '*/*/*/*/*', { ...opts, windows: false }), - ['a/a/a/a/a'] - ); - assert.deepStrictEqual( - match(fixtures, './*', { ...opts, windows: false }), - ['a', 'b'] - ); - assert.deepStrictEqual( - match(fixtures, './**/a/**', { ...opts, windows: false }), - [ - 'a', - 'a/a/a', - 'a/a/a/a', - 'a/a/a/a/a', - 'a/b', - 'a/x', - 'a/a', - 'a/a/b', - 'a/c' - ] - ); - assert.deepStrictEqual( - match(fixtures, './a/*/a', { ...opts, windows: false }), - ['a/a/a'] - ); - assert.deepStrictEqual( - match(fixtures, 'a/*', { ...opts, windows: false }), - ['a/b', 'a/x', 'a/a', 'a/c'] - ); - assert.deepStrictEqual( - match(fixtures, 'a/*/*', { ...opts, windows: false }), - ['a/a/a', 'a/a/b'] - ); - assert.deepStrictEqual( - match(fixtures, 'a/*/*/*', { ...opts, windows: false }), - ['a/a/a/a'] - ); - assert.deepStrictEqual( - match(fixtures, 'a/*/*/*/*', { ...opts, windows: false }), - ['a/a/a/a/a'] - ); - assert.deepStrictEqual( - match(fixtures, 'a/*/a', { ...opts, windows: false }), - ['a/a/a'] - ); + assert.deepStrictEqual(match(fixtures, '*', { ...opts, windows: false }), ['a', 'b']); + assert.deepStrictEqual(match(fixtures, '**/a/**', { ...opts, windows: false }), ['a', 'a/a/a', 'a/a/a/a', 'a/a/a/a/a', 'a/b', 'a/x', 'a/a', 'a/a/b', 'a/c']); + assert.deepStrictEqual(match(fixtures, '*/*', { ...opts, windows: false }), ['a/b', 'a/x', 'z/z', 'a/a', 'a/c', 'x/y']); + assert.deepStrictEqual(match(fixtures, '*/*/*', { ...opts, windows: false }), ['a/a/a', 'a/a/b']); + assert.deepStrictEqual(match(fixtures, '*/*/*/*', { ...opts, windows: false }), ['a/a/a/a']); + assert.deepStrictEqual(match(fixtures, '*/*/*/*/*', { ...opts, windows: false }), ['a/a/a/a/a']); + assert.deepStrictEqual(match(fixtures, './*', { ...opts, windows: false }), ['a', 'b']); + assert.deepStrictEqual(match(fixtures, './**/a/**', { ...opts, windows: false }), ['a', 'a/a/a', 'a/a/a/a', 'a/a/a/a/a', 'a/b', 'a/x', 'a/a', 'a/a/b', 'a/c']); + assert.deepStrictEqual(match(fixtures, './a/*/a', { ...opts, windows: false }), ['a/a/a']); + assert.deepStrictEqual(match(fixtures, 'a/*', { ...opts, windows: false }), ['a/b', 'a/x', 'a/a', 'a/c']); + assert.deepStrictEqual(match(fixtures, 'a/*/*', { ...opts, windows: false }), ['a/a/a', 'a/a/b']); + assert.deepStrictEqual(match(fixtures, 'a/*/*/*', { ...opts, windows: false }), ['a/a/a/a']); + assert.deepStrictEqual(match(fixtures, 'a/*/*/*/*', { ...opts, windows: false }), ['a/a/a/a/a']); + assert.deepStrictEqual(match(fixtures, 'a/*/a', { ...opts, windows: false }), ['a/a/a']); }); }); describe('windows', () => { it('should convert file paths to posix slashes', () => { - assert.deepStrictEqual( - match(['a\\b\\c.md'], '**/*.md', { windows: true }), - ['a/b/c.md'] - ); - assert.deepStrictEqual( - match(['a\\b\\c.md'], '**/*.md', { windows: false }), - ['a\\b\\c.md'] - ); + assert.deepStrictEqual(match(['a\\b\\c.md'], '**/*.md', { windows: true }), ['a/b/c.md']); + assert.deepStrictEqual(match(['a\\b\\c.md'], '**/*.md', { windows: false }), ['a\\b\\c.md']); }); it('should convert absolute paths to posix slashes', () => { - assert.deepStrictEqual( - match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: true }), - ['E:/a/b/c.md'] - ); - assert.deepStrictEqual( - match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: false }), - [] - ); + assert.deepStrictEqual(match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: true }), ['E:/a/b/c.md']); + assert.deepStrictEqual(match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: false }), []); }); }); }); diff --git a/test/options.onMatch.js b/test/options.onMatch.js index e365b837..caf23355 100644 --- a/test/options.onMatch.js +++ b/test/options.onMatch.js @@ -6,22 +6,15 @@ const picomatch = require('..'); const { isMatch } = picomatch; const equal = (actual, expected, msg) => { - assert.deepStrictEqual( - [].concat(actual).sort(), - [].concat(expected).sort(), - msg - ); + assert.deepStrictEqual([].concat(actual).sort(), [].concat(expected).sort(), msg); }; const format = str => str.replace(/^\.\//, ''); const options = () => { return { format, - onMatch({ output }, matches) { - if ( - output.length > 2 && - (output.startsWith('./') || output.startsWith('.\\')) - ) { + onMatch({ pattern, regex, input, output }, matches) { + if (output.length > 2 && (output.startsWith('./') || output.startsWith('.\\'))) { output = output.slice(2); } if (matches) { @@ -33,21 +26,7 @@ const options = () => { describe('options.onMatch', () => { it('should call options.onMatch on each matching string', () => { - const fixtures = [ - 'a', - './a', - 'b', - 'a/a', - './a/b', - 'a/c', - './a/x', - './a/a/a', - 'a/a/b', - './a/a/a/a', - './a/a/a/a/a', - 'x/y', - './z/z' - ]; + const fixtures = ['a', './a', 'b', 'a/a', './a/b', 'a/c', './a/x', './a/a/a', 'a/a/b', './a/a/a/a', './a/a/a/a/a', 'x/y', './z/z']; assert(!isMatch('./.a', '*.a', { format })); assert(!isMatch('./.a', './*.a', { format })); @@ -57,9 +36,7 @@ describe('options.onMatch', () => { assert(!isMatch('a/b/c/d/e/z/c.md', './a/**/j/**/z/*.md', { format })); assert(isMatch('./.a', './.a', { format })); assert(isMatch('./a/b/c.md', 'a/**/*.md', { format })); - assert( - isMatch('./a/b/c/d/e/j/n/p/o/z/c.md', './a/**/j/**/z/*.md', { format }) - ); + assert(isMatch('./a/b/c/d/e/j/n/p/o/z/c.md', './a/**/j/**/z/*.md', { format })); assert(isMatch('./a/b/c/d/e/z/c.md', '**/*.md', { format })); assert(isMatch('./a/b/c/d/e/z/c.md', './a/**/z/*.md', { format })); assert(isMatch('./a/b/c/d/e/z/c.md', 'a/**/z/*.md', { format })); @@ -74,40 +51,13 @@ describe('options.onMatch', () => { assert(isMatch('a/b/c/j/e/z/c.md', 'a/**/j/**/z/*.md', { format })); equal(match(fixtures, '*', options()), ['a', 'b']); - equal(match(fixtures, '**/a/**', options()), [ - 'a', - 'a/a', - 'a/c', - 'a/b', - 'a/x', - 'a/a/a', - 'a/a/b', - 'a/a/a/a', - 'a/a/a/a/a' - ]); - equal(match(fixtures, '*/*', options()), [ - 'a/a', - 'a/b', - 'a/c', - 'a/x', - 'x/y', - 'z/z' - ]); + equal(match(fixtures, '**/a/**', options()), ['a', 'a/a', 'a/c', 'a/b', 'a/x', 'a/a/a', 'a/a/b', 'a/a/a/a', 'a/a/a/a/a']); + equal(match(fixtures, '*/*', options()), ['a/a', 'a/b', 'a/c', 'a/x', 'x/y', 'z/z']); equal(match(fixtures, '*/*/*', options()), ['a/a/a', 'a/a/b']); equal(match(fixtures, '*/*/*/*', options()), ['a/a/a/a']); equal(match(fixtures, '*/*/*/*/*', options()), ['a/a/a/a/a']); equal(match(fixtures, './*', options()), ['a', 'b']); - equal(match(fixtures, './**/a/**', options()), [ - 'a', - 'a/a', - 'a/b', - 'a/c', - 'a/x', - 'a/a/a', - 'a/a/b', - 'a/a/a/a', - 'a/a/a/a/a' - ]); + equal(match(fixtures, './**/a/**', options()), ['a', 'a/a', 'a/b', 'a/c', 'a/x', 'a/a/a', 'a/a/b', 'a/a/a/a', 'a/a/a/a/a']); equal(match(fixtures, './a/*/a', options()), ['a/a/a']); equal(match(fixtures, 'a/*', options()), ['a/a', 'a/b', 'a/c', 'a/x']); equal(match(fixtures, 'a/*/*', options()), ['a/a/a', 'a/a/b']); diff --git a/test/posix-classes.js b/test/posix-classes.js index 35750e78..f3eed940 100644 --- a/test/posix-classes.js +++ b/test/posix-classes.js @@ -15,36 +15,16 @@ describe('posix classes', () => { describe('posix bracket type conversion', () => { it('should create regex character classes from POSIX bracket expressions:', () => { assert.strictEqual(convert('foo[[:lower:]]bar'), 'foo[a-z]bar'); - assert.strictEqual( - convert('foo[[:lower:][:upper:]]bar'), - 'foo[a-zA-Z]bar' - ); + assert.strictEqual(convert('foo[[:lower:][:upper:]]bar'), 'foo[a-zA-Z]bar'); assert.strictEqual(convert('[[:alpha:]123]'), '(?=.)[a-zA-Z123]'); assert.strictEqual(convert('[[:lower:]]'), '(?=.)[a-z]'); assert.strictEqual(convert('[![:lower:]]'), '(?=.)[^a-z]'); - assert.strictEqual( - convert('[[:digit:][:upper:][:space:]]'), - '(?=.)[0-9A-Z \\t\\r\\n\\v\\f]' - ); + assert.strictEqual(convert('[[:digit:][:upper:][:space:]]'), '(?=.)[0-9A-Z \\t\\r\\n\\v\\f]'); assert.strictEqual(convert('[[:xdigit:]]'), '(?=.)[A-Fa-f0-9]'); - assert.strictEqual( - convert( - '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]' - ), - '(?=.)[a-zA-Z0-9a-zA-Z \\t\\x00-\\x1F\\x7F0-9\\x21-\\x7Ea-z\\x20-\\x7E \\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~ \\t\\r\\n\\v\\fA-ZA-Fa-f0-9]' - ); - assert.strictEqual( - convert( - '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]' - ), - '(?=.)[^a-zA-Z0-9a-zA-Z \\t\\x00-\\x1F\\x7F0-9a-z \\t\\r\\n\\v\\fA-ZA-Fa-f0-9]' - ); + assert.strictEqual(convert('[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'), '(?=.)[a-zA-Z0-9a-zA-Z \\t\\x00-\\x1F\\x7F0-9\\x21-\\x7Ea-z\\x20-\\x7E \\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~ \\t\\r\\n\\v\\fA-ZA-Fa-f0-9]'); + assert.strictEqual(convert('[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'), '(?=.)[^a-zA-Z0-9a-zA-Z \\t\\x00-\\x1F\\x7F0-9a-z \\t\\r\\n\\v\\fA-ZA-Fa-f0-9]'); assert.strictEqual(convert('[a-c[:digit:]x-z]'), '(?=.)[a-c0-9x-z]'); - assert.strictEqual( - convert('[_[:alpha:]][_[:alnum:]][_[:alnum:]]*'), - '(?=.)[_a-zA-Z][_a-zA-Z0-9][_a-zA-Z0-9]*', - [] - ); + assert.strictEqual(convert('[_[:alpha:]][_[:alnum:]][_[:alnum:]]*'), '(?=.)[_a-zA-Z][_a-zA-Z0-9][_a-zA-Z0-9]*', []); }); }); @@ -85,30 +65,12 @@ describe('posix classes', () => { assert(!isMatch('A', '[[:lower:]]')); assert(!isMatch('9', '[[:lower:]]')); - assert( - isMatch('a', '[:alpha:]'), - 'invalid posix bracket, but valid char class' - ); - assert( - isMatch('l', '[:alpha:]'), - 'invalid posix bracket, but valid char class' - ); - assert( - isMatch('p', '[:alpha:]'), - 'invalid posix bracket, but valid char class' - ); - assert( - isMatch('h', '[:alpha:]'), - 'invalid posix bracket, but valid char class' - ); - assert( - isMatch(':', '[:alpha:]'), - 'invalid posix bracket, but valid char class' - ); - assert( - !isMatch('b', '[:alpha:]'), - 'invalid posix bracket, but valid char class' - ); + assert(isMatch('a', '[:alpha:]'), 'invalid posix bracket, but valid char class'); + assert(isMatch('l', '[:alpha:]'), 'invalid posix bracket, but valid char class'); + assert(isMatch('p', '[:alpha:]'), 'invalid posix bracket, but valid char class'); + assert(isMatch('h', '[:alpha:]'), 'invalid posix bracket, but valid char class'); + assert(isMatch(':', '[:alpha:]'), 'invalid posix bracket, but valid char class'); + assert(!isMatch('b', '[:alpha:]'), 'invalid posix bracket, but valid char class'); }); it('should support multiple posix brackets in one character class', () => { @@ -171,10 +133,7 @@ describe('posix classes', () => { it('should not create an invalid posix character class:', () => { assert.strictEqual(convert('[:al:]'), '(?:\\[:al:\\]|[:al:])'); - assert.strictEqual( - convert('[abc[:punct:][0-9]'), - '(?=.)[abc\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~\\[0-9]' - ); + assert.strictEqual(convert('[abc[:punct:][0-9]'), '(?=.)[abc\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~\\[0-9]'); }); it('should return `true` when the pattern matches:', () => { @@ -186,24 +145,9 @@ describe('posix classes', () => { assert(isMatch('5', '[[:xdigit:]]')); assert(isMatch('f', '[[:xdigit:]]')); assert(isMatch('D', '[[:xdigit:]]')); - assert( - isMatch( - '_', - '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]' - ) - ); - assert( - isMatch( - '_', - '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]' - ) - ); - assert( - isMatch( - '.', - '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]' - ) - ); + assert(isMatch('_', '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]')); + assert(isMatch('_', '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]')); + assert(isMatch('.', '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]')); assert(isMatch('5', '[a-c[:digit:]x-z]')); assert(isMatch('b', '[a-c[:digit:]x-z]')); assert(isMatch('y', '[a-c[:digit:]x-z]')); @@ -215,12 +159,7 @@ describe('posix classes', () => { assert(!isMatch('a', '[[:upper:]]')); assert(!isMatch('a', '[[:digit:][:upper:][:space:]]')); assert(!isMatch('.', '[[:digit:][:upper:][:space:]]')); - assert( - !isMatch( - '.', - '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]' - ) - ); + assert(!isMatch('.', '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]')); assert(!isMatch('q', '[a-c[:digit:]x-z]')); }); }); @@ -246,10 +185,7 @@ describe('posix classes', () => { describe('.makeRe()', () => { it('should make a regular expression for the given pattern:', () => { - assert.deepStrictEqual( - makeRe('[[:alpha:]123]', opts), - /^(?:(?=.)[a-zA-Z123])$/ - ); + assert.deepStrictEqual(makeRe('[[:alpha:]123]', opts), /^(?:(?=.)[a-zA-Z123])$/); assert.deepStrictEqual(makeRe('[![:lower:]]', opts), /^(?:(?=.)[^a-z])$/); }); }); @@ -392,13 +328,13 @@ describe('posix classes', () => { assert(!isMatch('b', '[[:alpha:]\\]')); }); - it("OK, what's a tab? is it a blank? a space?", () => { + it('OK, what\'s a tab? is it a blank? a space?', () => { assert(isMatch('\t', '[[:blank:]]')); assert(isMatch('\t', '[[:space:]]')); assert(isMatch(' ', '[[:space:]]')); }); - it("let's check out characters in the ASCII range", () => { + it('let\'s check out characters in the ASCII range', () => { assert(!isMatch('\\377', '[[:ascii:]]')); assert(!isMatch('9', '[1[:alpha:]123]')); }); diff --git a/test/qmarks.js b/test/qmarks.js index 2f3b37de..1a2dadf3 100644 --- a/test/qmarks.js +++ b/test/qmarks.js @@ -15,79 +15,30 @@ describe('qmarks and stars', () => { assert.deepStrictEqual(match(['?', '??', '???'], '?*'), ['?', '??', '???']); assert.deepStrictEqual(match(['?', '??', '???'], '*?'), ['?', '??', '???']); assert.deepStrictEqual(match(['?', '??', '???'], '?*?'), ['??', '???']); - assert.deepStrictEqual(match(['?*', '?*?', '?*?*?'], '?*'), [ - '?*', - '?*?', - '?*?*?' - ]); - assert.deepStrictEqual(match(['?*', '?*?', '?*?*?'], '*?'), [ - '?*', - '?*?', - '?*?*?' - ]); - assert.deepStrictEqual(match(['?*', '?*?', '?*?*?'], '?*?'), [ - '?*', - '?*?', - '?*?*?' - ]); + assert.deepStrictEqual(match(['?*', '?*?', '?*?*?'], '?*'), ['?*', '?*?', '?*?*?']); + assert.deepStrictEqual(match(['?*', '?*?', '?*?*?'], '*?'), ['?*', '?*?', '?*?*?']); + assert.deepStrictEqual(match(['?*', '?*?', '?*?*?'], '?*?'), ['?*', '?*?', '?*?*?']); }); it('should support consecutive stars and question marks', () => { - assert.deepStrictEqual(match(['aaa', 'aac', 'abc'], 'a*?c'), [ - 'aac', - 'abc' - ]); - assert.deepStrictEqual(match(['abc', 'abb', 'acc'], 'a**?c'), [ - 'abc', - 'acc' - ]); - assert.deepStrictEqual(match(['abc', 'aaaabbbbbbccccc'], 'a*****?c'), [ - 'abc', - 'aaaabbbbbbccccc' - ]); - assert.deepStrictEqual(match(['a', 'ab', 'abc', 'abcd'], '*****?'), [ - 'a', - 'ab', - 'abc', - 'abcd' - ]); - assert.deepStrictEqual(match(['a', 'ab', 'abc', 'abcd'], '*****??'), [ - 'ab', - 'abc', - 'abcd' - ]); - assert.deepStrictEqual(match(['a', 'ab', 'abc', 'abcd'], '?*****??'), [ - 'abc', - 'abcd' - ]); + assert.deepStrictEqual(match(['aaa', 'aac', 'abc'], 'a*?c'), ['aac', 'abc']); + assert.deepStrictEqual(match(['abc', 'abb', 'acc'], 'a**?c'), ['abc', 'acc']); + assert.deepStrictEqual(match(['abc', 'aaaabbbbbbccccc'], 'a*****?c'), ['abc', 'aaaabbbbbbccccc']); + assert.deepStrictEqual(match(['a', 'ab', 'abc', 'abcd'], '*****?'), ['a', 'ab', 'abc', 'abcd']); + assert.deepStrictEqual(match(['a', 'ab', 'abc', 'abcd'], '*****??'), ['ab', 'abc', 'abcd']); + assert.deepStrictEqual(match(['a', 'ab', 'abc', 'abcd'], '?*****??'), ['abc', 'abcd']); assert.deepStrictEqual(match(['abc', 'abb', 'zzz'], '?*****?c'), ['abc']); - assert.deepStrictEqual(match(['abc', 'bbb', 'zzz'], '?***?****?'), [ - 'abc', - 'bbb', - 'zzz' - ]); + assert.deepStrictEqual(match(['abc', 'bbb', 'zzz'], '?***?****?'), ['abc', 'bbb', 'zzz']); assert.deepStrictEqual(match(['abc', 'bbb', 'zzz'], '?***?****c'), ['abc']); assert.deepStrictEqual(match(['abc'], '*******?'), ['abc']); assert.deepStrictEqual(match(['abc'], '*******c'), ['abc']); assert.deepStrictEqual(match(['abc'], '?***?****'), ['abc']); - assert.deepStrictEqual(match(['abcdecdhjk'], 'a****c**?**??*****'), [ - 'abcdecdhjk' - ]); - assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??***k'), [ - 'abcdecdhjk' - ]); - assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??***k**'), [ - 'abcdecdhjk' - ]); - assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??k'), [ - 'abcdecdhjk' - ]); - assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??k***'), [ - 'abcdecdhjk' - ]); - assert.deepStrictEqual(match(['abcdecdhjk'], 'a*cd**?**??k'), [ - 'abcdecdhjk' - ]); + assert.deepStrictEqual(match(['abcdecdhjk'], 'a****c**?**??*****'), ['abcdecdhjk']); + assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??***k'), ['abcdecdhjk']); + assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??***k**'), ['abcdecdhjk']); + assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??k'), ['abcdecdhjk']); + assert.deepStrictEqual(match(['abcdecdhjk'], 'a**?**cd**?**??k***'), ['abcdecdhjk']); + assert.deepStrictEqual(match(['abcdecdhjk'], 'a*cd**?**??k'), ['abcdecdhjk']); }); it('should match backslashes with question marks when not on windows', () => { @@ -103,32 +54,17 @@ describe('qmarks and stars', () => { assert.deepStrictEqual(match(fixtures, '?'), ['a']); assert.deepStrictEqual(match(fixtures, '??'), ['aa', 'ab']); assert.deepStrictEqual(match(fixtures, '???'), ['aaa']); - assert.deepStrictEqual( - match(['a/', '/a/', '/a/b/', '/a/b/c/', '/a/b/c/d/'], '??'), - [] - ); + assert.deepStrictEqual(match(['a/', '/a/', '/a/b/', '/a/b/c/', '/a/b/c/d/'], '??'), []); assert.deepStrictEqual(match(['a/b/c.md'], 'a/?/c.md'), ['a/b/c.md']); assert.deepStrictEqual(match(['a/bb/c.md'], 'a/?/c.md'), []); assert.deepStrictEqual(match(['a/bb/c.md'], 'a/??/c.md'), ['a/bb/c.md']); assert.deepStrictEqual(match(['a/bbb/c.md'], 'a/??/c.md'), []); assert.deepStrictEqual(match(['a/bbb/c.md'], 'a/???/c.md'), ['a/bbb/c.md']); - assert.deepStrictEqual(match(['a/bbbb/c.md'], 'a/????/c.md'), [ - 'a/bbbb/c.md' - ]); + assert.deepStrictEqual(match(['a/bbbb/c.md'], 'a/????/c.md'), ['a/bbbb/c.md']); }); it('should not match slashes question marks', () => { - const fixtures = [ - '//', - 'a/', - '/a', - '/a/', - 'aa', - '/aa', - 'a/a', - 'aaa', - '/aaa' - ]; + const fixtures = ['//', 'a/', '/a', '/a/', 'aa', '/aa', 'a/a', 'aaa', '/aaa']; assert.deepStrictEqual(match(fixtures, '/?'), ['/a']); assert.deepStrictEqual(match(fixtures, '/??'), ['/aa']); assert.deepStrictEqual(match(fixtures, '/???'), ['/aaa']); @@ -142,41 +78,20 @@ describe('qmarks and stars', () => { }); it('should support question marks and stars between slashes', () => { - assert.deepStrictEqual(match(['a/b.bb/c/d/efgh.ijk/e'], 'a/*/?/**/e'), [ - 'a/b.bb/c/d/efgh.ijk/e' - ]); + assert.deepStrictEqual(match(['a/b.bb/c/d/efgh.ijk/e'], 'a/*/?/**/e'), ['a/b.bb/c/d/efgh.ijk/e']); assert.deepStrictEqual(match(['a/b/c/d/e'], 'a/?/c/?/*/e'), []); - assert.deepStrictEqual(match(['a/b/c/d/e/e'], 'a/?/c/?/*/e'), [ - 'a/b/c/d/e/e' - ]); - assert.deepStrictEqual(match(['a/b/c/d/efgh.ijk/e'], 'a/*/?/**/e'), [ - 'a/b/c/d/efgh.ijk/e' - ]); - assert.deepStrictEqual(match(['a/b/c/d/efghijk/e'], 'a/*/?/**/e'), [ - 'a/b/c/d/efghijk/e' - ]); - assert.deepStrictEqual(match(['a/b/c/d/efghijk/e'], 'a/?/**/e'), [ - 'a/b/c/d/efghijk/e' - ]); - assert.deepStrictEqual(match(['a/b/c/d/efghijk/e'], 'a/?/c/?/*/e'), [ - 'a/b/c/d/efghijk/e' - ]); + assert.deepStrictEqual(match(['a/b/c/d/e/e'], 'a/?/c/?/*/e'), ['a/b/c/d/e/e']); + assert.deepStrictEqual(match(['a/b/c/d/efgh.ijk/e'], 'a/*/?/**/e'), ['a/b/c/d/efgh.ijk/e']); + assert.deepStrictEqual(match(['a/b/c/d/efghijk/e'], 'a/*/?/**/e'), ['a/b/c/d/efghijk/e']); + assert.deepStrictEqual(match(['a/b/c/d/efghijk/e'], 'a/?/**/e'), ['a/b/c/d/efghijk/e']); + assert.deepStrictEqual(match(['a/b/c/d/efghijk/e'], 'a/?/c/?/*/e'), ['a/b/c/d/efghijk/e']); assert.deepStrictEqual(match(['a/bb/e'], 'a/?/**/e'), []); assert.deepStrictEqual(match(['a/bb/e'], 'a/?/e'), []); - assert.deepStrictEqual(match(['a/bbb/c/d/efgh.ijk/e'], 'a/*/?/**/e'), [ - 'a/bbb/c/d/efgh.ijk/e' - ]); + assert.deepStrictEqual(match(['a/bbb/c/d/efgh.ijk/e'], 'a/*/?/**/e'), ['a/bbb/c/d/efgh.ijk/e']); }); it('should match no more than one character between slashes', () => { - const fixtures = [ - 'a/a', - 'a/a/a', - 'a/aa/a', - 'a/aaa/a', - 'a/aaaa/a', - 'a/aaaaa/a' - ]; + const fixtures = ['a/a', 'a/a/a', 'a/aa/a', 'a/aaa/a', 'a/aaaa/a', 'a/aaaaa/a']; assert.deepStrictEqual(match(fixtures, '?/?'), ['a/a']); assert.deepStrictEqual(match(fixtures, '?/???/?'), ['a/aaa/a']); assert.deepStrictEqual(match(fixtures, '?/????/?'), ['a/aaaa/a']); @@ -190,18 +105,7 @@ describe('qmarks and stars', () => { }); it('should not match non-leading dots with question marks', () => { - const fixtures = [ - '.', - '.a', - 'a', - 'aa', - 'a.a', - 'aa.a', - 'aaa', - 'aaa.a', - 'aaaa.a', - 'aaaaa' - ]; + const fixtures = ['.', '.a', 'a', 'aa', 'a.a', 'aa.a', 'aaa', 'aaa.a', 'aaaa.a', 'aaaaa']; assert.deepStrictEqual(match(fixtures, '?'), ['a']); assert.deepStrictEqual(match(fixtures, '.?'), ['.a']); assert.deepStrictEqual(match(fixtures, '?a'), ['aa']); @@ -214,18 +118,7 @@ describe('qmarks and stars', () => { }); it('should match non-leading dots with question marks when options.dot is true', () => { - const fixtures = [ - '.', - '.a', - 'a', - 'aa', - 'a.a', - 'aa.a', - '.aa', - 'aaa.a', - 'aaaa.a', - 'aaaaa' - ]; + const fixtures = ['.', '.a', 'a', 'aa', 'a.a', 'aa.a', '.aa', 'aaa.a', 'aaaa.a', 'aaaaa']; const opts = { dot: true }; assert.deepStrictEqual(match(fixtures, '?', opts), ['.', 'a']); assert.deepStrictEqual(match(fixtures, '.?', opts), ['.a']); diff --git a/test/slashes-posix.js b/test/slashes-posix.js index d8d2df5c..cd4d0b9f 100644 --- a/test/slashes-posix.js +++ b/test/slashes-posix.js @@ -1151,9 +1151,7 @@ describe('slash handling - posix', () => { const format = str => str.replace(/^\.\//, ''); assert(!isMatch('./a/b/c/d/e/z/c.md', './a/**/j/**/z/*.md', { format })); assert(!isMatch('./a/b/c/j/e/z/c.txt', './a/**/j/**/z/*.md', { format })); - assert( - isMatch('./a/b/c/d/e/j/n/p/o/z/c.md', './a/**/j/**/z/*.md', { format }) - ); + assert(isMatch('./a/b/c/d/e/j/n/p/o/z/c.md', './a/**/j/**/z/*.md', { format })); assert(isMatch('./a/b/c/d/e/z/c.md', './a/**/z/*.md', { format })); assert(isMatch('./a/b/c/j/e/z/c.md', './a/**/j/**/z/*.md', { format })); assert(isMatch('./a/b/z/.a', './a/**/z/.a', { format })); @@ -1200,55 +1198,14 @@ describe('slash handling - posix', () => { assert(!isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/*')); assert(!isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/*')); assert(isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/**')); - assert( - !isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/**', { - noglobstar: true - }) - ); + assert(!isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/**', { noglobstar: true })); assert(isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/**')); - assert( - isMatch( - 'https://foo.com/bar/baz/app.min.js', - 'https://foo.com/**/app.min.js' - ) - ); - assert( - isMatch( - 'https://foo.com/bar/baz/app.min.js', - 'https://foo.com/*/*/app.min.js' - ) - ); - assert( - isMatch( - 'https://foo.com/bar/baz/app.min.js', - 'https://foo.com/*/*/app.min.js', - { noglobstar: true } - ) - ); - assert( - !isMatch( - 'https://foo.com/bar/baz/app.min.js', - 'https://foo.com/*/app.min.js' - ) - ); - assert( - !isMatch( - 'https://foo.com/bar/baz/app.min.js', - 'https://foo.com/*/app.min.js' - ) - ); - assert( - isMatch( - 'https://foo.com/bar/baz/app.min.js', - 'https://foo.com/**/app.min.js' - ) - ); - assert( - !isMatch( - 'https://foo.com/bar/baz/app.min.js', - 'https://foo.com/**/app.min.js', - { noglobstar: true } - ) - ); + assert(isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/**/app.min.js')); + assert(isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/*/*/app.min.js')); + assert(isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/*/*/app.min.js', { noglobstar: true })); + assert(!isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/*/app.min.js')); + assert(!isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/*/app.min.js')); + assert(isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/**/app.min.js')); + assert(!isMatch('https://foo.com/bar/baz/app.min.js', 'https://foo.com/**/app.min.js', { noglobstar: true })); }); }); diff --git a/test/slashes-windows.js b/test/slashes-windows.js index 584fd438..1e109948 100644 --- a/test/slashes-windows.js +++ b/test/slashes-windows.js @@ -6,11 +6,7 @@ const { isMatch, makeRe } = require('..'); describe('slash handling - windows', () => { it('should match absolute windows paths with regex from makeRe', () => { const regex = makeRe('**/path/**', { windows: true }); - assert( - regex.test('C:\\Users\\user\\Projects\\project\\path\\image.jpg', { - windows: true - }) - ); + assert(regex.test('C:\\Users\\user\\Projects\\project\\path\\image.jpg', { windows: true })); }); it('should match windows path separators with a string literal', () => { diff --git a/test/special-characters.js b/test/special-characters.js index 579643cf..c6958a51 100644 --- a/test/special-characters.js +++ b/test/special-characters.js @@ -270,9 +270,7 @@ describe('special characters', () => { assert(isMatch('\\\\foo/bar', '//*/*', { windows: true })); assert(isMatch('\\\\unc\\admin$', '**', { windows: true })); assert(isMatch('\\\\unc\\admin$', '//*/*$', { windows: true })); - assert( - isMatch('\\\\unc\\admin$\\system32', '//*/*$/*32', { windows: true }) - ); + assert(isMatch('\\\\unc\\admin$\\system32', '//*/*$/*32', { windows: true })); assert(isMatch('\\\\unc\\share\\foo', '//u*/s*/f*', { windows: true })); assert(isMatch('foo\\bar\\baz', 'f*/*/*', { windows: true })); }); @@ -286,16 +284,9 @@ describe('special characters', () => { assert(isMatch('\\\\foo/bar', '//*/*', { windows: true })); assert(isMatch('\\\\unc\\admin$', '//**', { windows: true })); assert(isMatch('\\\\unc\\admin$', '//*/*$', { windows: true })); - assert( - isMatch('\\\\unc\\admin$\\system32', '//*/*$/*32', { windows: true }) - ); + assert(isMatch('\\\\unc\\admin$\\system32', '//*/*$/*32', { windows: true })); assert(isMatch('\\\\unc\\share\\foo', '//u*/s*/f*', { windows: true })); - assert( - isMatch('\\\\\\\\\\\\unc\\share\\foo', '/\\{1,\\}u*/s*/f*', { - windows: true, - unescape: true - }) - ); + assert(isMatch('\\\\\\\\\\\\unc\\share\\foo', '/\\{1,\\}u*/s*/f*', { windows: true, unescape: true })); assert(isMatch('foo\\bar\\baz', 'f*/*/*', { windows: true })); assert(isMatch('//*:/**', '**')); assert(!isMatch('//server/file', '//*')); diff --git a/test/wildmat.js b/test/wildmat.js index 5f39d71c..c61195e5 100644 --- a/test/wildmat.js +++ b/test/wildmat.js @@ -20,26 +20,11 @@ describe('Wildmat (git) tests', () => { }); it('should support recursion', () => { - assert( - !isMatch( - '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1', - '-*-*-*-*-*-*-12-*-*-*-m-*-*-*' - ) - ); - assert( - !isMatch( - '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1', - '-*-*-*-*-*-*-12-*-*-*-m-*-*-*' - ) - ); + assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*')); + assert(!isMatch('-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*')); assert(!isMatch('ab/cXd/efXg/hi', '*X*i')); assert(!isMatch('ab/cXd/efXg/hi', '*Xg*i')); - assert( - !isMatch( - 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz', - '**/*a*b*g*n*t' - ) - ); + assert(!isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz', '**/*a*b*g*n*t')); assert(!isMatch('foo', '*/*/*')); assert(!isMatch('foo', 'fo')); assert(!isMatch('foo/bar', '*/*/*')); @@ -52,23 +37,11 @@ describe('Wildmat (git) tests', () => { assert(!isMatch('foo/bba/arr', 'foo/**z')); assert(!isMatch('foo/bba/arr', 'foo/*arr')); assert(!isMatch('foo/bba/arr', 'foo/*z')); - assert( - !isMatch( - 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1', - 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*' - ) - ); - assert( - isMatch( - '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1', - '-*-*-*-*-*-*-12-*-*-*-m-*-*-*' - ) - ); + assert(!isMatch('XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1', 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*')); + assert(isMatch('-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1', '-*-*-*-*-*-*-12-*-*-*-m-*-*-*')); assert(isMatch('ab/cXd/efXg/hi', '**/*X*/**/*i')); assert(isMatch('ab/cXd/efXg/hi', '*/*X*/*/*i')); - assert( - isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt', '**/*a*b*g*n*t') - ); + assert(isMatch('abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt', '**/*a*b*g*n*t')); assert(isMatch('abcXdefXghi', '*X*i')); assert(isMatch('foo', 'foo')); assert(isMatch('foo/bar', 'foo/*')); From e2991d3e3be0eccaa818877cbc52d4b930c26401 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Thu, 19 Mar 2026 22:26:21 +0100 Subject: [PATCH 6/6] Add node 24 and 25 --- .github/workflows/test.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 926dcc8a..18f19fda 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,6 @@ name: Tests -on: - push: - branches: - - master - pull_request: +on: [push, pull_request] env: FORCE_COLOR: 2 @@ -17,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - node: [12, 14, 16, 18, 20, 22, 23] + node: [12, 14, 16, 18, 20, 22, 24, 25] os: [ubuntu-latest, windows-latest, macos-latest] exclude: - os: macos-latest