UNPKG

4.69 kBMarkdownView Raw
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
3> Returns an object with the (non-glob) base path and the actual pattern.
4
5Use [glob-parent](https://github.com/es128/glob-parent) if you just want the base path.
6
7## Install with [npm](npmjs.org)
8
9```bash
10npm i glob-base --save
11```
12
13## Related projects
14* [glob-parent](https://github.com/es128/glob-parent): Strips glob magic from a string to provide the parent path
15* [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.
16* [parse-glob](https://github.com/jonschlinkert/parse-glob): Parse a glob pattern into an object of tokens.
17* [is-glob](https://github.com/jonschlinkert/is-glob): Returns `true` if the given string looks like a glob pattern.
18* [braces](https://github.com/jonschlinkert/braces): Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces specification.
19* [fill-range](https://github.com/jonschlinkert/fill-range): Fill in a range of numbers or letters, optionally passing an increment or multiplier to use.
20* [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.
21
22## Usage
23
24```js
25var globBase = require('glob-base');
26
27globBase('a/b/.git/');
28//=> { base: 'a/b/.git/', isGlob: false, glob: '' })
29
30globBase('a/b/**/e');
31//=> { base: 'a/b', isGlob: true, glob: '**/e' }
32
33globBase('a/b/*.{foo,bar}');
34//=> { base: 'a/b', isGlob: true, glob: '*.{foo,bar}' }
35
36globBase('a/b/.git/**');
37//=> { base: 'a/b/.git', isGlob: true, glob: '**' }
38
39globBase('a/b/c/*.md');
40//=> { base: 'a/b/c', isGlob: true, glob: '*.md' }
41
42globBase('a/b/c/.*.md');
43//=> { base: 'a/b/c', isGlob: true, glob: '.*.md' }
44
45globBase('a/b/{c,d}');
46//=> { base: 'a/b', isGlob: true, glob: '{c,d}' }
47
48globBase('!*.min.js');
49//=> { base: '.', isGlob: true, glob: '!*.min.js' }
50
51globBase('!foo');
52//=> { base: '.', isGlob: true, glob: '!foo' }
53
54globBase('!foo/(a|b).min.js');
55//=> { base: '.', isGlob: true, glob: '!foo/(a|b).min.js' }
56
57globBase('');
58//=> { base: '.', isGlob: false, glob: '' }
59
60globBase('**/*.md');
61//=> { base: '.', isGlob: true, glob: '**/*.md' }
62
63globBase('**/*.min.js');
64//=> { base: '.', isGlob: true, glob: '**/*.min.js' }
65
66globBase('**/.*');
67//=> { base: '.', isGlob: true, glob: '**/.*' }
68
69globBase('**/d');
70//=> { base: '.', isGlob: true, glob: '**/d' }
71
72globBase('*.*');
73//=> { base: '.', isGlob: true, glob: '*.*' }
74
75globBase('*.min.js');
76//=> { base: '.', isGlob: true, glob: '*.min.js' }
77
78globBase('*/*');
79//=> { base: '.', isGlob: true, glob: '*/*' }
80
81globBase('*b');
82//=> { base: '.', isGlob: true, glob: '*b' }
83
84globBase('.');
85//=> { base: '.', isGlob: false, glob: '.' }
86
87globBase('.*');
88//=> { base: '.', isGlob: true, glob: '.*' }
89
90globBase('./*');
91//=> { base: '.', isGlob: true, glob: '*' }
92
93globBase('/a');
94//=> { base: '/', isGlob: false, glob: 'a' }
95
96globBase('@(a|b)/e.f.g/');
97//=> { base: '.', isGlob: true, glob: '@(a|b)/e.f.g/' }
98
99globBase('[a-c]b*');
100//=> { base: '.', isGlob: true, glob: '[a-c]b*' }
101
102globBase('a');
103//=> { base: '.', isGlob: false, glob: 'a' }
104
105globBase('a.min.js');
106//=> { base: '.', isGlob: false, glob: 'a.min.js' }
107
108globBase('a/');
109//=> { base: 'a/', isGlob: false, glob: '' }
110
111globBase('a/**/j/**/z/*.md');
112//=> { base: 'a', isGlob: true, glob: '**/j/**/z/*.md' }
113
114globBase('a/*/c/*.md');
115//=> { base: 'a', isGlob: true, glob: '*/c/*.md' }
116
117globBase('a/?/c.md');
118//=> { base: 'a', isGlob: true, glob: '?/c.md' }
119
120globBase('a/??/c.js');
121//=> { base: 'a', isGlob: true, glob: '??/c.js' }
122
123globBase('a?b');
124//=> { base: '.', isGlob: true, glob: 'a?b' }
125
126globBase('bb');
127//=> { base: '.', isGlob: false, glob: 'bb' }
128
129globBase('c.md');
130//=> { base: '.', isGlob: false, glob: 'c.md' }
131```
132
133## Running tests
134Install dev dependencies.
135
136```bash
137npm i -d && npm test
138```
139
140
141## Contributing
142Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/glob-base/issues)
143
144
145## Author
146
147**Jon Schlinkert**
148
149+ [github/jonschlinkert](https://github.com/jonschlinkert)
150+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
151
152## License
153Copyright (c) 2015 Jon Schlinkert
154Released under the MIT license
155
156***
157
158_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 08, 2015._