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.

74 lines
1.3 KiB

4 years ago
  1. # dir-glob [![Build Status](https://travis-ci.org/kevva/dir-glob.svg?branch=master)](https://travis-ci.org/kevva/dir-glob)
  2. > Convert directories to glob compatible strings
  3. ## Install
  4. ```
  5. $ npm install dir-glob
  6. ```
  7. ## Usage
  8. ```js
  9. const dirGlob = require('dir-glob');
  10. dirGlob(['index.js', 'test.js', 'fixtures']).then(files => {
  11. console.log(files);
  12. //=> ['index.js', 'test.js', 'fixtures/**']
  13. });
  14. dirGlob(['lib/**', 'fixtures'], {
  15. files: ['test', 'unicorn']
  16. extensions: ['js']
  17. }).then(files => {
  18. console.log(files);
  19. //=> ['lib/**', 'fixtures/**/test.js', 'fixtures/**/unicorn.js']
  20. });
  21. dirGlob(['lib/**', 'fixtures'], {
  22. files: ['test', 'unicorn', '*.jsx'],
  23. extensions: ['js', 'png']
  24. }).then(files => {
  25. console.log(files);
  26. //=> ['lib/**', 'fixtures/**/test.{js,png}', 'fixtures/**/unicorn.{js,png}', 'fixtures/**/*.jsx']
  27. });
  28. ```
  29. ## API
  30. ### dirGlob(input, [options])
  31. Returns a `Promise` for an array of glob strings.
  32. ### dirGlob.sync(input, [options])
  33. Returns an array of glob strings.
  34. #### input
  35. Type: `Array` `string`
  36. A `string` or an `Array` of paths.
  37. #### options
  38. ##### extensions
  39. Type: `Array`
  40. Append extensions to the end of your globs.
  41. ##### files
  42. Type: `Array`
  43. Only glob for certain files.
  44. ## License
  45. MIT © [Kevin Mårtensson](https://github.com/kevva)