a7295f50cc82154755d283879c0fdc18ff987664a63c3e8ee898df3d5b4c53709fe0a0976f4ff3d46980523ad18fc77a8495420ab1223e4b10a6eaaf02391d 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # 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)
  2. > 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.
  3. Also take a look at [is-valid-glob](https://github.com/jonschlinkert/is-valid-glob) and [has-glob](https://github.com/jonschlinkert/has-glob).
  4. ## Install
  5. Install with [npm](https://www.npmjs.com/)
  6. ```sh
  7. $ npm i is-glob --save
  8. ```
  9. ## Usage
  10. ```js
  11. var isGlob = require('is-glob');
  12. ```
  13. **True**
  14. Patterns that have glob characters or regex patterns will return `true`:
  15. ```js
  16. isGlob('!foo.js');
  17. isGlob('*.js');
  18. isGlob('**/abc.js');
  19. isGlob('abc/*.js');
  20. isGlob('abc/(aaa|bbb).js');
  21. isGlob('abc/[a-z].js');
  22. isGlob('abc/{a,b}.js');
  23. isGlob('abc/?.js');
  24. //=> true
  25. ```
  26. Extglobs
  27. ```js
  28. isGlob('abc/@(a).js');
  29. isGlob('abc/!(a).js');
  30. isGlob('abc/+(a).js');
  31. isGlob('abc/*(a).js');
  32. isGlob('abc/?(a).js');
  33. //=> true
  34. ```
  35. **False**
  36. Patterns that do not have glob patterns return `false`:
  37. ```js
  38. isGlob('abc.js');
  39. isGlob('abc/def/ghi.js');
  40. isGlob('foo.js');
  41. isGlob('abc/@.js');
  42. isGlob('abc/+.js');
  43. isGlob();
  44. isGlob(null);
  45. //=> false
  46. ```
  47. 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)):
  48. ```js
  49. isGlob(['**/*.js']);
  50. isGlob(['foo.js']);
  51. //=> false
  52. ```
  53. ## Related
  54. * [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)
  55. * [is-extglob](https://www.npmjs.com/package/is-extglob): Returns true if a string has an extglob. | [homepage](https://github.com/jonschlinkert/is-extglob)
  56. * [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)
  57. * [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)
  58. * [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)
  59. ## Run tests
  60. Install dev dependencies:
  61. ```sh
  62. $ npm i -d && npm test
  63. ```
  64. ## Contributing
  65. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-glob/issues/new).
  66. ## Author
  67. **Jon Schlinkert**
  68. + [github/jonschlinkert](https://github.com/jonschlinkert)
  69. + [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
  70. ## License
  71. Copyright © 2015 Jon Schlinkert
  72. Released under the MIT license.
  73. ***
  74. _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 02, 2015._