commit e3e768c589ae6dedbb6d5f07b181d0dbfab930ac Author: jonschlinkert Date: Fri Mar 6 16:01:02 2015 -0500 first commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..4a3f1d3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,10 @@ +# Enforce Unix newlines +* text eol=lf + +# binaries +*.ai binary +*.psd binary +*.jpg binary +*.gif binary +*.png binary +*.jpeg binary \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e685a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +*.DS_Store +*.sublime-* +_gh_pages +bower_components +node_modules +npm-debug.log +temp +test/actual +tmp +TODO.md +vendor \ No newline at end of file diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..01134d6 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,19 @@ +{ + "asi": false, + "boss": true, + "camelcase": true, + "curly": true, + "eqeqeq": true, + "eqnull": true, + "esnext": true, + "immed": true, + "latedef": false, + "laxcomma": false, + "mocha": true, + "newcap": true, + "noarg": true, + "node": true, + "sub": true, + "undef": true, + "unused": true +} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f9cffe6 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +sudo: false +language: node_js +node_js: + - "0.10" + - "0.12" + - "iojs" +git: + depth: 10 diff --git a/.verb.md b/.verb.md new file mode 100644 index 0000000..c0dedb0 --- /dev/null +++ b/.verb.md @@ -0,0 +1,59 @@ +# {%= name %} {%= badge("fury") %} {%= badge("travis") %} + +> {%= description %} + +{%= include("install-npm", {save: true}) %} + +## Usage + +```js +var isExtglob = require('{%= name %}'); +``` + +**True** + +```js +isExtglob('?(abc)'); +isExtglob('@(abc)'); +isExtglob('!(abc)'); +isExtglob('*(abc)'); +isExtglob('+(abc)'); +``` + +**False** + +Everything else... + +```js +isExtglob('foo.js'); +isExtglob('!foo.js'); +isExtglob('*.js'); +isExtglob('**/abc.js'); +isExtglob('abc/*.js'); +isExtglob('abc/(aaa|bbb).js'); +isExtglob('abc/[a-z].js'); +isExtglob('abc/{a,b}.js'); +isExtglob('abc/?.js'); +isExtglob('abc.js'); +isExtglob('abc/def/ghi.js'); +``` + +## Related +{%= related(['extglob', 'micromatch', 'parse-glob']) %} + +## Run tests +{%= include("tests") %} + +## Contributing +{%= include("contributing") %} + +## Author +{%= include("author") %} + +## License +{%= copyright() %} +{%= license() %} + +*** + +{%= include("footer") %} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fa30c4c --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014-2015, Jon Schlinkert. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..80e7128 --- /dev/null +++ b/README.md @@ -0,0 +1,75 @@ +# is-extglob [![NPM version](https://badge.fury.io/js/is-extglob.svg)](http://badge.fury.io/js/is-extglob) [![Build Status](https://travis-ci.org/jonschlinkert/is-extglob.svg)](https://travis-ci.org/jonschlinkert/is-extglob) + +> Returns true if a string has an extglob. + +## Install with [npm](npmjs.org) + +```bash +npm i is-extglob --save +``` + +## Usage + +```js +var isExtglob = require('is-extglob'); +``` + +**True** + +```js +isExtglob('?(abc)'); +isExtglob('@(abc)'); +isExtglob('!(abc)'); +isExtglob('*(abc)'); +isExtglob('+(abc)'); +``` + +**False** + +Everything else... + +```js +isExtglob('foo.js'); +isExtglob('!foo.js'); +isExtglob('*.js'); +isExtglob('**/abc.js'); +isExtglob('abc/*.js'); +isExtglob('abc/(aaa|bbb).js'); +isExtglob('abc/[a-z].js'); +isExtglob('abc/{a,b}.js'); +isExtglob('abc/?.js'); +isExtglob('abc.js'); +isExtglob('abc/def/ghi.js'); +``` + +## Related +* [extglob](https://github.com/jonschlinkert/extglob): Extended globs. extglobs add the expressive power of regular expressions to glob patterns. +* [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A faster alternative to minimatch (10-45x faster on avg), with all the features you're used to using in your Grunt and gulp tasks. +* [parse-glob](https://github.com/jonschlinkert/parse-glob): Parse a glob pattern into an object of tokens. + +## Run tests +Install dev dependencies. + +```bash +npm i -d && npm test +``` + + +## Contributing +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-extglob/issues) + + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License +Copyright (c) 2015 Jon Schlinkert +Released under the MIT license + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 06, 2015._ \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..c21571a --- /dev/null +++ b/browser.js @@ -0,0 +1,14 @@ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +module.exports = function isExtglob(str) { + return typeof str === 'string' + && /[@?!+*]\(/.test(str); +}; + +},{}]},{},[1]); diff --git a/index.js b/index.js new file mode 100644 index 0000000..803047f --- /dev/null +++ b/index.js @@ -0,0 +1,11 @@ +/*! + * is-extglob + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +module.exports = function isExtglob(str) { + return typeof str === 'string' + && /[@?!+*]\(/.test(str); +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..1056eac --- /dev/null +++ b/package.json @@ -0,0 +1,48 @@ +{ + "name": "is-extglob", + "description": "Returns true if a string has an extglob.", + "version": "1.0.0", + "homepage": "https://github.com/jonschlinkert/is-extglob", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "repository": "jonschlinkert/is-extglob", + "bugs": { + "url": "https://github.com/jonschlinkert/is-extglob/issues" + }, + "license": "MIT", + "files": [ + "index.js" + ], + "main": "index.js", + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "mocha", + "prepublish": "browserify -o browser.js -e index.js" + }, + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "keywords": [ + "bash", + "braces", + "check", + "exec", + "extglob", + "expression", + "glob", + "globbing", + "globstar", + "match", + "matches", + "pattern", + "regex", + "regular", + "string", + "test" + ] +} \ No newline at end of file diff --git a/test.js b/test.js new file mode 100644 index 0000000..4405780 --- /dev/null +++ b/test.js @@ -0,0 +1,64 @@ +/*! + * is-extglob + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +require('should'); +var isExtglob = require('./'); + +describe('isExtglob', function () { + it('should return true when the string has an extglob:', function () { + isExtglob('?(abc)').should.be.true; + isExtglob('@(abc)').should.be.true; + isExtglob('!(abc)').should.be.true; + isExtglob('*(abc)').should.be.true; + isExtglob('+(abc)').should.be.true; + isExtglob('xyz/?(abc)/xyz').should.be.true; + isExtglob('xyz/@(abc)/xyz').should.be.true; + isExtglob('xyz/!(abc)/xyz').should.be.true; + isExtglob('xyz/*(abc)/xyz').should.be.true; + isExtglob('xyz/+(abc)/xyz').should.be.true; + isExtglob('?(abc|xyz)/xyz').should.be.true; + isExtglob('@(abc|xyz)').should.be.true; + isExtglob('!(abc|xyz)').should.be.true; + isExtglob('*(abc|xyz)').should.be.true; + isExtglob('+(abc|xyz)').should.be.true; + }); + + it('should return false when the string does not have an extglob:', function () { + isExtglob('? (abc)').should.be.false; + isExtglob('@.(abc)').should.be.false; + isExtglob('!&(abc)').should.be.false; + isExtglob('*z(abc)').should.be.false; + isExtglob('+~(abc)').should.be.false; + isExtglob().should.be.false; + isExtglob(null).should.be.false; + isExtglob(['**/*.js']).should.be.false; + isExtglob(['foo.js']).should.be.false; + isExtglob('*.js').should.be.false; + isExtglob('!*.js').should.be.false; + isExtglob('!foo').should.be.false; + isExtglob('!foo.js').should.be.false; + isExtglob('**/abc.js').should.be.false; + isExtglob('abc/*.js').should.be.false; + isExtglob('abc/{a,b}.js').should.be.false; + isExtglob('abc/{a..z}.js').should.be.false; + isExtglob('abc/{a..z..2}.js').should.be.false; + isExtglob('abc/(aaa|bbb).js').should.be.false; + isExtglob('abc/?.js').should.be.false; + isExtglob('?.js').should.be.false; + isExtglob('[abc].js').should.be.false; + isExtglob('[^abc].js').should.be.false; + isExtglob('a/b/c/[a-z].js').should.be.false; + isExtglob('[a-j]*[^c]b/c').should.be.false; + isExtglob('.').should.be.false; + isExtglob('aa').should.be.false; + isExtglob('abc.js').should.be.false; + isExtglob('abc/def/ghi.js').should.be.false; + }); +}); +