From 04d6b8841fcd5eaca45522c556185369a25efa13 Mon Sep 17 00:00:00 2001 From: Jared K. Smith Date: Sep 19 2017 20:46:11 +0000 Subject: Update to upstream 4.0.0 release --- diff --git a/.gitignore b/.gitignore index d970cbc..2f929fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /is-glob-2.0.1.tgz +/is-glob-4.0.0.tgz diff --git a/nodejs-is-glob.spec b/nodejs-is-glob.spec index cfdc29e..9e65c19 100644 --- a/nodejs-is-glob.spec +++ b/nodejs-is-glob.spec @@ -4,7 +4,7 @@ %global enable_tests 1 Name: nodejs-is-glob -Version: 2.0.1 +Version: 4.0.0 Release: 1%{?dist} Summary: Returns `true` if the given string looks like a glob pattern @@ -41,6 +41,7 @@ initialization time, and a better user experience. # setup the tests cp -p %{SOURCE1} . +%nodejs_fixdep is-extglob %build # nothing to do! @@ -71,5 +72,11 @@ ln -s %{nodejs_sitelib}/should node_modules/should %changelog +* Tue Sep 19 2017 Jared Smith - 4.0.0-1 +- Update to upstream 4.0.0 release + +* Wed Apr 19 2017 Jared Smith - 2.0.1-2 +- Relax dependency on npm(is-extglob) + * Tue Feb 9 2016 Jared Smith - 2.0.1-1 - Initial packaging diff --git a/sources b/sources index 5cb3d95..63f8f27 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -094686a7618e52db5f126af328da6aff is-glob-2.0.1.tgz +SHA512 (is-glob-4.0.0.tgz) = 20483d1d208a8ad594601464092ced926d8b7a76aff1ed389a5c478e2311836c3d071f364c52031036a6c1f9f4460c0580b34b4a465dd18253d82a2574df0a0b diff --git a/test.js b/test.js index a9e5feb..4fcae29 100644 --- a/test.js +++ b/test.js @@ -11,71 +11,298 @@ require('mocha'); var assert = require('assert'); var isGlob = require('./'); -describe('isGlob', function () { - describe('glob patterns', function () { - it('should return `true` if it is a glob pattern:', function () { +describe('isGlob', function() { + describe('glob patterns', function() { + it('should be true if it is a glob pattern:', function() { + assert(!isGlob('@.(?abc)'), 'invalid pattern'); assert(isGlob('*.js')); assert(isGlob('!*.js')); assert(isGlob('!foo')); assert(isGlob('!foo.js')); assert(isGlob('**/abc.js')); assert(isGlob('abc/*.js')); + assert(isGlob('@.(?:abc)')); + assert(isGlob('@.(?!abc)')); }); - it('should return `false` if it is not a string:', function () { + it('should not match escaped globs', function() { + assert(!isGlob('\\!\\*.js')); + assert(!isGlob('\\!foo')); + assert(!isGlob('\\!foo.js')); + assert(!isGlob('\\*(foo).js')); + assert(!isGlob('\\*.js')); + assert(!isGlob('\\*\\*/abc.js')); + assert(!isGlob('abc/\\*.js')); + }); + + it('should be false if the value is not a string:', function() { assert(!isGlob()); assert(!isGlob(null)); assert(!isGlob(['**/*.js'])); assert(!isGlob(['foo.js'])); }); - it('should return `false` if it is not a glob pattern:', function () { + it('should be false if it is not a glob pattern:', function() { + assert(!isGlob('')); + assert(!isGlob('~/abc')); + assert(!isGlob('~/abc')); + assert(!isGlob('~/(abc)')); + assert(!isGlob('+~(abc)')); assert(!isGlob('.')); + assert(!isGlob('@.(abc)')); assert(!isGlob('aa')); + assert(!isGlob('who?')); + assert(!isGlob('why!?')); + assert(!isGlob('where???')); + assert(!isGlob('abc!/def/!ghi.js')); assert(!isGlob('abc.js')); + assert(!isGlob('abc/def/!ghi.js')); assert(!isGlob('abc/def/ghi.js')); }); }); - describe('brace patterns', function () { - it('should return `true` if the path has brace characters:', function () { + describe('regex capture groups', function() { + it('should be true if the path has a regex capture group:', function() { + assert(isGlob('abc/(?!foo).js')); + assert(isGlob('abc/(?:foo).js')); + assert(isGlob('abc/(?=foo).js')); + assert(isGlob('abc/(a|b).js')); + assert(isGlob('abc/(a|b|c).js')); + assert(isGlob('abc/(foo bar)/*.js'), 'not a capture group but has a glob'); + }); + + it('should be true if the path has parens but is not a valid capture group', function() { + assert(!isGlob('abc/(?foo).js'), 'invalid capture group'); + assert(!isGlob('abc/(a b c).js'), 'unlikely to be a capture group'); + assert(!isGlob('abc/(ab).js'), 'unlikely to be a capture group'); + assert(!isGlob('abc/(abc).js'), 'unlikely to be a capture group'); + assert(!isGlob('abc/(foo bar).js'), 'unlikely to be a capture group'); + }); + + it('should be false if the capture group is imbalanced:', function() { + assert(!isGlob('abc/(?ab.js')); + assert(!isGlob('abc/(ab.js')); + assert(!isGlob('abc/(a|b.js')); + assert(!isGlob('abc/(a|b|c.js')); + }); + + it('should be false if the group is escaped:', function() { + assert(!isGlob('abc/\\(a|b).js')); + assert(!isGlob('abc/\\(a|b|c).js')); + }); + + it('should be true if glob chars exist and `options.strict` is false', function() { + assert(isGlob('$(abc)', {strict: false})); + assert(isGlob('&(abc)', {strict: false})); + assert(isGlob('? (abc)', {strict: false})); + assert(isGlob('?.js', {strict: false})); + assert(isGlob('abc/(?ab.js', {strict: false})); + assert(isGlob('abc/(ab.js', {strict: false})); + assert(isGlob('abc/(a|b.js', {strict: false})); + assert(isGlob('abc/(a|b|c.js', {strict: false})); + assert(isGlob('abc/(foo).js', {strict: false})); + assert(isGlob('abc/?.js', {strict: false})); + assert(isGlob('abc/[1-3.js', {strict: false})); + assert(isGlob('abc/[^abc.js', {strict: false})); + assert(isGlob('abc/[abc.js', {strict: false})); + assert(isGlob('abc/foo?.js', {strict: false})); + assert(isGlob('abc/{abc.js', {strict: false})); + assert(isGlob('Who?.js', {strict: false})); + }); + + it('should be false if the first delim is escaped and options.strict is false:', function() { + assert(!isGlob('abc/\\(a|b).js', {strict: false})); + assert(!isGlob('abc/(a|b\\).js')); + assert(!isGlob('abc/\\(a|b|c).js', {strict: false})); + assert(!isGlob('abc/\\(a|b|c.js', {strict: false})); + assert(!isGlob('abc/\\[abc].js', {strict: false})); + assert(!isGlob('abc/\\[abc.js', {strict: false})); + + assert(isGlob('abc/(a|b\\).js', {strict: false})); + }); + }); + + describe('regex character classes', function() { + it('should be true if the path has a regex character class:', function() { + assert(isGlob('abc/[abc].js')); + assert(isGlob('abc/[^abc].js')); + assert(isGlob('abc/[1-3].js')); + }); + + it('should be false if the character class is not balanced:', function() { + assert(!isGlob('abc/[abc.js')); + assert(!isGlob('abc/[^abc.js')); + assert(!isGlob('abc/[1-3.js')); + }); + + it('should be false if the character class is escaped:', function() { + assert(!isGlob('abc/\\[abc].js')); + assert(!isGlob('abc/\\[^abc].js')); + assert(!isGlob('abc/\\[1-3].js')); + }); + }); + + describe('brace patterns', function() { + it('should be true if the path has brace characters:', function() { assert(isGlob('abc/{a,b}.js')); assert(isGlob('abc/{a..z}.js')); assert(isGlob('abc/{a..z..2}.js')); }); + + it('should be false if (basic) braces are not balanced:', function() { + assert(!isGlob('abc/\\{a,b}.js')); + assert(!isGlob('abc/\\{a..z}.js')); + assert(!isGlob('abc/\\{a..z..2}.js')); + }); }); - describe('regex patterns', function () { - it('should return `true` if the path has regex characters:', function () { - assert(isGlob('abc/(aaa|bbb).js')); - assert(isGlob('abc/?.js')); - assert(isGlob('?.js')); - assert(isGlob('[abc].js')); + describe('regex patterns', function() { + it('should be true if the path has regex characters:', function() { + assert(!isGlob('$(abc)')); + assert(!isGlob('&(abc)')); + assert(!isGlob('Who?.js')); + assert(!isGlob('? (abc)')); + assert(!isGlob('?.js')); + assert(!isGlob('abc/?.js')); + + assert(isGlob('!&(abc)')); + assert(isGlob('!*.js')); + assert(isGlob('!foo')); + assert(isGlob('!foo.js')); + assert(isGlob('**/abc.js')); + assert(isGlob('*.js')); + assert(isGlob('*z(abc)')); + assert(isGlob('[1-10].js')); assert(isGlob('[^abc].js')); - assert(isGlob('a/b/c/[a-z].js')); assert(isGlob('[a-j]*[^c]b/c')); + assert(isGlob('[abc].js')); + assert(isGlob('a/b/c/[a-z].js')); + assert(isGlob('abc/(aaa|bbb).js')); + assert(isGlob('abc/*.js')); + assert(isGlob('abc/{a,b}.js')); + assert(isGlob('abc/{a..z..2}.js')); + assert(isGlob('abc/{a..z}.js')); + }); + + it('should be false if regex characters are escaped', function() { + assert(!isGlob('\\?.js')); + assert(!isGlob('\\[1-10\\].js')); + assert(!isGlob('\\[^abc\\].js')); + assert(!isGlob('\\[a-j\\]\\*\\[^c\\]b/c')); + assert(!isGlob('\\[abc\\].js')); + assert(!isGlob('\\a/b/c/\\[a-z\\].js')); + assert(!isGlob('abc/\\(aaa|bbb).js')); + assert(!isGlob('abc/\\?.js')); }); }); - describe('extglob patterns', function () { - it('should return `true` if it has an extglob:', function () { - assert(isGlob('abc/@(a).js')); + describe('extglob patterns', function() { + it('should be true if it has an extglob:', function() { assert(isGlob('abc/!(a).js')); - assert(isGlob('abc/+(a).js')); + assert(isGlob('abc/!(a|b).js')); + assert(isGlob('abc/(ab)*.js')); + assert(isGlob('abc/(a|b).js')); assert(isGlob('abc/*(a).js')); + assert(isGlob('abc/*(a|b).js')); + assert(isGlob('abc/+(a).js')); + assert(isGlob('abc/+(a|b).js')); assert(isGlob('abc/?(a).js')); + assert(isGlob('abc/?(a|b).js')); + assert(isGlob('abc/@(a).js')); + assert(isGlob('abc/@(a|b).js')); + }); + + it('should be false if extglob characters are escaped:', function() { + assert(!isGlob('abc/\\*.js')); + assert(!isGlob('abc/\\*\\*.js')); + assert(!isGlob('abc/\\@(a).js')); + assert(!isGlob('abc/\\!(a).js')); + assert(!isGlob('abc/\\+(a).js')); + assert(!isGlob('abc/\\*(a).js')); + assert(!isGlob('abc/\\?(a).js')); + assert(isGlob('abc/\\@(a|b).js'), 'matches since extglob is not escaped'); + assert(isGlob('abc/\\!(a|b).js'), 'matches since extglob is not escaped'); + assert(isGlob('abc/\\+(a|b).js'), 'matches since extglob is not escaped'); + assert(isGlob('abc/\\*(a|b).js'), 'matches since extglob is not escaped'); + assert(isGlob('abc/\\?(a|b).js'), 'matches since extglob is not escaped'); + assert(isGlob('abc/\\@(a\\|b).js'), 'matches since extglob is not escaped'); + assert(isGlob('abc/\\!(a\\|b).js'), 'matches since extglob is not escaped'); + assert(isGlob('abc/\\+(a\\|b).js'), 'matches since extglob is not escaped'); + assert(isGlob('abc/\\*(a\\|b).js'), 'matches since extglob is not escaped'); + assert(isGlob('abc/\\?(a\\|b).js'), 'matches since extglob is not escaped'); + }); + + it('should not return true for non-extglob parens', function() { + assert(!isGlob('C:/Program Files (x86)/')); }); - it('should return `true` if it has extglob characters and is not valid path:', function () { - assert(isGlob('abc/!.js')); + it('should be true if it has glob characters and is not a valid path:', function() { + assert(isGlob('abc/[*].js')); assert(isGlob('abc/*.js')); - assert(isGlob('abc/?.js')); }); - it('should return `false` if it has extglob characters but is a valid path:', function () { + it('should be false if it is a valid non-glob path:', function() { + assert(!isGlob('abc/?.js')); + assert(!isGlob('abc/!.js')); assert(!isGlob('abc/@.js')); assert(!isGlob('abc/+.js')); }); }); + + describe('isGlob', function() { + it('should return true when the string has an extglob:', function() { + assert(isGlob('?(abc)')); + assert(isGlob('@(abc)')); + assert(isGlob('!(abc)')); + assert(isGlob('*(abc)')); + assert(isGlob('+(abc)')); + assert(isGlob('xyz/?(abc)/xyz')); + assert(isGlob('xyz/@(abc)/xyz')); + assert(isGlob('xyz/!(abc)/xyz')); + assert(isGlob('xyz/*(abc)/xyz')); + assert(isGlob('xyz/+(abc)/xyz')); + assert(isGlob('?(abc|xyz)/xyz')); + assert(isGlob('@(abc|xyz)')); + assert(isGlob('!(abc|xyz)')); + assert(isGlob('*(abc|xyz)')); + assert(isGlob('+(abc|xyz)')); + }); + + it('should not match escaped extglobs', function() { + assert(!isGlob('\\?(abc)')); + assert(!isGlob('\\@(abc)')); + assert(!isGlob('\\!(abc)')); + assert(!isGlob('\\*(abc)')); + assert(!isGlob('\\+(abc)')); + assert(!isGlob('xyz/\\?(abc)/xyz')); + assert(!isGlob('xyz/\\@(abc)/xyz')); + assert(!isGlob('xyz/\\!(abc)/xyz')); + assert(!isGlob('xyz/\\*(abc)/xyz')); + assert(!isGlob('xyz/\\+(abc)/xyz')); + }); + + it('should detect when an glob is in the same pattern as an escaped glob', function() { + assert(isGlob('\\?(abc|xyz)/xyz')); + assert(isGlob('\\@(abc|xyz)')); + assert(isGlob('\\!(abc|xyz)')); + assert(isGlob('\\*(abc|xyz)')); + assert(isGlob('\\+(abc|xyz)')); + assert(isGlob('\\?(abc)/?(abc)')); + assert(isGlob('\\@(abc)/@(abc)')); + assert(isGlob('\\!(abc)/!(abc)')); + assert(isGlob('\\*(abc)/*(abc)')); + assert(isGlob('\\+(abc)/+(abc)')); + assert(isGlob('xyz/\\?(abc)/xyz/def/?(abc)/xyz')); + assert(isGlob('xyz/\\@(abc)/xyz/def/@(abc)/xyz')); + assert(isGlob('xyz/\\!(abc)/xyz/def/!(abc)/xyz')); + assert(isGlob('xyz/\\*(abc)/xyz/def/*(abc)/xyz')); + assert(isGlob('xyz/\\+(abc)/xyz/def/+(abc)/xyz')); + assert(isGlob('\\?(abc|xyz)/xyz/?(abc|xyz)/xyz')); + assert(isGlob('\\@(abc|xyz)/@(abc|xyz)')); + assert(isGlob('\\!(abc|xyz)/!(abc|xyz)')); + assert(isGlob('\\*(abc|xyz)/*(abc|xyz)')); + assert(isGlob('\\+(abc|xyz)/+(abc|xyz)')); + }); + }); });