diff --git a/package-lock.json b/package-lock.json index 5b89bb48..ef0254c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "minimatch", - "version": "7.1.0", + "version": "7.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "minimatch", - "version": "7.1.0", + "version": "7.1.1", "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" diff --git a/package.json b/package.json index 0dc7f0c0..cff3ad30 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Isaac Z. Schlueter (http://blog.izs.me)", "name": "minimatch", "description": "a glob matcher in javascript", - "version": "7.1.0", + "version": "7.1.1", "repository": { "type": "git", "url": "git://github.com/isaacs/minimatch.git" diff --git a/src/index.ts b/src/index.ts index 8c7f3bd6..03bc74cf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -495,9 +495,13 @@ export class Minimatch { i-- } } - if (parts[0] === '.') { + if ( + parts[0] === '.' && + parts.length === 2 && + (parts[1] === '.' || parts[1] === '') + ) { didSomething = true - parts.shift() + parts.pop() } } @@ -577,9 +581,13 @@ export class Minimatch { i-- } } - if (parts[0] === '.') { + if ( + parts[0] === '.' && + parts.length === 2 && + (parts[1] === '.' || parts[1] === '') + ) { didSomething = true - parts.shift() + parts.pop() } } @@ -589,7 +597,9 @@ export class Minimatch { const p = parts[dd - 1] if (p && p !== '.' && p !== '..' && p !== '**') { didSomething = true - parts.splice(dd - 1, 2) + const needDot = dd === 1 && parts[dd + 1] === '**' + const splin = needDot ? ['.'] : [] + parts.splice(dd - 1, 2, ...splin) if (parts.length === 0) parts.push('') dd -= 2 } diff --git a/tap-snapshots/test/optimization-level-2.ts.test.cjs b/tap-snapshots/test/optimization-level-2.ts.test.cjs index f20a40ce..5daea2b8 100644 --- a/tap-snapshots/test/optimization-level-2.ts.test.cjs +++ b/tap-snapshots/test/optimization-level-2.ts.test.cjs @@ -630,7 +630,7 @@ exports[`test/optimization-level-2.ts TAP basic tests > makeRe {a,*(b|{c,d})} 1` ` exports[`test/optimization-level-2.ts TAP basic tests > makeRe {c*,./c*} 1`] = ` -/^(?:(?=.)c[^/]*?)$/ +/^(?:(?=.)c[^/]*?|\\.\\/(?=.)c[^/]*?)$/ ` exports[`test/optimization-level-2.ts TAP basic tests > makeRe Å 1`] = ` @@ -665,6 +665,30 @@ exports[`test/optimization-level-2.ts TAP basic tests > makeRe å 4`] = ` /^(?:å)$/ ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ** > defaults 1`] = ` +Array [ + Array [ + "**", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ** > multislash 1`] = ` +Array [ + Array [ + "**", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ** > no globstar 1`] = ` +Array [ + Array [ + "*", + ], +] +` + exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux **/.. > defaults 1`] = ` Array [ Array [ @@ -732,6 +756,19 @@ Array [ ] ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux **/../x > defaults 2`] = ` +Array [ + Array [ + "..", + "x", + ], + Array [ + "**", + "x", + ], +] +` + exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux **/../x > multislash 1`] = ` Array [ Array [ @@ -745,6 +782,19 @@ Array [ ] ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux **/../x > multislash 2`] = ` +Array [ + Array [ + "..", + "x", + ], + Array [ + "**", + "x", + ], +] +` + exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux **/../x > no globstar 1`] = ` Array [ Array [ @@ -753,6 +803,250 @@ Array [ ] ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux **/../x > no globstar 2`] = ` +Array [ + Array [ + "x", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux */../** > defaults 1`] = ` +Array [ + Array [ + ".", + "**", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux */../** > multislash 1`] = ` +Array [ + Array [ + ".", + "**", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux */../** > no globstar 1`] = ` +Array [ + Array [ + "*", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./ > defaults 1`] = ` +Array [ + Array [ + ".", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./ > multislash 1`] = ` +Array [ + Array [ + ".", + "", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./ > no globstar 1`] = ` +Array [ + Array [ + ".", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./** > defaults 1`] = ` +Array [ + Array [ + ".", + "**", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./** > multislash 1`] = ` +Array [ + Array [ + ".", + "**", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./** > no globstar 1`] = ` +Array [ + Array [ + ".", + "*", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./**/ > defaults 1`] = ` +Array [ + Array [ + ".", + "**", + "", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./**/ > multislash 1`] = ` +Array [ + Array [ + ".", + "**", + "", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./**/ > no globstar 1`] = ` +Array [ + Array [ + ".", + "*", + "", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./**/../x > defaults 1`] = ` +Array [ + Array [ + ".", + "..", + "x", + ], + Array [ + ".", + "**", + "x", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./**/../x > multislash 1`] = ` +Array [ + Array [ + ".", + "..", + "x", + ], + Array [ + ".", + "**", + "x", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./**/../x > no globstar 1`] = ` +Array [ + Array [ + ".", + "x", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./**/x > defaults 1`] = ` +Array [ + Array [ + ".", + "**", + "x", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./**/x > multislash 1`] = ` +Array [ + Array [ + ".", + "**", + "x", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./**/x > no globstar 1`] = ` +Array [ + Array [ + ".", + "*", + "x", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./././. > defaults 1`] = ` +Array [ + Array [ + ".", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./././. > multislash 1`] = ` +Array [ + Array [ + ".", + ".", + ".", + ".", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./././. > no globstar 1`] = ` +Array [ + Array [ + ".", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./x/.././///.//./ > defaults 1`] = ` +Array [ + Array [ + ".", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./x/.././///.//./ > multislash 1`] = ` +Array [ + Array [ + ".", + ".", + "", + "", + "", + ".", + "", + ".", + "", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux ./x/.././///.//./ > no globstar 1`] = ` +Array [ + Array [ + ".", + ], +] +` + exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux //host/share > defaults 1`] = ` Array [ Array [ @@ -952,147 +1246,369 @@ Array [ Array [ "a", "b", - "d", + "d", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{**/,}*/b > defaults 1`] = ` +Array [ + Array [ + "a", + "**", + "*", + "b", + ], + Array [ + "a", + "*", + "b", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{**/,}*/b > multislash 1`] = ` +Array [ + Array [ + "a", + "**", + "*", + "b", + ], + Array [ + "a", + "*", + "b", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{**/,}*/b > no globstar 1`] = ` +Array [ + Array [ + "a", + "*", + "*", + "b", + ], + Array [ + "a", + "*", + "b", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{**/,}b > defaults 1`] = ` +Array [ + Array [ + "a", + "**", + "b", + ], + Array [ + "a", + "b", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{**/,}b > multislash 1`] = ` +Array [ + Array [ + "a", + "**", + "b", + ], + Array [ + "a", + "b", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{**/,}b > no globstar 1`] = ` +Array [ + Array [ + "a", + "*", + "b", + ], + Array [ + "a", + "b", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*,.c}/b > defaults 1`] = ` +Array [ + Array [ + "a", + "*", + "b", + ], + Array [ + "a", + ".c", + "b", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*,.c}/b > multislash 1`] = ` +Array [ + Array [ + "a", + "*", + "b", + ], + Array [ + "a", + ".c", + "b", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*,.c}/b > no globstar 1`] = ` +Array [ + Array [ + "a", + "*", + "b", + ], + Array [ + "a", + ".c", + "b", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*,c}/b > defaults 1`] = ` +Array [ + Array [ + "a", + "*", + "b", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*,c}/b > multislash 1`] = ` +Array [ + Array [ + "a", + "*", + "b", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*,c}/b > no globstar 1`] = ` +Array [ + Array [ + "a", + "*", + "b", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*/b/d,c/b/*}/e > defaults 1`] = ` +Array [ + Array [ + "a", + "*", + "b", + "d", + "e", + ], + Array [ + "a", + "c", + "b", + "*", + "e", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*/b/d,c/b/*}/e > multislash 1`] = ` +Array [ + Array [ + "a", + "*", + "b", + "d", + "e", + ], + Array [ + "a", + "c", + "b", + "*", + "e", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*/b/d,c/b/*}/e > no globstar 1`] = ` +Array [ + Array [ + "a", + "*", + "b", + "d", + "e", + ], + Array [ + "a", + "c", + "b", + "*", + "e", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{**/,}*/b > defaults 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{,**/}*/b > defaults 1`] = ` Array [ Array [ "a", - "**", "*", "b", ], Array [ "a", + "**", "*", "b", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{**/,}*/b > multislash 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{,**/}*/b > multislash 1`] = ` Array [ Array [ "a", - "**", "*", "b", ], Array [ "a", + "**", "*", "b", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{**/,}*/b > no globstar 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{,**/}*/b > no globstar 1`] = ` Array [ Array [ "a", "*", - "*", "b", ], Array [ "a", "*", + "*", "b", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{**/,}b > defaults 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{,**/}b > defaults 1`] = ` Array [ Array [ "a", - "**", "b", ], Array [ "a", + "**", "b", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{**/,}b > multislash 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{,**/}b > multislash 1`] = ` Array [ Array [ "a", - "**", "b", ], Array [ "a", + "**", "b", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{**/,}b > no globstar 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{,**/}b > no globstar 1`] = ` Array [ Array [ "a", - "*", "b", ], Array [ "a", + "*", "b", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*,.c}/b > defaults 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{.c,*}/b > defaults 1`] = ` Array [ Array [ "a", - "*", + ".c", "b", ], Array [ "a", - ".c", + "*", "b", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*,.c}/b > multislash 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{.c,*}/b > multislash 1`] = ` Array [ Array [ "a", - "*", + ".c", "b", ], Array [ "a", - ".c", + "*", "b", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*,.c}/b > no globstar 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{.c,*}/b > no globstar 1`] = ` Array [ Array [ "a", - "*", + ".c", "b", ], Array [ "a", - ".c", + "*", "b", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*,c}/b > defaults 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c,*}/b > defaults 1`] = ` Array [ Array [ "a", @@ -1102,7 +1618,7 @@ Array [ ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*,c}/b > multislash 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c,*}/b > multislash 1`] = ` Array [ Array [ "a", @@ -1112,7 +1628,7 @@ Array [ ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*,c}/b > no globstar 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c,*}/b > no globstar 1`] = ` Array [ Array [ "a", @@ -1122,8 +1638,15 @@ Array [ ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*/b/d,c/b/*}/e > defaults 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c/b/*,*/b/d}/e > defaults 1`] = ` Array [ + Array [ + "a", + "c", + "b", + "*", + "e", + ], Array [ "a", "*", @@ -1131,6 +1654,11 @@ Array [ "d", "e", ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c/b/*,*/b/d}/e > multislash 1`] = ` +Array [ Array [ "a", "c", @@ -1138,11 +1666,25 @@ Array [ "*", "e", ], + Array [ + "a", + "*", + "b", + "d", + "e", + ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*/b/d,c/b/*}/e > multislash 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c/b/*,*/b/d}/e > no globstar 1`] = ` Array [ + Array [ + "a", + "c", + "b", + "*", + "e", + ], Array [ "a", "*", @@ -1150,9 +1692,14 @@ Array [ "d", "e", ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c/b/d,*/b/*}/e > defaults 1`] = ` +Array [ Array [ "a", - "c", + "*", "b", "*", "e", @@ -1160,18 +1707,23 @@ Array [ ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{*/b/d,c/b/*}/e > no globstar 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c/b/d,*/b/*}/e > multislash 1`] = ` Array [ Array [ "a", "*", "b", - "d", + "*", "e", ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c/b/d,*/b/*}/e > no globstar 1`] = ` +Array [ Array [ "a", - "c", + "*", "b", "*", "e", @@ -1179,39 +1731,35 @@ Array [ ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{,**/}*/b > defaults 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux {a/**/b,a/b} > defaults 1`] = ` Array [ Array [ "a", - "*", + "**", "b", ], Array [ "a", - "**", - "*", "b", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{,**/}*/b > multislash 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux {a/**/b,a/b} > multislash 1`] = ` Array [ Array [ "a", - "*", + "**", "b", ], Array [ "a", - "**", - "*", "b", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{,**/}*/b > no globstar 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux {a/**/b,a/b} > no globstar 1`] = ` Array [ Array [ "a", @@ -1220,349 +1768,389 @@ Array [ ], Array [ "a", - "*", - "*", "b", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{,**/}b > defaults 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ** > defaults 1`] = ` Array [ Array [ - "a", - "b", + "**", ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ** > multislash 1`] = ` +Array [ Array [ - "a", "**", - "b", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{,**/}b > multislash 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ** > no globstar 1`] = ` Array [ Array [ - "a", - "b", + "*", ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/.. > defaults 1`] = ` +Array [ Array [ - "a", "**", - "b", + "..", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{,**/}b > no globstar 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/.. > multislash 1`] = ` Array [ Array [ - "a", - "b", + "**", + "..", ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/.. > no globstar 1`] = ` +Array [ Array [ - "a", - "*", - "b", + "", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{.c,*}/b > defaults 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/../ > defaults 1`] = ` Array [ Array [ - "a", - ".c", - "b", + "**", + "..", + "", ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/../ > multislash 1`] = ` +Array [ Array [ - "a", - "*", - "b", + "**", + "..", + "", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{.c,*}/b > multislash 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/../ > no globstar 1`] = ` Array [ Array [ - "a", - ".c", - "b", + "", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/../x > defaults 1`] = ` +Array [ + Array [ + "..", + "x", ], Array [ - "a", - "*", - "b", + "**", + "x", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{.c,*}/b > no globstar 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/../x > defaults 2`] = ` Array [ Array [ - "a", - ".c", - "b", + "..", + "x", ], Array [ - "a", - "*", - "b", + "**", + "x", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c,*}/b > defaults 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/../x > multislash 1`] = ` Array [ Array [ - "a", - "*", - "b", + "..", + "x", + ], + Array [ + "**", + "x", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c,*}/b > multislash 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/../x > multislash 2`] = ` Array [ Array [ - "a", - "*", - "b", + "..", + "x", + ], + Array [ + "**", + "x", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c,*}/b > no globstar 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/../x > no globstar 1`] = ` Array [ Array [ - "a", - "*", - "b", + "x", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c/b/*,*/b/d}/e > defaults 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/../x > no globstar 2`] = ` Array [ Array [ - "a", - "c", - "b", - "*", - "e", + "x", + ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 */../** > defaults 1`] = ` +Array [ + Array [ + ".", + "**", ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 */../** > multislash 1`] = ` +Array [ Array [ - "a", - "*", - "b", - "d", - "e", + ".", + "**", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c/b/*,*/b/d}/e > multislash 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 */../** > no globstar 1`] = ` Array [ Array [ - "a", - "c", - "b", "*", - "e", ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./ > defaults 1`] = ` +Array [ Array [ - "a", - "*", - "b", - "d", - "e", + ".", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c/b/*,*/b/d}/e > no globstar 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./ > multislash 1`] = ` Array [ Array [ - "a", - "c", - "b", - "*", - "e", + ".", + "", ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./ > no globstar 1`] = ` +Array [ Array [ - "a", - "*", - "b", - "d", - "e", + ".", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c/b/d,*/b/*}/e > defaults 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./** > defaults 1`] = ` Array [ Array [ - "a", - "*", - "b", - "*", - "e", + ".", + "**", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c/b/d,*/b/*}/e > multislash 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./** > multislash 1`] = ` Array [ Array [ - "a", - "*", - "b", - "*", - "e", + ".", + "**", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux a/{c/b/d,*/b/*}/e > no globstar 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./** > no globstar 1`] = ` Array [ Array [ - "a", - "*", - "b", + ".", "*", - "e", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux {a/**/b,a/b} > defaults 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./**/ > defaults 1`] = ` Array [ Array [ - "a", + ".", "**", - "b", - ], - Array [ - "a", - "b", + "", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux {a/**/b,a/b} > multislash 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./**/ > multislash 1`] = ` Array [ Array [ - "a", + ".", "**", - "b", + "", ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./**/ > no globstar 1`] = ` +Array [ Array [ - "a", - "b", + ".", + "*", + "", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization linux {a/**/b,a/b} > no globstar 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./**/../x > defaults 1`] = ` Array [ Array [ - "a", - "*", - "b", + ".", + "..", + "x", ], Array [ - "a", - "b", + ".", + "**", + "x", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/.. > defaults 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./**/../x > multislash 1`] = ` Array [ Array [ - "**", + ".", "..", + "x", + ], + Array [ + ".", + "**", + "x", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/.. > multislash 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./**/../x > no globstar 1`] = ` Array [ Array [ - "**", - "..", + ".", + "x", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/.. > no globstar 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./**/x > defaults 1`] = ` Array [ Array [ - "", + ".", + "**", + "x", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/../ > defaults 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./**/x > multislash 1`] = ` Array [ Array [ + ".", "**", - "..", - "", + "x", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/../ > multislash 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./**/x > no globstar 1`] = ` Array [ Array [ - "**", - "..", - "", + ".", + "*", + "x", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/../ > no globstar 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./././. > defaults 1`] = ` Array [ Array [ - "", + ".", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/../x > defaults 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./././. > multislash 1`] = ` Array [ Array [ - "..", - "x", + ".", + ".", + ".", + ".", ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./././. > no globstar 1`] = ` +Array [ Array [ - "**", - "x", + ".", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/../x > multislash 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./x/.././///.//./ > defaults 1`] = ` Array [ Array [ - "..", - "x", + ".", ], +] +` + +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./x/.././///.//./ > multislash 1`] = ` +Array [ Array [ - "**", - "x", + ".", + ".", + "", + "", + "", + ".", + "", + ".", + "", ], ] ` -exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 **/../x > no globstar 1`] = ` +exports[`test/optimization-level-2.ts TAP explicit pattern coalescing and optimization win32 ./x/.././///.//./ > no globstar 1`] = ` Array [ Array [ - "x", + ".", ], ] ` @@ -2307,7 +2895,7 @@ Array [ exports[`test/optimization-level-2.ts TAP optimize the file as well linux . > default 1`] = ` Array [ - "", + ".", ] ` @@ -2317,8 +2905,22 @@ Array [ ] ` +exports[`test/optimization-level-2.ts TAP optimize the file as well linux ./ > default 1`] = ` +Array [ + ".", +] +` + +exports[`test/optimization-level-2.ts TAP optimize the file as well linux ./ > multislash 1`] = ` +Array [ + ".", + "", +] +` + exports[`test/optimization-level-2.ts TAP optimize the file as well linux ./* > default 1`] = ` Array [ + ".", "*", ] ` @@ -2330,9 +2932,22 @@ Array [ ] ` +exports[`test/optimization-level-2.ts TAP optimize the file as well linux ./. > default 1`] = ` +Array [ + ".", +] +` + +exports[`test/optimization-level-2.ts TAP optimize the file as well linux ./. > multislash 1`] = ` +Array [ + ".", + ".", +] +` + exports[`test/optimization-level-2.ts TAP optimize the file as well linux ././. > default 1`] = ` Array [ - "", + ".", ] ` @@ -2344,6 +2959,28 @@ Array [ ] ` +exports[`test/optimization-level-2.ts TAP optimize the file as well linux .////././//././. > default 1`] = ` +Array [ + ".", +] +` + +exports[`test/optimization-level-2.ts TAP optimize the file as well linux .////././//././. > multislash 1`] = ` +Array [ + ".", + "", + "", + "", + ".", + ".", + "", + "", + ".", + ".", + ".", +] +` + exports[`test/optimization-level-2.ts TAP optimize the file as well linux / > default 1`] = ` Array [ "", @@ -2417,7 +3054,7 @@ Array [ exports[`test/optimization-level-2.ts TAP optimize the file as well win32 . > default 1`] = ` Array [ - "", + ".", ] ` @@ -2427,8 +3064,22 @@ Array [ ] ` +exports[`test/optimization-level-2.ts TAP optimize the file as well win32 ./ > default 1`] = ` +Array [ + ".", +] +` + +exports[`test/optimization-level-2.ts TAP optimize the file as well win32 ./ > multislash 1`] = ` +Array [ + ".", + "", +] +` + exports[`test/optimization-level-2.ts TAP optimize the file as well win32 ./* > default 1`] = ` Array [ + ".", "*", ] ` @@ -2440,9 +3091,22 @@ Array [ ] ` +exports[`test/optimization-level-2.ts TAP optimize the file as well win32 ./. > default 1`] = ` +Array [ + ".", +] +` + +exports[`test/optimization-level-2.ts TAP optimize the file as well win32 ./. > multislash 1`] = ` +Array [ + ".", + ".", +] +` + exports[`test/optimization-level-2.ts TAP optimize the file as well win32 ././. > default 1`] = ` Array [ - "", + ".", ] ` @@ -2454,6 +3118,28 @@ Array [ ] ` +exports[`test/optimization-level-2.ts TAP optimize the file as well win32 .////././//././. > default 1`] = ` +Array [ + ".", +] +` + +exports[`test/optimization-level-2.ts TAP optimize the file as well win32 .////././//././. > multislash 1`] = ` +Array [ + ".", + "", + "", + "", + ".", + ".", + "", + "", + ".", + ".", + ".", +] +` + exports[`test/optimization-level-2.ts TAP optimize the file as well win32 / > default 1`] = ` Array [ "", diff --git a/test/optimization-level-2.ts b/test/optimization-level-2.ts index b385549e..26d7d258 100644 --- a/test/optimization-level-2.ts +++ b/test/optimization-level-2.ts @@ -24,6 +24,12 @@ t.test('explicit pattern coalescing and optimization', t => { }) const patterns = [ + '**', + '**/../x', + './**', + './**/', + './**/x', + './**/../x', '//host/share', '//host/share/', '//host/share//s/o//me////.//path', @@ -44,6 +50,10 @@ t.test('explicit pattern coalescing and optimization', t => { 'a/{,**/}*/b', 'a/{**/,}b', 'a/{**/,}*/b', + './././.', + './', + './x/.././///.//./', + '*/../**', ] const exp = (p: string) => braceExpand(p).map(s => s.split('/')) @@ -69,6 +79,9 @@ t.test('optimize the file as well', t => { '', '.', '././.', + './.', + './', + './///././//././.', 'x/..', 'a/../b', ]