bc59dc76589d4f402aee2d8ba2892b9f013d5677.svn-base
2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# minimatch
A minimal matching utility.
[![Build Status](https://secure.travis-ci.org/isaacs/minimatch.png)](http://travis-ci.org/isaacs/minimatch)
This is the matching library used internally by npm.
Eventually, it will replace the C binding in node-glob.
It works by converting glob expressions into JavaScript `RegExp`
objects.
## Usage
```javascript
var minimatch = require("minimatch")
minimatch("bar.foo", "*.foo") // true!
minimatch("bar.foo", "*.bar") // false!
```
## Features
Supports all glob features.
See:
* `man sh`
* `man fnmatch`
* `man 5 gitignore`
### Departures from zsh/bash/ksh/sh
If the pattern starts with a `!` character, then it is negated.
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.)
The double-star `**` is always supported, instead of requiring a special
flag.
If an escaped pattern has no matches, and the `null` flag is not set,
then minimatch.match returns the pattern as-provided, rather than
interpreting the character escapes. For example,
`minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than
`"*a?"`.
## Functions
### minimatch(path, pattern, options)
Main export. Tests a path against
the pattern using the options.
### minimatch.filter(pattern, options)
Returns a function that tests its
supplied argument, suitable for use with `Array.filter`.
### minimatch.match(list, pattern, options)
Match against the list of
files, in the style of fnmatch or glob. If nothing is matched, then
return the pattern (unless `{ null: true }` in the options.)
### minimatch.makeRe(pattern, options)
Make a regular expression object
from the pattern.
## Options
All options are `false` by default.
### debug
Dump a ton of stuff to stderr.
### null
Return an empty list from minimatch.match, instead of a list
containing the pattern itself.
### nocase
Perform a case-insensitive match.
### cache
An LRU cache with `.get(k)` and `.set(k,v)` methods. By
default, an instance of `node-lru-cache` is used, with 1000 max
entries.
### slash
If set, then `a/*` will match `a/` as well as `a/b`.
### matchBase
If set, then patterns without slashes will be matched
against the basename of the path if it contains slashes. For example,
`a?b` would match `xyz/123/acb`.
### partial
Internal. Used by `minimatch.makeRe`.
### dot
Allow patterns to match paths starting with a period, even if
the pattern does not explicitly start with a period.