Compare commits

..

13 Commits

Author SHA1 Message Date
guenter.baumgart
392278f84f latest 2021-12-11 22:48:56 +01:00
guenter.baumgart
174ed61057 npm rebase 2021-12-11 22:38:14 +01:00
Jon Schlinkert
d8e155968e
remove funding file 2019-06-15 23:55:07 -04:00
Jon Schlinkert
cde2c89ef4
Create FUNDING.yml 2019-05-25 04:51:51 -04:00
Jon Schlinkert
9c4e6b4d49
Merge pull request #4 from micromatch/lodash
Remove lodash from dev dependencies as unused
2019-05-23 16:24:40 -04:00
Daniel Tschinder
67f59a53ba Fix tests 2019-05-23 10:46:32 -07:00
Daniel Tschinder
f82263c168 Remove lodash from dev dependencies as unused 2019-05-23 10:37:45 -07:00
jonschlinkert
9bfccb63ac 3.0.4 2015-09-22 11:18:18 -04:00
jonschlinkert
3492b6778b fix license format in package.json,
update readme, other metadata
2015-09-22 11:17:53 -04:00
jonschlinkert
92b8feaeb9 3.0.3 2015-09-22 11:14:16 -04:00
jonschlinkert
adc9d6ad47 prepublish 2015-09-22 11:14:02 -04:00
Jon Schlinkert
48570388ec Merge pull request #2 from es128/patch-1
Update deps
2015-09-22 10:21:59 -04:00
Elan Shanker
7c1c72dba1 Update deps 2015-09-22 10:05:38 -04:00
3 changed files with 262 additions and 200 deletions

View File

@ -1,23 +1,23 @@
# parse-glob [![NPM version](https://badge.fury.io/js/parse-glob.svg)](http://badge.fury.io/js/parse-glob) [![Build Status](https://travis-ci.org/jonschlinkert/parse-glob.svg)](https://travis-ci.org/jonschlinkert/parse-glob) # parse-glob [![NPM version](https://badge.fury.io/js/parse-glob.svg)](http://badge.fury.io/js/parse-glob) [![Build Status](https://travis-ci.org/jonschlinkert/parse-glob.svg)](https://travis-ci.org/jonschlinkert/parse-glob)
> Parse a glob pattern into an object of tokens. > Parse a glob pattern into an object of tokens.
**Changes from v1.0.0 to v3.0.2** **Changes from v1.0.0 to v3.0.4**
- 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
- adds `base` property * adds `base` property
See the [properties](#properties) section for details. See the [properties](#properties) section for details.
## Install with [npm](npmjs.org) Install with [npm](https://www.npmjs.com/)
```bash ```sh
npm i parse-glob --save $ npm i parse-glob --save
``` ```
- parses 1,000+ glob patterns in 29ms (2.3 GHz Intel Core i7) * parses 1,000+ glob patterns in 29ms (2.3 GHz Intel Core i7)
- Extensive [unit tests](./test.js) (more than 1,000 lines), covering wildcards, globstars, character classes, brace patterns, extglobs, dotfiles and other complex patterns. * Extensive [unit tests](./test.js) (more than 1,000 lines), covering wildcards, globstars, character classes, brace patterns, extglobs, dotfiles and other complex patterns.
See the tests for [hundreds of examples](./test.js). See the tests for [hundreds of examples](./test.js).
@ -60,43 +60,42 @@ parseGlob('a/b/c/**/*.{yml,json}');
The object returned by parseGlob has the following properties: The object returned by parseGlob has the following properties:
- `orig`: a copy of the original, unmodified glob pattern * `orig`: a copy of the original, unmodified glob pattern
- `is`: an object with boolean information about the glob: * `is`: an object with boolean information about the glob:
+ `glob`: true if the pattern actually a glob pattern - `glob`: true if the pattern actually a glob pattern
+ `negated`: true if it's a negation pattern (`!**/foo.js`) - `negated`: true if it's a negation pattern (`!**/foo.js`)
+ `extglob`: true if it has extglobs (`@(foo|bar)`) - `extglob`: true if it has extglobs (`@(foo|bar)`)
+ `braces`: true if it has braces (`{1..2}` or `.{txt,md}`) - `braces`: true if it has braces (`{1..2}` or `.{txt,md}`)
+ `brackets`: true if it has POSIX brackets (`[[:alpha:]]`) - `brackets`: true if it has POSIX brackets (`[[:alpha:]]`)
+ `globstar`: true if the pattern has a globstar (double star, `**`) - `globstar`: true if the pattern has a globstar (double star, `**`)
+ `dotfile`: true if the pattern should match dotfiles - `dotfile`: true if the pattern should match dotfiles
+ `dotdir`: true if the pattern should match dot-directories (like `.git`) - `dotdir`: true if the pattern should match dot-directories (like `.git`)
- `glob`: the glob pattern part of the string, if any * `glob`: the glob pattern part of the string, if any
- `base`: the non-glob part of the string, if any * `base`: the non-glob part of the string, if any
- `path`: file path segments * `path`: file path segments
+ `dirname`: directory - `dirname`: directory
+ `basename`: file name with extension - `basename`: file name with extension
+ `filename`: file name without extension - `filename`: file name without extension
+ `extname`: file extension with dot - `extname`: file extension with dot
+ `ext`: file extension without dot - `ext`: file extension without dot
## Related ## Related
* [glob-base](https://www.npmjs.com/package/glob-base): Returns an object with the (non-glob) base path and the actual pattern. | [homepage](https://github.com/jonschlinkert/glob-base)
* [glob-base](https://github.com/jonschlinkert/glob-base): Returns an object with the (non-glob) base path and the… [more](https://github.com/jonschlinkert/glob-base) * [glob-parent](https://www.npmjs.com/package/glob-parent): Strips glob magic from a string to provide the parent path | [homepage](https://github.com/es128/glob-parent)
* [glob-parent](https://github.com/es128/glob-parent): Strips glob magic from a string to provide the parent… [more](https://github.com/es128/glob-parent) * [glob-path-regex](https://www.npmjs.com/package/glob-path-regex): Regular expression for matching the parts of glob pattern. | [homepage](https://github.com/regexps/glob-path-regex)
* [glob-path-regex](https://github.com/regexps/glob-path-regex): Regular expression for matching the parts of glob pattern. * [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern. | [homepage](https://github.com/jonschlinkert/is-glob)
* [is-glob](https://github.com/jonschlinkert/is-glob): Returns `true` if the given string looks like a glob… [more](https://github.com/jonschlinkert/is-glob) * [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just… [more](https://www.npmjs.com/package/micromatch) | [homepage](https://github.com/jonschlinkert/micromatch)
* [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative… [more](https://github.com/jonschlinkert/micromatch)
## Contributing ## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/parse-glob/issues) Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/parse-glob/issues/new).
## Tests ## Tests
Install dev dependencies: Install dev dependencies:
```bash ```sh
npm i -d && npm test $ npm i -d && npm test
``` ```
## Author ## Author
@ -108,15 +107,9 @@ npm i -d && npm test
## License ## License
Copyright (c) 2014-2015 Jon Schlinkert Copyright © 2014-2015 Jon Schlinkert
Released under the MIT license. Released under the MIT license.
*** ***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 25, 2015._ _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 22, 2015._
<!-- reflinks generated by verb-reflinks plugin -->
[verb]: https://github.com/assemble/verb
[template]: https://github.com/jonschlinkert/template
[assemble]: http://assemble.io

View File

@ -156,8 +156,120 @@ function unescape(str) {
return str; return str;
} }
},{"glob-base":4,"is-dotfile":7,"is-extglob":8,"is-glob":9}],2:[function(require,module,exports){ },{"glob-base":2,"is-dotfile":4,"is-extglob":5,"is-glob":6}],2:[function(require,module,exports){
/*!
* glob-base <https://github.com/jonschlinkert/glob-base>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
var path = require('path');
var parent = require('glob-parent');
var isGlob = require('is-glob');
module.exports = function globBase(pattern) {
if (typeof pattern !== 'string') {
throw new TypeError('glob-base expects a string.');
}
var res = {};
res.base = parent(pattern);
res.isGlob = isGlob(pattern);
if (res.base !== '.') {
res.glob = pattern.substr(res.base.length);
if (res.glob.charAt(0) === '/') {
res.glob = res.glob.substr(1);
}
} else {
res.glob = pattern;
}
if (!res.isGlob) {
res.base = dirname(pattern);
res.glob = res.base !== '.'
? pattern.substr(res.base.length)
: pattern;
}
if (res.glob.substr(0, 2) === './') {
res.glob = res.glob.substr(2);
}
if (res.glob.charAt(0) === '/') {
res.glob = res.glob.substr(1);
}
return res;
};
function dirname(glob) {
if (glob.slice(-1) === '/') return glob;
return path.dirname(glob);
}
},{"glob-parent":3,"is-glob":6,"path":7}],3:[function(require,module,exports){
'use strict';
var path = require('path');
var isglob = require('is-glob');
module.exports = function globParent(str) {
str += 'a'; // preserves full path in case of trailing path separator
do {str = path.dirname(str)} while (isglob(str));
return str;
};
},{"is-glob":6,"path":7}],4:[function(require,module,exports){
/*!
* is-dotfile <https://github.com/jonschlinkert/is-dotfile>
*
* Copyright (c) 2015-2017, Jon Schlinkert.
* Released under the MIT License.
*/
module.exports = function(str) {
if (str.charCodeAt(0) === 46 /* . */ && str.indexOf('/', 1) === -1) {
return true;
}
var slash = str.lastIndexOf('/');
return slash !== -1 ? str.charCodeAt(slash + 1) === 46 /* . */ : false;
};
},{}],5:[function(require,module,exports){
/*!
* is-extglob <https://github.com/jonschlinkert/is-extglob>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
module.exports = function isExtglob(str) {
return typeof str === 'string'
&& /[@?!+*]\(/.test(str);
};
},{}],6:[function(require,module,exports){
/*!
* is-glob <https://github.com/jonschlinkert/is-glob>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
var isExtglob = require('is-extglob');
module.exports = function isGlob(str) {
return typeof str === 'string'
&& (/[*!?{}(|)[\]]/.test(str)
|| isExtglob(str));
};
},{"is-extglob":5}],7:[function(require,module,exports){
(function (process){ (function (process){
// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
// backported and transplited with Babel, with backwards-compat fixes
// Copyright Joyent, Inc. and other Node contributors. // Copyright Joyent, Inc. and other Node contributors.
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
@ -209,14 +321,6 @@ function normalizeArray(parts, allowAboveRoot) {
return parts; return parts;
} }
// Split a filename into [root, dir, basename, ext], unix version
// 'root' is just a slash, or nothing.
var splitPathRe =
/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
var splitPath = function(filename) {
return splitPathRe.exec(filename).slice(1);
};
// path.resolve([from ...], to) // path.resolve([from ...], to)
// posix version // posix version
exports.resolve = function() { exports.resolve = function() {
@ -332,37 +436,120 @@ exports.relative = function(from, to) {
exports.sep = '/'; exports.sep = '/';
exports.delimiter = ':'; exports.delimiter = ':';
exports.dirname = function(path) { exports.dirname = function (path) {
var result = splitPath(path), if (typeof path !== 'string') path = path + '';
root = result[0], if (path.length === 0) return '.';
dir = result[1]; var code = path.charCodeAt(0);
var hasRoot = code === 47 /*/*/;
if (!root && !dir) { var end = -1;
// No dirname whatsoever var matchedSlash = true;
return '.'; for (var i = path.length - 1; i >= 1; --i) {
code = path.charCodeAt(i);
if (code === 47 /*/*/) {
if (!matchedSlash) {
end = i;
break;
}
} else {
// We saw the first non-path separator
matchedSlash = false;
}
} }
if (dir) { if (end === -1) return hasRoot ? '/' : '.';
// It has a dirname, strip trailing slash if (hasRoot && end === 1) {
dir = dir.substr(0, dir.length - 1); // return '//';
// Backwards-compat fix:
return '/';
} }
return path.slice(0, end);
return root + dir;
}; };
function basename(path) {
if (typeof path !== 'string') path = path + '';
exports.basename = function(path, ext) { var start = 0;
var f = splitPath(path)[2]; var end = -1;
// TODO: make this comparison case-insensitive on windows? var matchedSlash = true;
var i;
for (i = path.length - 1; i >= 0; --i) {
if (path.charCodeAt(i) === 47 /*/*/) {
// If we reached a path separator that was not part of a set of path
// separators at the end of the string, stop now
if (!matchedSlash) {
start = i + 1;
break;
}
} else if (end === -1) {
// We saw the first non-path separator, mark this as the end of our
// path component
matchedSlash = false;
end = i + 1;
}
}
if (end === -1) return '';
return path.slice(start, end);
}
// Uses a mixed approach for backwards-compatibility, as ext behavior changed
// in new Node.js versions, so only basename() above is backported here
exports.basename = function (path, ext) {
var f = basename(path);
if (ext && f.substr(-1 * ext.length) === ext) { if (ext && f.substr(-1 * ext.length) === ext) {
f = f.substr(0, f.length - ext.length); f = f.substr(0, f.length - ext.length);
} }
return f; return f;
}; };
exports.extname = function (path) {
if (typeof path !== 'string') path = path + '';
var startDot = -1;
var startPart = 0;
var end = -1;
var matchedSlash = true;
// Track the state of characters (if any) we see before our first dot and
// after any path separator we find
var preDotState = 0;
for (var i = path.length - 1; i >= 0; --i) {
var code = path.charCodeAt(i);
if (code === 47 /*/*/) {
// If we reached a path separator that was not part of a set of path
// separators at the end of the string, stop now
if (!matchedSlash) {
startPart = i + 1;
break;
}
continue;
}
if (end === -1) {
// We saw the first non-path separator, mark this as the end of our
// extension
matchedSlash = false;
end = i + 1;
}
if (code === 46 /*.*/) {
// If this is our first dot, mark it as the start of our extension
if (startDot === -1)
startDot = i;
else if (preDotState !== 1)
preDotState = 1;
} else if (startDot !== -1) {
// We saw a non-dot and non-path separator before our dot, so we should
// have a good chance at having a non-empty extension
preDotState = -1;
}
}
exports.extname = function(path) { if (startDot === -1 || end === -1 ||
return splitPath(path)[3]; // We saw a non-dot character immediately before the dot
preDotState === 0 ||
// The (right-most) trimmed path component is exactly '..'
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
return '';
}
return path.slice(startDot, end);
}; };
function filter (xs, f) { function filter (xs, f) {
@ -384,7 +571,7 @@ var substr = 'ab'.substr(-1) === 'b'
; ;
}).call(this,require('_process')) }).call(this,require('_process'))
},{"_process":3}],3:[function(require,module,exports){ },{"_process":8}],8:[function(require,module,exports){
// shim for using process in browser // shim for using process in browser
var process = module.exports = {}; var process = module.exports = {};
@ -444,112 +631,4 @@ process.chdir = function (dir) {
}; };
process.umask = function() { return 0; }; process.umask = function() { return 0; };
},{}],4:[function(require,module,exports){ },{}]},{},[1]);
/*!
* glob-base <https://github.com/jonschlinkert/glob-base>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
var path = require('path');
var parent = require('glob-parent');
module.exports = function globBase(pattern) {
if (typeof pattern !== 'string') {
throw new TypeError('glob-base expects a string.');
}
var res = {};
res.base = parent(pattern);
res.isGlob = res.base !== pattern;
if (res.base !== '.') {
res.glob = pattern.substr(res.base.length);
if (res.glob.charAt(0) === '/') {
res.glob = res.glob.substr(1);
}
} else {
res.glob = pattern;
}
if (!res.isGlob) {
res.base = dirname(pattern);
res.glob = res.base !== '.'
? pattern.substr(res.base.length)
: pattern;
}
if (res.glob.substr(0, 2) === './') {
res.glob = res.glob.substr(2);
}
if (res.glob.charAt(0) === '/') {
res.glob = res.glob.substr(1);
}
return res;
};
function dirname(glob) {
if (glob.slice(-1) === '/') return glob;
return path.dirname(glob);
}
},{"glob-parent":5,"path":2}],5:[function(require,module,exports){
'use strict';
var path = require('path');
var isglob = require('is-glob');
module.exports = function globParent(str) {
while (isglob(str)) str = path.dirname(str);
return str;
};
},{"is-glob":6,"path":2}],6:[function(require,module,exports){
/*!
* is-glob <https://github.com/jonschlinkert/is-glob>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
module.exports = function isGlob(str) {
return typeof str === 'string'
&& /[!*{}?(|)[\]]/.test(str);
};
},{}],7:[function(require,module,exports){
/*!
* is-dotfile <https://github.com/regexps/is-dotfile>
*
* Copyright (c) 2015 Jon Schlinkert, contributors.
* Licensed under the MIT license.
*/
module.exports = function(str) {
if (str.charCodeAt(0) === 46 /* . */ && str.indexOf('/', 1) === -1) {
return true;
}
var last = str.lastIndexOf('/');
return last !== -1 ? str.charCodeAt(last + 1) === 46 /* . */ : false;
};
},{}],8:[function(require,module,exports){
/*!
* is-extglob <https://github.com/jonschlinkert/is-extglob>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
module.exports = function isExtglob(str) {
return typeof str === 'string'
&& /[@?!+*]\(/.test(str);
};
},{}],9:[function(require,module,exports){
arguments[4][6][0].apply(exports,arguments)
},{"dup":6}]},{},[1]);

View File

@ -1,23 +1,14 @@
{ {
"name": "parse-glob", "name": "@plastichub/parse-glob",
"description": "Parse a glob pattern into an object of tokens.", "description": "Parse a glob pattern into an object of tokens.",
"version": "3.0.2", "version": "3.0.5",
"homepage": "https://github.com/jonschlinkert/parse-glob", "homepage": "https://github.com/jonschlinkert/parse-glob",
"author": { "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"name": "Jon Schlinkert", "repository": "jonschlinkert/parse-glob",
"url": "https://github.com/jonschlinkert"
},
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/parse-glob.git"
},
"bugs": { "bugs": {
"url": "https://github.com/jonschlinkert/parse-glob/issues" "url": "https://github.com/jonschlinkert/parse-glob/issues"
}, },
"license": { "license": "MIT",
"type": "MIT",
"url": "https://github.com/jonschlinkert/parse-glob/blob/master/LICENSE"
},
"files": [ "files": [
"index.js" "index.js"
], ],
@ -30,15 +21,14 @@
"prepublish": "browserify -o browser.js -e index.js" "prepublish": "browserify -o browser.js -e index.js"
}, },
"dependencies": { "dependencies": {
"glob-base": "^0.2.0", "glob-base": "^0.3.0",
"is-dotfile": "^1.0.0", "is-dotfile": "^1.0.0",
"is-extglob": "^1.0.0", "is-extglob": "^1.0.0",
"is-glob": "^1.1.3" "is-glob": "^2.0.0"
}, },
"devDependencies": { "devDependencies": {
"browserify": "^9.0.3", "browserify": "^9.0.3",
"lodash": "^3.3.1", "mocha": "^3.0.0"
"mocha": "*"
}, },
"keywords": [ "keywords": [
"glob", "glob",