You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # is-valid-glob [![NPM version](https://img.shields.io/npm/v/is-valid-glob.svg?style=flat)](https://www.npmjs.com/package/is-valid-glob) [![NPM monthly downloads](https://img.shields.io/npm/dm/is-valid-glob.svg?style=flat)](https://npmjs.org/package/is-valid-glob) [![NPM total downloads](https://img.shields.io/npm/dt/is-valid-glob.svg?style=flat)](https://npmjs.org/package/is-valid-glob) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/is-valid-glob.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/is-valid-glob)
  2. > Return true if a value is a valid glob pattern or patterns.
  3. ## Install
  4. Install with [npm](https://www.npmjs.com/):
  5. ```sh
  6. $ npm install --save is-valid-glob
  7. ```
  8. ## Usage
  9. This really just checks to make sure that a pattern is either a string or array, and if it's an array it's either empty or consists of only strings.
  10. ```js
  11. var isValidGlob = require('is-valid-glob');
  12. isValidGlob('foo/*.js');
  13. //=> true
  14. ```
  15. **Valid patterns**
  16. ```js
  17. isValidGlob('a');
  18. isValidGlob('a.js');
  19. isValidGlob('*.js');
  20. isValidGlob(['a', 'b']);
  21. //=> all true
  22. ```
  23. **Invalid patterns**
  24. ```js
  25. isValidGlob();
  26. isValidGlob('');
  27. isValidGlob(null);
  28. isValidGlob(undefined);
  29. isValidGlob(new Buffer('foo'));
  30. isValidGlob(['foo', [[]]]);
  31. isValidGlob(['foo', [['bar']]]);
  32. isValidGlob(['foo', {}]);
  33. isValidGlob({});
  34. isValidGlob([]);
  35. isValidGlob(['']);
  36. //=> all false
  37. ```
  38. ## About
  39. ### Related projects
  40. * [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "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 bet")
  41. * [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/micromatch/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.")
  42. * [vinyl-fs](https://www.npmjs.com/package/vinyl-fs): Vinyl adapter for the file system | [homepage](http://github.com/wearefractal/vinyl-fs "Vinyl adapter for the file system")
  43. * [vinyl](https://www.npmjs.com/package/vinyl): Virtual file format. | [homepage](https://github.com/gulpjs/vinyl#readme "Virtual file format.")
  44. ### Contributing
  45. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  46. ### Contributors
  47. | **Commits** | **Contributor** |
  48. | --- | --- |
  49. | 9 | [jonschlinkert](https://github.com/jonschlinkert) |
  50. | 2 | [contra](https://github.com/contra) |
  51. ### Building docs
  52. _(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.)_
  53. To generate the readme, run the following command:
  54. ```sh
  55. $ npm install -g verbose/verb#dev verb-generate-readme && verb
  56. ```
  57. ### Running tests
  58. 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:
  59. ```sh
  60. $ npm install && npm test
  61. ```
  62. ### Author
  63. **Jon Schlinkert**
  64. * [github/jonschlinkert](https://github.com/jonschlinkert)
  65. * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
  66. ### License
  67. Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
  68. Released under the [MIT License](LICENSE).
  69. ***
  70. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on June 21, 2017._