it('should match escaped characters', function() { assert(!mm.isMatch('', '\\')); assert(!mm.isMatch('XXX/\\', '[A-Z]+/\\')); assert(mm.isMatch('\\', '\\')); if (isWindows()) { assert(!mm.isMatch('XXX/\\', '[A-Z]+/\\\\')); } else { assert(mm.isMatch('XXX/\\', '[A-Z]+/\\\\')); } assert(mm.isMatch('[ab]', '\\[ab]')); assert(mm.isMatch('[ab]', '[\\[:]ab]')); });
function matcher() { if (isWindows()) return; return bash.apply(null, arguments); }
describe('slashes', function() { it('should match forward slashes', function() { assert(nm.isMatch('/', '/')); }); it('should match backslashes', function() { assert(nm.isMatch('\\', '[\\\\/]')); assert(nm.isMatch('\\', '[\\\\/]+')); assert(nm.isMatch('\\\\', '[\\\\/]+')); assert(nm.isMatch('\\\\\\', '[\\\\/]+')); if (isWindows()) { nm(['\\'], '[\\\\/]', ['/']); nm(['\\', '\\\\', '\\\\\\'], '[\\\\/]+', ['/']); } else { nm(['\\'], '[\\\\/]', ['\\']); nm(['\\', '\\\\', '\\\\\\'], '[\\\\/]+', ['\\', '\\\\', '\\\\\\']); } var sep = path.sep; path.sep = '\\'; assert(nm.isMatch('\\', '[\\\\/]')); assert(nm.isMatch('\\', '[\\\\/]+')); assert(nm.isMatch('\\\\', '[\\\\/]+')); assert(nm.isMatch('\\\\\\', '[\\\\/]+')); nm(['\\'], '[\\\\/]', ['/']); nm(['\\', '\\\\', '\\\\\\'], '[\\\\/]+', ['/']); path.sep = sep; }); });
mm(['man/man1/bash.1'], '*/man*/bash.*', ['man/man1/bash.1']); if (isWindows()) {
describe('minimatch parity:', function() { describe('backslashes', function() { it('should match literal backslashes', function() { if (isWindows()) { mm.match(['\\'], '\\', ['/']); } else {
describe('.makeRe', function() { if (isWindows() || isTravis) { console.log('these tests use bash to test for bash parity. since bash does not work on most versions of windows, these tests are skipped on windows'); return; } else if (!isWindows() && !isTravis) { actual = nmRes === nm.bash.isMatch(fixture, pattern); } else { } else if (/^\?/.test(pattern) || /^\.\//.test(fixture)) { actual = true; } else if (!isWindows() && !isTravis) { actual = nmRes === nm.bash.isMatch(fixture, pattern, {dot: true}); } else { } else if (/^\?/.test(pattern) || /^\!/.test(fixture)) { actual = true; } else if (!isWindows() && !isTravis) { actual = nmRes === nm.bash.isMatch(fixture, pattern, {nonegate: true}); } else {
nm(['d', 'e', '!ab', '!abc', 'a!b', '\\!a'], '!!!!a*', ['a!b']); nm(['d', 'e', '!ab', '!abc', 'a!b', '\\!a'], '!!!!!!a*', ['a!b']); if (!isWindows()) { nm(['d', 'e', '!ab', '!abc', 'a!b', '\\!a'], '!!!!!a*', ['d', 'e', '!ab', '!abc', '\\!a']); nm(['d', 'e', '!ab', '!abc', 'a!b', '\\!a'], '!a*', ['d', 'e', '!ab', '!abc', '\\!a']);
describe('.isMatch', function() { if (isWindows() || isTravis) { console.log('these tests use bash to test for bash parity. since bash does not work on most versions of windows, these tests are skipped on windows'); return; } else if (/^\?/.test(pattern)) { actual = true; } else if (!isWindows() && !isTravis) { actual = nmRes === nm.bash.isMatch(fixture, pattern); } else { } else if (/^\?/.test(pattern) || /^\.\//.test(fixture)) { actual = true; } else if (!isWindows() && !isTravis) { actual = nmRes === nm.bash.isMatch(fixture, pattern, {dot: true}); } else { } else if (/^\?/.test(pattern) || /^\!/.test(fixture)) { actual = true; } else if (!isWindows() && !isTravis) { actual = nmRes === nm.bash.isMatch(fixture, pattern); } else {
it('should use escaped characters as literals:', function() { if (isWindows()) { mm(fixtures, '\\*', {nonull: true}, ['*', '/*']); mm(fixtures, '\\*', {nonull: true, unescape: true}, ['*']);