# Glob
Match files using the patterns the shell uses, like stars and stuff.
This is a glob implementation in JavaScript. It uses the `minimatch`
library to do its matching.
## Attention: node-glob users!
The API has changed dramatically between 2.x and 3.x. This library is
now 100% JavaScript, and the integer flags have been replaced with an
options object.
Also, there's an event emitter class, proper tests, and all the other
things you've come to expect from node modules.
And best of all, no compilation!
## Usage
```javascript
var glob = require("glob")
// options is optional
glob("**/*.js", options, function (er, files) {
// files is an array of filenames.
// If the `nonull` option is set, and nothing
// was found, then files is ["**/*.js"]
// er is an error object or null.
})
```
## Features
Please see the [minimatch
documentation](https://github.com/isaacs/minimatch) for more details.
Supports these glob features:
* Brace Expansion
* Extended glob matching
* "Globstar" `**` matching
See:
* `man sh`
* `man bash`
* `man 3 fnmatch`
* `man 5 gitignore`
* [minimatch documentation](https://github.com/isaacs/minimatch)
## glob(pattern, [options], cb)
* `pattern` {String} Pattern to be matched
* `options` {Object}
* `cb` {Function}
* `err` {Error | null}
* `matches` {Array<String>} filenames found matching the pattern
Perform an asynchronous glob search.
## glob.sync(pattern, [options])
* `pattern` {String} Pattern to be matched
* `options` {Object}
* return: {Array<String>} filenames found matching the pattern
Perform a synchronous glob search.
## Class: glob.Glob
Create a Glob object by instanting the `glob.Glob` class.
```javascript
var Glob = require("glob").Glob
var mg = new Glob(pattern, options, cb)
```
It's an EventEmitter, and starts walking the filesystem to find matches
immediately.
### new glob.Glob(pattern, [options], [cb])
* `pattern` {String} pattern to search for
* `options` {Object}
* `cb` {Function} Called when an error occurs, or matches are found
* `err` {Error | null}
* `matches` {Array<String>} filenames found matching the pattern
Note that if the `sync` flag is set in the options, then matches will
be immediately available on the `g.found` member.
### Properties
* `minimatch` The minimatch object that the glob uses.
* `options` The options object passed in.
* `error` The error encountered. When an error is encountered, the
glob object is in an undefined state, and should be discarded.
* `aborted` Boolean which is set to true when calling `abort()`. There
is no way at this time to continue a glob search after aborting, but
you can re-use the statCache to avoid having to duplicate syscalls.
* `statCache` Collection of all the stat results the glob search
performed.
* `cache` Convenience object. Each field has the following possible
values:
* `false` - Path does not exist
* `true` - Path exists
* `1` - Path exists, and is not a directory
* `2` - Path exists, and is a directory
* `[file, entries, ...]` - Path exists, is a directory, and the
array value is the results of `fs.readdir`
### Events
* `end` When the matching is finished, this is emitted with all the
matches found. If the `nonull` option is set, and no match was found,
then the `matches` list contains the original pattern. The matches
are sorted, unless the `nosort` flag is set.
* `match` Every time a match is found, this is emitted with the matched.
* `error` Emitted when an unexpected error is encountered, or whenever
any fs error occurs if `options.strict` is set.
* `abort` When `abort()` is called, this event is raised.
### Methods
* `abort` Stop the search.
### Options
All the options that can be passed to Minimatch can also be passed to
Glob to change pattern matching behavior. Also, some have been added,
or have glob-specific ramifications.
All options are false by default, unless otherwise noted.
All options are added to the glob object, as well.
* `cwd` The current working directory in which to search. Defaults
to `process.cwd()`.
* `root` The place where patterns starting with `/` will be mounted
onto. Defaults to `path.resolve(options.cwd, "/")` (`/` on Unix
systems, and `C:\` or some such on Windows.)
* `dot` Include `.dot` files in normal matches and `globstar` matches.
Note that an explicit dot in a portion of the pattern will always
match dot files.
* `nomount` By default, a pattern starting with a forward-slash will be
"mounted" onto the root setting, so that a valid filesystem path is
returned. Set this flag to disable that behavior.
* `mark` Add a `/` character to directory matches. Note that this
requires additional stat calls.
* `nosort` Don't sort the results.
* `stat` Set to true to stat *all* results. This reduces performance
somewhat, and is completely unnecessary, unless `readdir` is presumed
to be an untrustworthy indicator of file existence. It will cause
ELOOP to be triggered one level sooner in the case of cyclical
symbolic links.
* `silent` When an unusual error is encountered
when attempting to read a directory, a warning will be printed to
stderr. Set the `silent` option to true to suppress these warnings.
* `strict` When an unusual error is encountered
when attempting to read a directory, the process will just continue on
in search of other matches. Set the `strict` option to raise an error
in these cases.
* `cache` See `cache` property above. Pass in a previously generated
cache object to save some fs calls.
* `statCache` A cache of results of filesystem information, to prevent
unnecessary stat calls. While it should not normally be necessary to
set this, you may pass the statCache from one glob() call to the
options object of another, if you know that the filesystem will not
change between calls. (See "Race Conditions" below.)
* `sync` Perform a synchronous glob search.
* `nounique` In some cases, brace-expanded patterns can result in the
same file showing up multiple times in the result set. By default,
this implementation prevents duplicates in the result set.
Set this flag to disable that behavior.
* `nonull` Set to never return an empty set, instead returning a set
containing the pattern itself. This is the default in glob(3).
* `nocase` Perform a case-insensitive match. Note that case-insensitive
filesystems will sometimes result in glob returning results that are
case-insensitively matched anyway, since readdir and stat will not
raise an error.
* `debug` Set to enable debug logging in minimatch and glob.
* `globDebug` Set to enable debug logging in glob, but not minimatch.
## Comparisons to other fnmatch/glob implementations
While strict compliance with the existing standards is a worthwhile
goal, some discrepancies exist between node-glob and other
implementations, and are intentional.
If the pattern starts with a `!` character, then it is negated. Set the
`nonegate` flag to suppress this behavior, and treat leading `!`
characters normally. This is perhaps relevant if you wish to start the
pattern with a negative extglob pattern like `!(a|B)`. Multiple `!`
characters at the start of a pattern will negate the pattern multiple
times.
If a pattern starts with `#`, then it is treated as a comment, and
will not match anything. Use `\#` to match a literal `#` at the
start of a line, or set the `nocomment` flag to suppress this behavior.
The double-star character `**` is supported by default, unless the
`noglobstar` flag is set. This is supported in the manner of bsdglob
and bash 4.1, where `**` only has special significance if it is the only
thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but
`a/**b` will not.
If an escaped pattern has no matches, and the `nonull` flag is set,
then glob returns the pattern as-provided, rather than
interpreting the character escapes. For example,
`glob.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than
`"*a?"`.
没有合适的资源?快使用搜索试试~ 我知道了~
grunt-cli压缩包-0.1.13版本
共133个文件
js:73个
json:14个
md:11个
5星 · 超过95%的资源 需积分: 40 126 下载量 92 浏览量
2018-03-09
15:28:06
上传
评论 4
收藏 333KB ZIP 举报
温馨提示
grunt-cli的0.1.13版本压缩包,里面带有node_modules等目录。供有需要的人使用。
资源推荐
资源详情
资源评论
收起资源包目录
grunt-cli压缩包-0.1.13版本 (133个子文件)
AUTHORS 144B
bash 2KB
cup.coffee 1B
mug.coffee 0B
CONTRIBUTORS 524B
grunt 1KB
lodash.js 240KB
lodash.compat.js 238KB
lodash.js 225KB
lodash.underscore.js 156KB
lodash.compat.min.js 33KB
lodash.min.js 28KB
minimatch.js 28KB
glob.js 19KB
lodash.underscore.min.js 18KB
nopt.js 15KB
basic.js 15KB
defaults.js 9KB
basic.js 8KB
bench.js 7KB
lru-cache.js 7KB
async.js 4KB
00-setup.js 4KB
resolver.js 4KB
resolver_sync.js 3KB
sync.js 3KB
mark.js 3KB
findup-sync_test.js 2KB
nocase-nomagic.js 2KB
foreach.js 2KB
pause-resume.js 2KB
abbrev.js 2KB
bash-comparison.js 2KB
mock.js 2KB
mock_sync.js 1KB
findup-sync.js 1KB
nopt.js 1KB
info.js 1KB
cwd-test.js 1KB
sigmund.js 1KB
root.js 1KB
test.js 1KB
my-program.js 1KB
root-nomount.js 1KB
Gruntfile.js 940B
memory-leak.js 879B
completion.js 770B
stat.js 759B
basic.js 684B
readme-issue.js 672B
inherits_browser.js 672B
brace-expand.js 647B
cli.js 606B
test.js 510B
globstar-match.js 503B
Gruntfile.js 495B
caching.js 436B
filter.js 414B
filter_sync.js 363B
core.js 288B
new-glob-optional-options.js 256B
zz-cleanup.js 251B
g.js 228B
usr-local.js 218B
extglob-ending-with-state-char.js 200B
index.js 194B
async.js 153B
core.js 110B
sync.js 103B
inherits.js 42B
index.js 39B
quux.js 20B
foo.js 20B
index.js 20B
index.js 20B
doom.js 0B
other-lib.js 0B
root.js 0B
mug.js 0B
.jshintrc 229B
bash-results.json 30KB
package.json 11KB
package.json 11KB
package.json 8KB
package.json 4KB
package.json 4KB
package.json 3KB
package.json 3KB
package.json 2KB
package.json 2KB
package.json 1KB
package.json 1KB
core.json 510B
package.json 27B
LICENSE 1KB
LICENSE 1KB
LICENSE 1KB
LICENSE 1KB
LICENSE 765B
LICENSE 765B
共 133 条
- 1
- 2
资源评论
- lijiang00720012018-05-06资源非常好,介绍的很全面,非常实用!!
- hyj_simple2019-10-15很不错,谢谢分享
- feuji2018-06-04可以下载,谢谢分享
青青木屋
- 粉丝: 295
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功