a5a74a8deec4f6b6854e7ad68ebd7b428db8d04add7a2f5ad2c3f36ff95066b6b154bc0bbb3381eb1cc39b3334cfb7964aa39283e29c0d5db3c9c6d24ef04f 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. # is-glob [![NPM version](https://img.shields.io/npm/v/is-glob.svg?style=flat)](https://www.npmjs.com/package/is-glob) [![NPM downloads](https://img.shields.io/npm/dm/is-glob.svg?style=flat)](https://npmjs.org/package/is-glob) [![Build Status](https://img.shields.io/travis/jonschlinkert/is-glob.svg?style=flat)](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. ## Install
  4. Install with [npm](https://www.npmjs.com/):
  5. ```sh
  6. $ npm install --save is-glob
  7. ```
  8. You might also be interested in [is-valid-glob](https://github.com/jonschlinkert/is-valid-glob) and [has-glob](https://github.com/jonschlinkert/has-glob).
  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. Escaped globs or extglobs return `false`:
  37. ```js
  38. isGlob('abc/\\@(a).js');
  39. isGlob('abc/\\!(a).js');
  40. isGlob('abc/\\+(a).js');
  41. isGlob('abc/\\*(a).js');
  42. isGlob('abc/\\?(a).js');
  43. isGlob('\\!foo.js');
  44. isGlob('\\*.js');
  45. isGlob('\\*\\*/abc.js');
  46. isGlob('abc/\\*.js');
  47. isGlob('abc/\\(aaa|bbb).js');
  48. isGlob('abc/\\[a-z].js');
  49. isGlob('abc/\\{a,b}.js');
  50. isGlob('abc/\\?.js');
  51. //=> false
  52. ```
  53. Patterns that do not have glob patterns return `false`:
  54. ```js
  55. isGlob('abc.js');
  56. isGlob('abc/def/ghi.js');
  57. isGlob('foo.js');
  58. isGlob('abc/@.js');
  59. isGlob('abc/+.js');
  60. isGlob();
  61. isGlob(null);
  62. //=> false
  63. ```
  64. 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)):
  65. ```js
  66. isGlob(['**/*.js']);
  67. isGlob(['foo.js']);
  68. //=> false
  69. ```
  70. ## About
  71. ### Related projects
  72. * [assemble](https://www.npmjs.com/package/assemble): Get the rocks out of your socks! Assemble makes you fast at creating web projects… [more](https://github.com/assemble/assemble) | [homepage](https://github.com/assemble/assemble "Get the rocks out of your socks! Assemble makes you fast at creating web projects. Assemble is used by thousands of projects for rapid prototyping, creating themes, scaffolds, boilerplates, e-books, UI components, API documentation, blogs, building websit")
  73. * [base](https://www.npmjs.com/package/base): base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… [more](https://github.com/node-base/base) | [homepage](https://github.com/node-base/base "base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting with a handful of common methods, like `set`, `get`, `del` and `use`.")
  74. * [update](https://www.npmjs.com/package/update): Be scalable! Update is a new, open source developer framework and CLI for automating updates… [more](https://github.com/update/update) | [homepage](https://github.com/update/update "Be scalable! Update is a new, open source developer framework and CLI for automating updates of any kind in code projects.")
  75. * [verb](https://www.npmjs.com/package/verb): Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… [more](https://github.com/verbose/verb) | [homepage](https://github.com/verbose/verb "Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used on hundreds of projects of all sizes to generate everything from API docs to readmes.")
  76. ### Contributing
  77. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  78. ### Contributors
  79. | **Commits** | **Contributor**<br/> |
  80. | --- | --- |
  81. | 40 | [jonschlinkert](https://github.com/jonschlinkert) |
  82. | 1 | [tuvistavie](https://github.com/tuvistavie) |
  83. ### Building docs
  84. _(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
  85. To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
  86. ```sh
  87. $ npm install -g verb verb-generate-readme && verb
  88. ```
  89. ### Running tests
  90. Install dev dependencies:
  91. ```sh
  92. $ npm install -d && npm test
  93. ```
  94. ### Author
  95. **Jon Schlinkert**
  96. * [github/jonschlinkert](https://github.com/jonschlinkert)
  97. * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
  98. ### License
  99. Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
  100. Released under the [MIT license](https://github.com/jonschlinkert/is-glob/blob/master/LICENSE).
  101. ***
  102. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.31, on October 12, 2016._