No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

README.md 7.0 KiB

hace 10 meses
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. # is-glob [![NPM version](https://img.shields.io/npm/v/is-glob.svg?style=flat)](https://www.npmjs.com/package/is-glob) [![NPM monthly downloads](https://img.shields.io/npm/dm/is-glob.svg?style=flat)](https://npmjs.org/package/is-glob) [![NPM total downloads](https://img.shields.io/npm/dt/is-glob.svg?style=flat)](https://npmjs.org/package/is-glob) [![Build Status](https://img.shields.io/github/workflow/status/micromatch/is-glob/dev)](https://github.com/micromatch/is-glob/actions)
  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. Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
  4. ## Install
  5. Install with [npm](https://www.npmjs.com/):
  6. ```sh
  7. $ npm install --save is-glob
  8. ```
  9. 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).
  10. ## Usage
  11. ```js
  12. var isGlob = require('is-glob');
  13. ```
  14. ### Default behavior
  15. **True**
  16. Patterns that have glob characters or regex patterns will return `true`:
  17. ```js
  18. isGlob('!foo.js');
  19. isGlob('*.js');
  20. isGlob('**/abc.js');
  21. isGlob('abc/*.js');
  22. isGlob('abc/(aaa|bbb).js');
  23. isGlob('abc/[a-z].js');
  24. isGlob('abc/{a,b}.js');
  25. //=> true
  26. ```
  27. Extglobs
  28. ```js
  29. isGlob('abc/@(a).js');
  30. isGlob('abc/!(a).js');
  31. isGlob('abc/+(a).js');
  32. isGlob('abc/*(a).js');
  33. isGlob('abc/?(a).js');
  34. //=> true
  35. ```
  36. **False**
  37. Escaped globs or extglobs return `false`:
  38. ```js
  39. isGlob('abc/\\@(a).js');
  40. isGlob('abc/\\!(a).js');
  41. isGlob('abc/\\+(a).js');
  42. isGlob('abc/\\*(a).js');
  43. isGlob('abc/\\?(a).js');
  44. isGlob('\\!foo.js');
  45. isGlob('\\*.js');
  46. isGlob('\\*\\*/abc.js');
  47. isGlob('abc/\\*.js');
  48. isGlob('abc/\\(aaa|bbb).js');
  49. isGlob('abc/\\[a-z].js');
  50. isGlob('abc/\\{a,b}.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('abc/?.js');
  61. isGlob();
  62. isGlob(null);
  63. //=> false
  64. ```
  65. 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)):
  66. ```js
  67. isGlob(['**/*.js']);
  68. isGlob(['foo.js']);
  69. //=> false
  70. ```
  71. ### Option strict
  72. When `options.strict === false` the behavior is less strict in determining if a pattern is a glob. Meaning that
  73. some patterns that would return `false` may return `true`. This is done so that matching libraries like [micromatch](https://github.com/micromatch/micromatch) have a chance at determining if the pattern is a glob or not.
  74. **True**
  75. Patterns that have glob characters or regex patterns will return `true`:
  76. ```js
  77. isGlob('!foo.js', {strict: false});
  78. isGlob('*.js', {strict: false});
  79. isGlob('**/abc.js', {strict: false});
  80. isGlob('abc/*.js', {strict: false});
  81. isGlob('abc/(aaa|bbb).js', {strict: false});
  82. isGlob('abc/[a-z].js', {strict: false});
  83. isGlob('abc/{a,b}.js', {strict: false});
  84. //=> true
  85. ```
  86. Extglobs
  87. ```js
  88. isGlob('abc/@(a).js', {strict: false});
  89. isGlob('abc/!(a).js', {strict: false});
  90. isGlob('abc/+(a).js', {strict: false});
  91. isGlob('abc/*(a).js', {strict: false});
  92. isGlob('abc/?(a).js', {strict: false});
  93. //=> true
  94. ```
  95. **False**
  96. Escaped globs or extglobs return `false`:
  97. ```js
  98. isGlob('\\!foo.js', {strict: false});
  99. isGlob('\\*.js', {strict: false});
  100. isGlob('\\*\\*/abc.js', {strict: false});
  101. isGlob('abc/\\*.js', {strict: false});
  102. isGlob('abc/\\(aaa|bbb).js', {strict: false});
  103. isGlob('abc/\\[a-z].js', {strict: false});
  104. isGlob('abc/\\{a,b}.js', {strict: false});
  105. //=> false
  106. ```
  107. ## About
  108. <details>
  109. <summary><strong>Contributing</strong></summary>
  110. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  111. </details>
  112. <details>
  113. <summary><strong>Running Tests</strong></summary>
  114. Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
  115. ```sh
  116. $ npm install && npm test
  117. ```
  118. </details>
  119. <details>
  120. <summary><strong>Building docs</strong></summary>
  121. _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
  122. To generate the readme, run the following command:
  123. ```sh
  124. $ npm install -g verbose/verb#dev verb-generate-readme && verb
  125. ```
  126. </details>
  127. ### Related projects
  128. You might also be interested in these projects:
  129. * [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")
  130. * [base](https://www.npmjs.com/package/base): Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks | [homepage](https://github.com/node-base/base "Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks")
  131. * [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.")
  132. * [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.")
  133. ### Contributors
  134. | **Commits** | **Contributor** |
  135. | --- | --- |
  136. | 47 | [jonschlinkert](https://github.com/jonschlinkert) |
  137. | 5 | [doowb](https://github.com/doowb) |
  138. | 1 | [phated](https://github.com/phated) |
  139. | 1 | [danhper](https://github.com/danhper) |
  140. | 1 | [paulmillr](https://github.com/paulmillr) |
  141. ### Author
  142. **Jon Schlinkert**
  143. * [GitHub Profile](https://github.com/jonschlinkert)
  144. * [Twitter Profile](https://twitter.com/jonschlinkert)
  145. * [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
  146. ### License
  147. Copyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).
  148. Released under the [MIT License](LICENSE).
  149. ***
  150. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on March 27, 2019._