381ef910a116a62bdd9e0566164cafde0eee57186459d7f1ac948d2ece9d35292acee70f1104c0b7638408c701e5cc9d6a47bdd6c33c09cd8b79e6d5877174 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. # glob-base [![NPM version](https://badge.fury.io/js/glob-base.svg)](http://badge.fury.io/js/glob-base) [![Build Status](https://travis-ci.org/jonschlinkert/glob-base.svg)](https://travis-ci.org/jonschlinkert/glob-base)
  2. > Returns an object with the (non-glob) base path and the actual pattern.
  3. Use [glob-parent](https://github.com/es128/glob-parent) if you just want the base path.
  4. ## Install with [npm](npmjs.org)
  5. ```bash
  6. npm i glob-base --save
  7. ```
  8. ## Related projects
  9. * [glob-parent](https://github.com/es128/glob-parent): Strips glob magic from a string to provide the parent path
  10. * [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A faster alternative to minimatch (10-45x faster on avg), with all the features you're used to using in your Grunt and gulp tasks.
  11. * [parse-glob](https://github.com/jonschlinkert/parse-glob): Parse a glob pattern into an object of tokens.
  12. * [is-glob](https://github.com/jonschlinkert/is-glob): Returns `true` if the given string looks like a glob pattern.
  13. * [braces](https://github.com/jonschlinkert/braces): Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces specification.
  14. * [fill-range](https://github.com/jonschlinkert/fill-range): Fill in a range of numbers or letters, optionally passing an increment or multiplier to use.
  15. * [expand-range](https://github.com/jonschlinkert/expand-range): Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See the benchmarks. Used by micromatch.
  16. ## Usage
  17. ```js
  18. var globBase = require('glob-base');
  19. globBase('a/b/.git/');
  20. //=> { base: 'a/b/.git/', isGlob: false, glob: '' })
  21. globBase('a/b/**/e');
  22. //=> { base: 'a/b', isGlob: true, glob: '**/e' }
  23. globBase('a/b/*.{foo,bar}');
  24. //=> { base: 'a/b', isGlob: true, glob: '*.{foo,bar}' }
  25. globBase('a/b/.git/**');
  26. //=> { base: 'a/b/.git', isGlob: true, glob: '**' }
  27. globBase('a/b/c/*.md');
  28. //=> { base: 'a/b/c', isGlob: true, glob: '*.md' }
  29. globBase('a/b/c/.*.md');
  30. //=> { base: 'a/b/c', isGlob: true, glob: '.*.md' }
  31. globBase('a/b/{c,d}');
  32. //=> { base: 'a/b', isGlob: true, glob: '{c,d}' }
  33. globBase('!*.min.js');
  34. //=> { base: '.', isGlob: true, glob: '!*.min.js' }
  35. globBase('!foo');
  36. //=> { base: '.', isGlob: true, glob: '!foo' }
  37. globBase('!foo/(a|b).min.js');
  38. //=> { base: '.', isGlob: true, glob: '!foo/(a|b).min.js' }
  39. globBase('');
  40. //=> { base: '.', isGlob: false, glob: '' }
  41. globBase('**/*.md');
  42. //=> { base: '.', isGlob: true, glob: '**/*.md' }
  43. globBase('**/*.min.js');
  44. //=> { base: '.', isGlob: true, glob: '**/*.min.js' }
  45. globBase('**/.*');
  46. //=> { base: '.', isGlob: true, glob: '**/.*' }
  47. globBase('**/d');
  48. //=> { base: '.', isGlob: true, glob: '**/d' }
  49. globBase('*.*');
  50. //=> { base: '.', isGlob: true, glob: '*.*' }
  51. globBase('*.min.js');
  52. //=> { base: '.', isGlob: true, glob: '*.min.js' }
  53. globBase('*/*');
  54. //=> { base: '.', isGlob: true, glob: '*/*' }
  55. globBase('*b');
  56. //=> { base: '.', isGlob: true, glob: '*b' }
  57. globBase('.');
  58. //=> { base: '.', isGlob: false, glob: '.' }
  59. globBase('.*');
  60. //=> { base: '.', isGlob: true, glob: '.*' }
  61. globBase('./*');
  62. //=> { base: '.', isGlob: true, glob: '*' }
  63. globBase('/a');
  64. //=> { base: '/', isGlob: false, glob: 'a' }
  65. globBase('@(a|b)/e.f.g/');
  66. //=> { base: '.', isGlob: true, glob: '@(a|b)/e.f.g/' }
  67. globBase('[a-c]b*');
  68. //=> { base: '.', isGlob: true, glob: '[a-c]b*' }
  69. globBase('a');
  70. //=> { base: '.', isGlob: false, glob: 'a' }
  71. globBase('a.min.js');
  72. //=> { base: '.', isGlob: false, glob: 'a.min.js' }
  73. globBase('a/');
  74. //=> { base: 'a/', isGlob: false, glob: '' }
  75. globBase('a/**/j/**/z/*.md');
  76. //=> { base: 'a', isGlob: true, glob: '**/j/**/z/*.md' }
  77. globBase('a/*/c/*.md');
  78. //=> { base: 'a', isGlob: true, glob: '*/c/*.md' }
  79. globBase('a/?/c.md');
  80. //=> { base: 'a', isGlob: true, glob: '?/c.md' }
  81. globBase('a/??/c.js');
  82. //=> { base: 'a', isGlob: true, glob: '??/c.js' }
  83. globBase('a?b');
  84. //=> { base: '.', isGlob: true, glob: 'a?b' }
  85. globBase('bb');
  86. //=> { base: '.', isGlob: false, glob: 'bb' }
  87. globBase('c.md');
  88. //=> { base: '.', isGlob: false, glob: 'c.md' }
  89. ```
  90. ## Running tests
  91. Install dev dependencies.
  92. ```bash
  93. npm i -d && npm test
  94. ```
  95. ## Contributing
  96. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/glob-base/issues)
  97. ## Author
  98. **Jon Schlinkert**
  99. + [github/jonschlinkert](https://github.com/jonschlinkert)
  100. + [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
  101. ## License
  102. Copyright (c) 2015 Jon Schlinkert
  103. Released under the MIT license
  104. ***
  105. _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 08, 2015._