From e1dca4d7722ba3387486a3721c6c51ece61744db Mon Sep 17 00:00:00 2001 From: jonschlinkert Date: Sun, 8 Mar 2015 22:00:41 -0400 Subject: [PATCH] update/rebuild docs --- .verb.md | 107 +++++++++++++++++++++------------------------------- README.md | 111 ++++++++++++++++++++++-------------------------------- 2 files changed, 86 insertions(+), 132 deletions(-) diff --git a/.verb.md b/.verb.md index 750c7de..d16000e 100644 --- a/.verb.md +++ b/.verb.md @@ -2,7 +2,7 @@ > {%= 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 boolean properties are now on the `is` object @@ -21,82 +21,59 @@ See the tests for [hundreds of examples](./test.js). ```js var parseGlob = require('{%= name %}'); -parseGlob('a/b/{c,d}/*.js'); +``` + +**Example** + +```js +parseGlob('a/b/c/**/*.{yml,json}'); ``` **Returns:** ```js -{ path: - { dirname: 'a/b/{c,d}/', - filename: '*.js', - basename: '*', - extname: '.js', - ext: 'js' }, - is: { glob: true, braces: true, negated: false, globstar: false, - dotfile: false, dotdir: false }, - original: 'a/b/{c,d}/*.js', - pattern: 'a/b/{c,d}/*.js' } +{ orig: 'a/b/c/**/*.{yml,json}', + is: + { glob: true, + negated: false, + extglob: false, + braces: true, + brackets: false, + globstar: true, + dotfile: false, + 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 The object returned by parseGlob has the following properties: -- `pattern`: the 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 +- `orig`: a copy of the original, unmodified glob pattern - `is`: an object with boolean information about the glob: - + `is.glob`: true if the pattern actually a glob pattern - + `is.negated`: true if it's a negation pattern (`!**/foo.js`) - + `is.globstar`: true if the pattern has a double star (`**`) - + `is.dotfile`: true if the pattern should match dotfiles - + `is.dotdir`: true if the pattern should match dot-directories (like `.git`) - - -### base property - -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. - -**Examples** - -Without `base` defined: - -```js -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' } -``` + + `glob`: true if the pattern actually a glob pattern + + `negated`: true if it's a negation pattern (`!**/foo.js`) + + `extglob`: true if it has extglobs (`@(foo|bar)`) + + `braces`: true if it has braces (`{1..2}` or `.{txt,md}`) + + `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 + + `dotdir`: true if the pattern should match dot-directories (like `.git`) +- `glob`: the glob pattern part of the string, if any +- `base`: the non-glob part of the string, if any +- `path`: file path segments + + `dirname`: directory + + `basename`: file name with extension + + `filename`: file name without extension + + `extname`: file extension with dot + + `ext`: file extension without dot ## Related {%= related(['glob-base', 'glob-parent', 'is-glob', 'glob-path-regex', 'micromatch']) %} diff --git a/README.md b/README.md index 1416910..68d42c8 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > 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 boolean properties are now on the `is` object @@ -25,85 +25,62 @@ See the tests for [hundreds of examples](./test.js). ```js var parseGlob = require('parse-glob'); -parseGlob('a/b/{c,d}/*.js'); +``` + +**Example** + +```js +parseGlob('a/b/c/**/*.{yml,json}'); ``` **Returns:** ```js -{ path: - { dirname: 'a/b/{c,d}/', - filename: '*.js', - basename: '*', - extname: '.js', - ext: 'js' }, - is: { glob: true, braces: true, negated: false, globstar: false, - dotfile: false, dotdir: false }, - original: 'a/b/{c,d}/*.js', - pattern: 'a/b/{c,d}/*.js' } +{ orig: 'a/b/c/**/*.{yml,json}', + is: + { glob: true, + negated: false, + extglob: false, + braces: true, + brackets: false, + globstar: true, + dotfile: false, + 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 The object returned by parseGlob has the following properties: -- `pattern`: the 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 +- `orig`: a copy of the original, unmodified glob pattern - `is`: an object with boolean information about the glob: - + `is.glob`: true if the pattern actually a glob pattern - + `is.negated`: true if it's a negation pattern (`!**/foo.js`) - + `is.globstar`: true if the pattern has a double star (`**`) - + `is.dotfile`: true if the pattern should match dotfiles - + `is.dotdir`: true if the pattern should match dot-directories (like `.git`) - - -### base property - -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. - -**Examples** - -Without `base` defined: - -```js -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' } -``` + + `glob`: true if the pattern actually a glob pattern + + `negated`: true if it's a negation pattern (`!**/foo.js`) + + `extglob`: true if it has extglobs (`@(foo|bar)`) + + `braces`: true if it has braces (`{1..2}` or `.{txt,md}`) + + `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 + + `dotdir`: true if the pattern should match dot-directories (like `.git`) +- `glob`: the glob pattern part of the string, if any +- `base`: the non-glob part of the string, if any +- `path`: file path segments + + `dirname`: directory + + `basename`: file name with extension + + `filename`: file name without extension + + `extname`: file extension with dot + + `ext`: file extension without dot ## 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 * [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. @@ -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._