is-glob
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -8,5 +8,8 @@ /*! | ||
var isExtglob = require('is-extglob'); | ||
module.exports = function isGlob(str) { | ||
return typeof str === 'string' | ||
&& /[@!*+{}?(|)[\]]/.test(str); | ||
&& (/[*!?{}(|)[\]]/.test(str) | ||
|| isExtglob(str)); | ||
}; |
{ | ||
"name": "is-glob", | ||
"description": "Returns `true` if the given string looks like a glob pattern.", | ||
"version": "2.0.0", | ||
"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.", | ||
"version": "2.0.1", | ||
"homepage": "https://github.com/jonschlinkert/is-glob", | ||
@@ -25,5 +25,7 @@ "author": { | ||
}, | ||
"dependencies": { | ||
"is-extglob": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*", | ||
"should": "*" | ||
"mocha": "*" | ||
}, | ||
@@ -47,3 +49,14 @@ "keywords": [ | ||
"test" | ||
] | ||
} | ||
], | ||
"verb": { | ||
"related": { | ||
"list": [ | ||
"has-glob", | ||
"is-extglob", | ||
"is-posix-bracket", | ||
"is-valid-glob", | ||
"micromatch" | ||
] | ||
} | ||
} | ||
} |
# is-glob [![NPM version](https://badge.fury.io/js/is-glob.svg)](http://badge.fury.io/js/is-glob) [![Build Status](https://travis-ci.org/jonschlinkert/is-glob.svg)](https://travis-ci.org/jonschlinkert/is-glob) | ||
> Returns `true` if the given string looks like a glob pattern. | ||
> 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. | ||
Also take a look at [is-valid-glob](https://github.com/jonschlinkert/is-valid-glob) and [has-glob](https://github.com/jonschlinkert/has-glob). | ||
## Install | ||
Install with [npm](https://www.npmjs.com/) | ||
```bash | ||
npm i is-glob --save | ||
```sh | ||
$ npm i is-glob --save | ||
``` | ||
@@ -15,32 +19,61 @@ | ||
var isGlob = require('is-glob'); | ||
``` | ||
isGlob('foo.js'); | ||
//=> 'false' | ||
**True** | ||
Patterns that have glob characters or regex patterns will return `true`: | ||
```js | ||
isGlob('!foo.js'); | ||
//=> 'true' | ||
isGlob('*.js'); | ||
//=> 'true' | ||
isGlob('**/abc.js'); | ||
//=> 'true' | ||
isGlob('abc/*.js'); | ||
//=> 'true' | ||
isGlob('abc/(aaa|bbb).js'); | ||
//=> 'true' | ||
isGlob('abc/[a-z].js'); | ||
//=> 'true' | ||
isGlob('abc/{a,b}.js'); | ||
//=> 'true' | ||
isGlob('abc/?.js'); | ||
//=> 'true' | ||
//=> true | ||
``` | ||
Extglobs | ||
```js | ||
isGlob('abc/@(a).js'); | ||
isGlob('abc/!(a).js'); | ||
isGlob('abc/+(a).js'); | ||
isGlob('abc/*(a).js'); | ||
isGlob('abc/?(a).js'); | ||
//=> true | ||
``` | ||
**False** | ||
Patterns that do not have glob patterns return `false`: | ||
```js | ||
isGlob('abc.js'); | ||
//=> 'false' | ||
isGlob('abc/def/ghi.js'); | ||
//=> 'false' | ||
isGlob('foo.js'); | ||
isGlob('abc/@.js'); | ||
isGlob('abc/+.js'); | ||
isGlob(); | ||
isGlob(null); | ||
//=> false | ||
``` | ||
Arrays are also `false` (If you want to check if an array has a glob pattern, use [has-glob](https://github.com/jonschlinkert/has-glob)): | ||
```js | ||
isGlob(['**/*.js']); | ||
isGlob(['foo.js']); | ||
//=> false | ||
``` | ||
## Related | ||
* [is-git-url](https://github.com/jonschlinkert/is-git-url): Regex to validate that a URL is a git url. | ||
* [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just… [more](https://github.com/jonschlinkert/micromatch) | ||
* [parse-glob](https://github.com/jonschlinkert/parse-glob): Parse a glob pattern into an object of tokens. | ||
* [has-glob](https://www.npmjs.com/package/has-glob): Returns `true` if an array has a glob pattern. | [homepage](https://github.com/jonschlinkert/has-glob) | ||
* [is-extglob](https://www.npmjs.com/package/is-extglob): Returns true if a string has an extglob. | [homepage](https://github.com/jonschlinkert/is-extglob) | ||
* [is-posix-bracket](https://www.npmjs.com/package/is-posix-bracket): Returns true if the given string is a POSIX bracket expression (POSIX character class). | [homepage](https://github.com/jonschlinkert/is-posix-bracket) | ||
* [is-valid-glob](https://www.npmjs.com/package/is-valid-glob): Return true if a value is a valid glob pattern or patterns. | [homepage](https://github.com/jonschlinkert/is-valid-glob) | ||
* [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just… [more](https://www.npmjs.com/package/micromatch) | [homepage](https://github.com/jonschlinkert/micromatch) | ||
@@ -51,4 +84,4 @@ ## Run tests | ||
```bash | ||
npm i -d && npm test | ||
```sh | ||
$ npm i -d && npm test | ||
``` | ||
@@ -58,3 +91,3 @@ | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-glob/issues) | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-glob/issues/new). | ||
@@ -70,3 +103,3 @@ ## Author | ||
Copyright (c) 2015 Jon Schlinkert | ||
Copyright © 2015 Jon Schlinkert | ||
Released under the MIT license. | ||
@@ -76,6 +109,2 @@ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on May 06, 2015._ | ||
[assemble]: http://assemble.io | ||
[template]: https://github.com/jonschlinkert/template | ||
[verb]: https://github.com/assemble/verb | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 02, 2015._ |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
5918
1
11
105
0
1
+ Addedis-extglob@^1.0.0
+ Addedis-extglob@1.0.0(transitive)