update/rebuild docs

This commit is contained in:
jonschlinkert 2015-03-08 22:00:41 -04:00
parent 918723a276
commit e1dca4d772
2 changed files with 86 additions and 132 deletions

107
.verb.md
View File

@ -2,7 +2,7 @@
> {%= description %} > {%= description %}
**BREAKING CHANGES in 2.0** **Changes from v1.0.0 to v{%= version %}**
- all path-related properties are now on the `path` object - all path-related properties are now on the `path` object
- all boolean properties are now on the `is` object - all boolean properties are now on the `is` object
@ -21,82 +21,59 @@ See the tests for [hundreds of examples](./test.js).
```js ```js
var parseGlob = require('{%= name %}'); var parseGlob = require('{%= name %}');
parseGlob('a/b/{c,d}/*.js'); ```
**Example**
```js
parseGlob('a/b/c/**/*.{yml,json}');
``` ```
**Returns:** **Returns:**
```js ```js
{ path: { orig: 'a/b/c/**/*.{yml,json}',
{ dirname: 'a/b/{c,d}/', is:
filename: '*.js', { glob: true,
basename: '*', negated: false,
extname: '.js', extglob: false,
ext: 'js' }, braces: true,
is: { glob: true, braces: true, negated: false, globstar: false, brackets: false,
dotfile: false, dotdir: false }, globstar: true,
original: 'a/b/{c,d}/*.js', dotfile: false,
pattern: 'a/b/{c,d}/*.js' } dotdir: false },
glob: '**/*.{yml,json}',
base: 'a/b/c',
path:
{ dirname: 'a/b/c/**/',
basename: '*.{yml,json}',
filename: '*',
extname: '.{yml,json}',
ext: '{yml,json}' } }
``` ```
## Properties ## Properties
The object returned by parseGlob has the following properties: The object returned by parseGlob has the following properties:
- `pattern`: the glob pattern - `orig`: a copy of the original, unmodified glob pattern
- `base`: when `true` is passed as the second argument, a `base` path is extracted and stripped from `pattern`. See more [below](#base-property)
- `original`: a copy of the original, unmodified glob pattern
- `path`: file path segments
+ `path.dirname`: directory
+ `path.filename`: filename, including extension
+ `path.basename`: filename, without extension
+ `path.extname`: file extension, with dot
+ `path.ext`: file extension, without dot
- `is`: an object with boolean information about the glob: - `is`: an object with boolean information about the glob:
+ `is.glob`: true if the pattern actually a glob pattern + `glob`: true if the pattern actually a glob pattern
+ `is.negated`: true if it's a negation pattern (`!**/foo.js`) + `negated`: true if it's a negation pattern (`!**/foo.js`)
+ `is.globstar`: true if the pattern has a double star (`**`) + `extglob`: true if it has extglobs (`@(foo|bar)`)
+ `is.dotfile`: true if the pattern should match dotfiles + `braces`: true if it has braces (`{1..2}` or `.{txt,md}`)
+ `is.dotdir`: true if the pattern should match dot-directories (like `.git`) + `brackets`: true if it has POSIX brackets (`[[:alpha:]]`)
+ `globstar`: true if the pattern has a globstar (double star, `**`)
+ `dotfile`: true if the pattern should match dotfiles
### base property + `dotdir`: true if the pattern should match dot-directories (like `.git`)
- `glob`: the glob pattern part of the string, if any
The `base` property is created by taking any leading dirname segments in the pattern that do not contain any glob symbols (`!*{}?(|)[]`). If a base cannot be extracted, the value of `base` will be an empty string. - `base`: the non-glob part of the string, if any
- `path`: file path segments
**Examples** + `dirname`: directory
+ `basename`: file name with extension
Without `base` defined: + `filename`: file name without extension
+ `extname`: file extension with dot
```js + `ext`: file extension without dot
var tokens = parseGlob('a/b/{c,d}/*.js');
// tokens.base => 'undefined'
// tokens.pattern => 'a/b/{c,d}/*.js'
```
With `base` defined:
```js
var tokens = parseGlob('a/b/{c,d}/*.js', true);
// tokens.base => 'a/b'
// tokens.pattern => '{c,d}/*.js'
```
The resulting object would be:
```js
{ path:
{ dirname: 'a/b/{c,d}/',
filename: '*.js',
basename: '*',
extname: '.js',
ext: 'js' },
is: { glob: true, negated: false, globstar: false,
dotfile: false, dotdir: false },
original: 'a/b/{c,d}/*.js',
pattern: '{c,d}/*.js',
base: 'a/b' }
```
## Related ## Related
{%= related(['glob-base', 'glob-parent', 'is-glob', 'glob-path-regex', 'micromatch']) %} {%= related(['glob-base', 'glob-parent', 'is-glob', 'glob-path-regex', 'micromatch']) %}

111
README.md
View File

@ -2,7 +2,7 @@
> Parse a glob pattern into an object of tokens. > Parse a glob pattern into an object of tokens.
**BREAKING CHANGES in 2.0** **Changes from v1.0.0 to v3.0.0**
- all path-related properties are now on the `path` object - all path-related properties are now on the `path` object
- all boolean properties are now on the `is` object - all boolean properties are now on the `is` object
@ -25,85 +25,62 @@ See the tests for [hundreds of examples](./test.js).
```js ```js
var parseGlob = require('parse-glob'); var parseGlob = require('parse-glob');
parseGlob('a/b/{c,d}/*.js'); ```
**Example**
```js
parseGlob('a/b/c/**/*.{yml,json}');
``` ```
**Returns:** **Returns:**
```js ```js
{ path: { orig: 'a/b/c/**/*.{yml,json}',
{ dirname: 'a/b/{c,d}/', is:
filename: '*.js', { glob: true,
basename: '*', negated: false,
extname: '.js', extglob: false,
ext: 'js' }, braces: true,
is: { glob: true, braces: true, negated: false, globstar: false, brackets: false,
dotfile: false, dotdir: false }, globstar: true,
original: 'a/b/{c,d}/*.js', dotfile: false,
pattern: 'a/b/{c,d}/*.js' } dotdir: false },
glob: '**/*.{yml,json}',
base: 'a/b/c',
path:
{ dirname: 'a/b/c/**/',
basename: '*.{yml,json}',
filename: '*',
extname: '.{yml,json}',
ext: '{yml,json}' } }
``` ```
## Properties ## Properties
The object returned by parseGlob has the following properties: The object returned by parseGlob has the following properties:
- `pattern`: the glob pattern - `orig`: a copy of the original, unmodified glob pattern
- `base`: when `true` is passed as the second argument, a `base` path is extracted and stripped from `pattern`. See more [below](#base-property)
- `original`: a copy of the original, unmodified glob pattern
- `path`: file path segments
+ `path.dirname`: directory
+ `path.filename`: filename, including extension
+ `path.basename`: filename, without extension
+ `path.extname`: file extension, with dot
+ `path.ext`: file extension, without dot
- `is`: an object with boolean information about the glob: - `is`: an object with boolean information about the glob:
+ `is.glob`: true if the pattern actually a glob pattern + `glob`: true if the pattern actually a glob pattern
+ `is.negated`: true if it's a negation pattern (`!**/foo.js`) + `negated`: true if it's a negation pattern (`!**/foo.js`)
+ `is.globstar`: true if the pattern has a double star (`**`) + `extglob`: true if it has extglobs (`@(foo|bar)`)
+ `is.dotfile`: true if the pattern should match dotfiles + `braces`: true if it has braces (`{1..2}` or `.{txt,md}`)
+ `is.dotdir`: true if the pattern should match dot-directories (like `.git`) + `brackets`: true if it has POSIX brackets (`[[:alpha:]]`)
+ `globstar`: true if the pattern has a globstar (double star, `**`)
+ `dotfile`: true if the pattern should match dotfiles
### base property + `dotdir`: true if the pattern should match dot-directories (like `.git`)
- `glob`: the glob pattern part of the string, if any
The `base` property is created by taking any leading dirname segments in the pattern that do not contain any glob symbols (`!*{}?(|)[]`). If a base cannot be extracted, the value of `base` will be an empty string. - `base`: the non-glob part of the string, if any
- `path`: file path segments
**Examples** + `dirname`: directory
+ `basename`: file name with extension
Without `base` defined: + `filename`: file name without extension
+ `extname`: file extension with dot
```js + `ext`: file extension without dot
var tokens = parseGlob('a/b/{c,d}/*.js');
// tokens.base => 'undefined'
// tokens.pattern => 'a/b/{c,d}/*.js'
```
With `base` defined:
```js
var tokens = parseGlob('a/b/{c,d}/*.js', true);
// tokens.base => 'a/b'
// tokens.pattern => '{c,d}/*.js'
```
The resulting object would be:
```js
{ path:
{ dirname: 'a/b/{c,d}/',
filename: '*.js',
basename: '*',
extname: '.js',
ext: 'js' },
is: { glob: true, negated: false, globstar: false,
dotfile: false, dotdir: false },
original: 'a/b/{c,d}/*.js',
pattern: '{c,d}/*.js',
base: 'a/b' }
```
## Related ## Related
* [glob-base](https://github.com/jonschlinkert/glob-base): Split a glob into a base path and a pattern. * [glob-base](https://github.com/jonschlinkert/glob-base): Returns an object with the (non-glob) base path and the actual pattern.
* [glob-parent](https://github.com/es128/glob-parent): Strips glob magic from a string to provide the parent path * [glob-parent](https://github.com/es128/glob-parent): Strips glob magic from a string to provide the parent path
* [is-glob](https://github.com/jonschlinkert/is-glob): Returns `true` if the given string looks like a glob pattern. * [is-glob](https://github.com/jonschlinkert/is-glob): Returns `true` if the given string looks like a glob pattern.
* [glob-path-regex](https://github.com/regexps/glob-path-regex): Regular expression for matching the parts of glob pattern. * [glob-path-regex](https://github.com/regexps/glob-path-regex): Regular expression for matching the parts of glob pattern.
@ -134,4 +111,4 @@ Released under the MIT license
*** ***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 06, 2015._ _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 08, 2015._