diff --git a/.gitignore b/.gitignore index e69de29..d970cbc 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/is-glob-2.0.1.tgz diff --git a/nodejs-is-glob.spec b/nodejs-is-glob.spec new file mode 100644 index 0000000..cfdc29e --- /dev/null +++ b/nodejs-is-glob.spec @@ -0,0 +1,75 @@ +%{?nodejs_find_provides_and_requires} + +%global packagename is-glob +%global enable_tests 1 + +Name: nodejs-is-glob +Version: 2.0.1 +Release: 1%{?dist} +Summary: Returns `true` if the given string looks like a glob pattern + +License: MIT +URL: https://github.com/jonschlinkert/is-glob.git +Source0: https://registry.npmjs.org/%{packagename}/-/%{packagename}-%{version}.tgz +# The test files are not included in the npm tarball. +Source1: https://raw.githubusercontent.com/jonschlinkert/is-glob/%{version}/test.js + + +BuildArch: noarch +%if 0%{?fedora} >= 19 +ExclusiveArch: %{nodejs_arches} noarch +%else +ExclusiveArch: %{ix86} x86_64 %{arm} noarch +%endif + +BuildRequires: nodejs-packaging +BuildRequires: npm(is-extglob) +%if 0%{?enable_tests} +BuildRequires: mocha +BuildRequires: npm(should) +%endif + +%description +Returns `true` if the given string looks like a glob pattern or an extglob +pattern. This makes it easy to create code that only uses external modules +like node-glob when necessary, resulting in much faster code execution and +initialization time, and a better user experience. + + +%prep +%setup -q -n package +# setup the tests +cp -p %{SOURCE1} . + + +%build +# nothing to do! + +%install +mkdir -p %{buildroot}%{nodejs_sitelib}/%{packagename} +cp -pr package.json index.js \ + %{buildroot}%{nodejs_sitelib}/%{packagename} + +%nodejs_symlink_deps + +%check +%nodejs_symlink_deps --check +ln -s %{nodejs_sitelib}/should node_modules/should +%{__nodejs} -e 'require("./")' +%if 0%{?enable_tests} +%{_bindir}/mocha -R spec +%else +%{_bindir}/echo "Tests disabled..." +%endif + + +%files +%{!?_licensedir:%global license %doc} +%doc *.md +%license LICENSE +%{nodejs_sitelib}/%{packagename} + + +%changelog +* Tue Feb 9 2016 Jared Smith - 2.0.1-1 +- Initial packaging diff --git a/sources b/sources index e69de29..5cb3d95 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +094686a7618e52db5f126af328da6aff is-glob-2.0.1.tgz diff --git a/test.js b/test.js new file mode 100644 index 0000000..a9e5feb --- /dev/null +++ b/test.js @@ -0,0 +1,81 @@ +/*! + * is-glob + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +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 () { + assert(isGlob('*.js')); + assert(isGlob('!*.js')); + assert(isGlob('!foo')); + assert(isGlob('!foo.js')); + assert(isGlob('**/abc.js')); + assert(isGlob('abc/*.js')); + }); + + it('should return `false` if it 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 () { + assert(!isGlob('.')); + assert(!isGlob('aa')); + assert(!isGlob('abc.js')); + assert(!isGlob('abc/def/ghi.js')); + }); + }); + + describe('brace patterns', function () { + it('should return `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')); + }); + }); + + 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')); + assert(isGlob('[^abc].js')); + assert(isGlob('a/b/c/[a-z].js')); + assert(isGlob('[a-j]*[^c]b/c')); + }); + }); + + describe('extglob patterns', function () { + it('should return `true` if it has an extglob:', function () { + 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')); + }); + + it('should return `true` if it has extglob characters and is not 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 () { + assert(!isGlob('abc/@.js')); + assert(!isGlob('abc/+.js')); + }); + }); +}); +