272e4bd5e6c86b90eea713fade225504bf958b6cdc8fe2497a47ceadef97631f6dab23b46a2263273bd4d8b80cff5e6b8b5ada5b6490f3a3c481b0c8f18962 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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(['index.js', 'inner_folder'], {
  15. cwd: 'fixtures'
  16. }).then(files => {
  17. console.log(files);
  18. //=> ['index.js', 'inner_folder/**']
  19. });
  20. dirGlob(['lib/**', 'fixtures'], {
  21. files: ['test', 'unicorn']
  22. extensions: ['js']
  23. }).then(files => {
  24. console.log(files);
  25. //=> ['lib/**', 'fixtures/**/test.js', 'fixtures/**/unicorn.js']
  26. });
  27. dirGlob(['lib/**', 'fixtures'], {
  28. files: ['test', 'unicorn', '*.jsx'],
  29. extensions: ['js', 'png']
  30. }).then(files => {
  31. console.log(files);
  32. //=> ['lib/**', 'fixtures/**/test.{js,png}', 'fixtures/**/unicorn.{js,png}', 'fixtures/**/*.jsx']
  33. });
  34. ```
  35. ## API
  36. ### dirGlob(input, [options])
  37. Returns a `Promise` for an array of glob strings.
  38. ### dirGlob.sync(input, [options])
  39. Returns an array of glob strings.
  40. #### input
  41. Type: `Array` `string`
  42. A `string` or an `Array` of paths.
  43. #### options
  44. ##### extensions
  45. Type: `Array`
  46. Append extensions to the end of your globs.
  47. ##### files
  48. Type: `Array`
  49. Only glob for certain files.
  50. ##### cwd
  51. Type: `string`
  52. Test in specific directory.
  53. ## License
  54. MIT © [Kevin Mårtensson](https://github.com/kevva)