@dropthis/cli 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +171 -0
- package/dist/cli.cjs +1489 -0
- package/dist/cli.cjs.map +1 -0
- package/node_modules/@dropthis/node/README.md +90 -0
- package/node_modules/@dropthis/node/dist/index.cjs +1010 -0
- package/node_modules/@dropthis/node/dist/index.cjs.map +1 -0
- package/node_modules/@dropthis/node/dist/index.d.cts +408 -0
- package/node_modules/@dropthis/node/dist/index.d.ts +408 -0
- package/node_modules/@dropthis/node/dist/index.mjs +969 -0
- package/node_modules/@dropthis/node/dist/index.mjs.map +1 -0
- package/node_modules/@dropthis/node/package.json +55 -0
- package/node_modules/@nodelib/fs.scandir/LICENSE +21 -0
- package/node_modules/@nodelib/fs.scandir/README.md +171 -0
- package/node_modules/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
- package/node_modules/@nodelib/fs.scandir/out/adapters/fs.js +19 -0
- package/node_modules/@nodelib/fs.scandir/out/constants.d.ts +4 -0
- package/node_modules/@nodelib/fs.scandir/out/constants.js +17 -0
- package/node_modules/@nodelib/fs.scandir/out/index.d.ts +12 -0
- package/node_modules/@nodelib/fs.scandir/out/index.js +26 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/async.js +104 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/common.d.ts +1 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/common.js +13 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/sync.d.ts +5 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/sync.js +54 -0
- package/node_modules/@nodelib/fs.scandir/out/settings.d.ts +20 -0
- package/node_modules/@nodelib/fs.scandir/out/settings.js +24 -0
- package/node_modules/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
- package/node_modules/@nodelib/fs.scandir/out/types/index.js +2 -0
- package/node_modules/@nodelib/fs.scandir/out/utils/fs.d.ts +2 -0
- package/node_modules/@nodelib/fs.scandir/out/utils/fs.js +19 -0
- package/node_modules/@nodelib/fs.scandir/out/utils/index.d.ts +2 -0
- package/node_modules/@nodelib/fs.scandir/out/utils/index.js +5 -0
- package/node_modules/@nodelib/fs.scandir/package.json +44 -0
- package/node_modules/@nodelib/fs.stat/LICENSE +21 -0
- package/node_modules/@nodelib/fs.stat/README.md +126 -0
- package/node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
- package/node_modules/@nodelib/fs.stat/out/adapters/fs.js +17 -0
- package/node_modules/@nodelib/fs.stat/out/index.d.ts +12 -0
- package/node_modules/@nodelib/fs.stat/out/index.js +26 -0
- package/node_modules/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
- package/node_modules/@nodelib/fs.stat/out/providers/async.js +36 -0
- package/node_modules/@nodelib/fs.stat/out/providers/sync.d.ts +3 -0
- package/node_modules/@nodelib/fs.stat/out/providers/sync.js +23 -0
- package/node_modules/@nodelib/fs.stat/out/settings.d.ts +16 -0
- package/node_modules/@nodelib/fs.stat/out/settings.js +16 -0
- package/node_modules/@nodelib/fs.stat/out/types/index.d.ts +4 -0
- package/node_modules/@nodelib/fs.stat/out/types/index.js +2 -0
- package/node_modules/@nodelib/fs.stat/package.json +37 -0
- package/node_modules/@nodelib/fs.walk/LICENSE +21 -0
- package/node_modules/@nodelib/fs.walk/README.md +215 -0
- package/node_modules/@nodelib/fs.walk/out/index.d.ts +14 -0
- package/node_modules/@nodelib/fs.walk/out/index.js +34 -0
- package/node_modules/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
- package/node_modules/@nodelib/fs.walk/out/providers/async.js +30 -0
- package/node_modules/@nodelib/fs.walk/out/providers/index.d.ts +4 -0
- package/node_modules/@nodelib/fs.walk/out/providers/index.js +9 -0
- package/node_modules/@nodelib/fs.walk/out/providers/stream.d.ts +12 -0
- package/node_modules/@nodelib/fs.walk/out/providers/stream.js +34 -0
- package/node_modules/@nodelib/fs.walk/out/providers/sync.d.ts +10 -0
- package/node_modules/@nodelib/fs.walk/out/providers/sync.js +14 -0
- package/node_modules/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
- package/node_modules/@nodelib/fs.walk/out/readers/async.js +97 -0
- package/node_modules/@nodelib/fs.walk/out/readers/common.d.ts +7 -0
- package/node_modules/@nodelib/fs.walk/out/readers/common.js +31 -0
- package/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
- package/node_modules/@nodelib/fs.walk/out/readers/reader.js +11 -0
- package/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts +15 -0
- package/node_modules/@nodelib/fs.walk/out/readers/sync.js +59 -0
- package/node_modules/@nodelib/fs.walk/out/settings.d.ts +30 -0
- package/node_modules/@nodelib/fs.walk/out/settings.js +26 -0
- package/node_modules/@nodelib/fs.walk/out/types/index.d.ts +8 -0
- package/node_modules/@nodelib/fs.walk/out/types/index.js +2 -0
- package/node_modules/@nodelib/fs.walk/package.json +44 -0
- package/node_modules/braces/LICENSE +21 -0
- package/node_modules/braces/README.md +586 -0
- package/node_modules/braces/index.js +170 -0
- package/node_modules/braces/lib/compile.js +60 -0
- package/node_modules/braces/lib/constants.js +57 -0
- package/node_modules/braces/lib/expand.js +113 -0
- package/node_modules/braces/lib/parse.js +331 -0
- package/node_modules/braces/lib/stringify.js +32 -0
- package/node_modules/braces/lib/utils.js +122 -0
- package/node_modules/braces/package.json +77 -0
- package/node_modules/fast-glob/LICENSE +21 -0
- package/node_modules/fast-glob/README.md +830 -0
- package/node_modules/fast-glob/out/index.d.ts +40 -0
- package/node_modules/fast-glob/out/index.js +102 -0
- package/node_modules/fast-glob/out/managers/tasks.d.ts +22 -0
- package/node_modules/fast-glob/out/managers/tasks.js +110 -0
- package/node_modules/fast-glob/out/providers/async.d.ts +9 -0
- package/node_modules/fast-glob/out/providers/async.js +23 -0
- package/node_modules/fast-glob/out/providers/filters/deep.d.ts +16 -0
- package/node_modules/fast-glob/out/providers/filters/deep.js +62 -0
- package/node_modules/fast-glob/out/providers/filters/entry.d.ts +17 -0
- package/node_modules/fast-glob/out/providers/filters/entry.js +85 -0
- package/node_modules/fast-glob/out/providers/filters/error.d.ts +8 -0
- package/node_modules/fast-glob/out/providers/filters/error.js +15 -0
- package/node_modules/fast-glob/out/providers/matchers/matcher.d.ts +33 -0
- package/node_modules/fast-glob/out/providers/matchers/matcher.js +45 -0
- package/node_modules/fast-glob/out/providers/matchers/partial.d.ts +4 -0
- package/node_modules/fast-glob/out/providers/matchers/partial.js +38 -0
- package/node_modules/fast-glob/out/providers/provider.d.ts +19 -0
- package/node_modules/fast-glob/out/providers/provider.js +48 -0
- package/node_modules/fast-glob/out/providers/stream.d.ts +11 -0
- package/node_modules/fast-glob/out/providers/stream.js +31 -0
- package/node_modules/fast-glob/out/providers/sync.d.ts +9 -0
- package/node_modules/fast-glob/out/providers/sync.js +23 -0
- package/node_modules/fast-glob/out/providers/transformers/entry.d.ts +8 -0
- package/node_modules/fast-glob/out/providers/transformers/entry.js +26 -0
- package/node_modules/fast-glob/out/readers/async.d.ts +10 -0
- package/node_modules/fast-glob/out/readers/async.js +35 -0
- package/node_modules/fast-glob/out/readers/reader.d.ts +15 -0
- package/node_modules/fast-glob/out/readers/reader.js +33 -0
- package/node_modules/fast-glob/out/readers/stream.d.ts +14 -0
- package/node_modules/fast-glob/out/readers/stream.js +55 -0
- package/node_modules/fast-glob/out/readers/sync.d.ts +12 -0
- package/node_modules/fast-glob/out/readers/sync.js +43 -0
- package/node_modules/fast-glob/out/settings.d.ts +164 -0
- package/node_modules/fast-glob/out/settings.js +59 -0
- package/node_modules/fast-glob/out/types/index.d.ts +31 -0
- package/node_modules/fast-glob/out/types/index.js +2 -0
- package/node_modules/fast-glob/out/utils/array.d.ts +2 -0
- package/node_modules/fast-glob/out/utils/array.js +22 -0
- package/node_modules/fast-glob/out/utils/errno.d.ts +2 -0
- package/node_modules/fast-glob/out/utils/errno.js +7 -0
- package/node_modules/fast-glob/out/utils/fs.d.ts +4 -0
- package/node_modules/fast-glob/out/utils/fs.js +19 -0
- package/node_modules/fast-glob/out/utils/index.d.ts +8 -0
- package/node_modules/fast-glob/out/utils/index.js +17 -0
- package/node_modules/fast-glob/out/utils/path.d.ts +13 -0
- package/node_modules/fast-glob/out/utils/path.js +68 -0
- package/node_modules/fast-glob/out/utils/pattern.d.ts +49 -0
- package/node_modules/fast-glob/out/utils/pattern.js +206 -0
- package/node_modules/fast-glob/out/utils/stream.d.ts +4 -0
- package/node_modules/fast-glob/out/utils/stream.js +17 -0
- package/node_modules/fast-glob/out/utils/string.d.ts +2 -0
- package/node_modules/fast-glob/out/utils/string.js +11 -0
- package/node_modules/fast-glob/package.json +81 -0
- package/node_modules/fastq/LICENSE +13 -0
- package/node_modules/fastq/README.md +310 -0
- package/node_modules/fastq/SECURITY.md +15 -0
- package/node_modules/fastq/bench.js +66 -0
- package/node_modules/fastq/eslint.config.js +11 -0
- package/node_modules/fastq/example.js +14 -0
- package/node_modules/fastq/example.mjs +9 -0
- package/node_modules/fastq/index.d.ts +59 -0
- package/node_modules/fastq/package.json +49 -0
- package/node_modules/fastq/queue.js +346 -0
- package/node_modules/fastq/test/example.ts +83 -0
- package/node_modules/fastq/test/promise.js +325 -0
- package/node_modules/fastq/test/test.js +733 -0
- package/node_modules/fastq/test/tsconfig.json +11 -0
- package/node_modules/fill-range/LICENSE +21 -0
- package/node_modules/fill-range/README.md +237 -0
- package/node_modules/fill-range/index.js +248 -0
- package/node_modules/fill-range/package.json +74 -0
- package/node_modules/glob-parent/LICENSE +15 -0
- package/node_modules/glob-parent/README.md +137 -0
- package/node_modules/glob-parent/index.js +42 -0
- package/node_modules/glob-parent/package.json +48 -0
- package/node_modules/ignore/LICENSE-MIT +21 -0
- package/node_modules/ignore/README.md +452 -0
- package/node_modules/ignore/index.d.ts +81 -0
- package/node_modules/ignore/index.js +784 -0
- package/node_modules/ignore/legacy.js +681 -0
- package/node_modules/ignore/package.json +87 -0
- package/node_modules/is-extglob/LICENSE +21 -0
- package/node_modules/is-extglob/README.md +107 -0
- package/node_modules/is-extglob/index.js +20 -0
- package/node_modules/is-extglob/package.json +69 -0
- package/node_modules/is-glob/LICENSE +21 -0
- package/node_modules/is-glob/README.md +206 -0
- package/node_modules/is-glob/index.js +150 -0
- package/node_modules/is-glob/package.json +81 -0
- package/node_modules/is-number/LICENSE +21 -0
- package/node_modules/is-number/README.md +187 -0
- package/node_modules/is-number/index.js +18 -0
- package/node_modules/is-number/package.json +82 -0
- package/node_modules/merge2/LICENSE +21 -0
- package/node_modules/merge2/README.md +144 -0
- package/node_modules/merge2/index.js +144 -0
- package/node_modules/merge2/package.json +43 -0
- package/node_modules/micromatch/LICENSE +21 -0
- package/node_modules/micromatch/README.md +1024 -0
- package/node_modules/micromatch/index.js +474 -0
- package/node_modules/micromatch/package.json +119 -0
- package/node_modules/mime-db/HISTORY.md +541 -0
- package/node_modules/mime-db/LICENSE +23 -0
- package/node_modules/mime-db/README.md +109 -0
- package/node_modules/mime-db/db.json +9342 -0
- package/node_modules/mime-db/index.js +12 -0
- package/node_modules/mime-db/package.json +56 -0
- package/node_modules/mime-types/HISTORY.md +421 -0
- package/node_modules/mime-types/LICENSE +23 -0
- package/node_modules/mime-types/README.md +126 -0
- package/node_modules/mime-types/index.js +211 -0
- package/node_modules/mime-types/mimeScore.js +52 -0
- package/node_modules/mime-types/package.json +45 -0
- package/node_modules/picomatch/LICENSE +21 -0
- package/node_modules/picomatch/README.md +716 -0
- package/node_modules/picomatch/index.js +3 -0
- package/node_modules/picomatch/lib/constants.js +184 -0
- package/node_modules/picomatch/lib/parse.js +1392 -0
- package/node_modules/picomatch/lib/picomatch.js +342 -0
- package/node_modules/picomatch/lib/scan.js +391 -0
- package/node_modules/picomatch/lib/utils.js +64 -0
- package/node_modules/picomatch/package.json +81 -0
- package/node_modules/queue-microtask/LICENSE +20 -0
- package/node_modules/queue-microtask/README.md +90 -0
- package/node_modules/queue-microtask/index.d.ts +2 -0
- package/node_modules/queue-microtask/index.js +9 -0
- package/node_modules/queue-microtask/package.json +55 -0
- package/node_modules/reusify/.github/dependabot.yml +7 -0
- package/node_modules/reusify/.github/workflows/ci.yml +96 -0
- package/node_modules/reusify/LICENSE +22 -0
- package/node_modules/reusify/README.md +139 -0
- package/node_modules/reusify/SECURITY.md +15 -0
- package/node_modules/reusify/benchmarks/createNoCodeFunction.js +30 -0
- package/node_modules/reusify/benchmarks/fib.js +13 -0
- package/node_modules/reusify/benchmarks/reuseNoCodeFunction.js +38 -0
- package/node_modules/reusify/eslint.config.js +14 -0
- package/node_modules/reusify/package.json +50 -0
- package/node_modules/reusify/reusify.d.ts +14 -0
- package/node_modules/reusify/reusify.js +33 -0
- package/node_modules/reusify/test.js +66 -0
- package/node_modules/reusify/tsconfig.json +11 -0
- package/node_modules/run-parallel/LICENSE +20 -0
- package/node_modules/run-parallel/README.md +85 -0
- package/node_modules/run-parallel/index.js +51 -0
- package/node_modules/run-parallel/package.json +58 -0
- package/node_modules/to-regex-range/LICENSE +21 -0
- package/node_modules/to-regex-range/README.md +305 -0
- package/node_modules/to-regex-range/index.js +288 -0
- package/node_modules/to-regex-range/package.json +88 -0
- package/package.json +53 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://gulpjs.com">
|
|
3
|
+
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
# glob-parent
|
|
8
|
+
|
|
9
|
+
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Azure Pipelines Build Status][azure-pipelines-image]][azure-pipelines-url] [![Travis Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
|
|
10
|
+
|
|
11
|
+
Extract the non-magic parent path from a glob string.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
var globParent = require('glob-parent');
|
|
17
|
+
|
|
18
|
+
globParent('path/to/*.js'); // 'path/to'
|
|
19
|
+
globParent('/root/path/to/*.js'); // '/root/path/to'
|
|
20
|
+
globParent('/*.js'); // '/'
|
|
21
|
+
globParent('*.js'); // '.'
|
|
22
|
+
globParent('**/*.js'); // '.'
|
|
23
|
+
globParent('path/{to,from}'); // 'path'
|
|
24
|
+
globParent('path/!(to|from)'); // 'path'
|
|
25
|
+
globParent('path/?(to|from)'); // 'path'
|
|
26
|
+
globParent('path/+(to|from)'); // 'path'
|
|
27
|
+
globParent('path/*(to|from)'); // 'path'
|
|
28
|
+
globParent('path/@(to|from)'); // 'path'
|
|
29
|
+
globParent('path/**/*'); // 'path'
|
|
30
|
+
|
|
31
|
+
// if provided a non-glob path, returns the nearest dir
|
|
32
|
+
globParent('path/foo/bar.js'); // 'path/foo'
|
|
33
|
+
globParent('path/foo/'); // 'path/foo'
|
|
34
|
+
globParent('path/foo'); // 'path' (see issue #3 for details)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## API
|
|
38
|
+
|
|
39
|
+
### `globParent(maybeGlobString, [options])`
|
|
40
|
+
|
|
41
|
+
Takes a string and returns the part of the path before the glob begins. Be aware of Escaping rules and Limitations below.
|
|
42
|
+
|
|
43
|
+
#### options
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
{
|
|
47
|
+
// Disables the automatic conversion of slashes for Windows
|
|
48
|
+
flipBackslashes: true
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Escaping
|
|
53
|
+
|
|
54
|
+
The following characters have special significance in glob patterns and must be escaped if you want them to be treated as regular path characters:
|
|
55
|
+
|
|
56
|
+
- `?` (question mark) unless used as a path segment alone
|
|
57
|
+
- `*` (asterisk)
|
|
58
|
+
- `|` (pipe)
|
|
59
|
+
- `(` (opening parenthesis)
|
|
60
|
+
- `)` (closing parenthesis)
|
|
61
|
+
- `{` (opening curly brace)
|
|
62
|
+
- `}` (closing curly brace)
|
|
63
|
+
- `[` (opening bracket)
|
|
64
|
+
- `]` (closing bracket)
|
|
65
|
+
|
|
66
|
+
**Example**
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
globParent('foo/[bar]/') // 'foo'
|
|
70
|
+
globParent('foo/\\[bar]/') // 'foo/[bar]'
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Limitations
|
|
74
|
+
|
|
75
|
+
### Braces & Brackets
|
|
76
|
+
This library attempts a quick and imperfect method of determining which path
|
|
77
|
+
parts have glob magic without fully parsing/lexing the pattern. There are some
|
|
78
|
+
advanced use cases that can trip it up, such as nested braces where the outer
|
|
79
|
+
pair is escaped and the inner one contains a path separator. If you find
|
|
80
|
+
yourself in the unlikely circumstance of being affected by this or need to
|
|
81
|
+
ensure higher-fidelity glob handling in your library, it is recommended that you
|
|
82
|
+
pre-process your input with [expand-braces] and/or [expand-brackets].
|
|
83
|
+
|
|
84
|
+
### Windows
|
|
85
|
+
Backslashes are not valid path separators for globs. If a path with backslashes
|
|
86
|
+
is provided anyway, for simple cases, glob-parent will replace the path
|
|
87
|
+
separator for you and return the non-glob parent path (now with
|
|
88
|
+
forward-slashes, which are still valid as Windows path separators).
|
|
89
|
+
|
|
90
|
+
This cannot be used in conjunction with escape characters.
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
// BAD
|
|
94
|
+
globParent('C:\\Program Files \\(x86\\)\\*.ext') // 'C:/Program Files /(x86/)'
|
|
95
|
+
|
|
96
|
+
// GOOD
|
|
97
|
+
globParent('C:/Program Files\\(x86\\)/*.ext') // 'C:/Program Files (x86)'
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
If you are using escape characters for a pattern without path parts (i.e.
|
|
101
|
+
relative to `cwd`), prefix with `./` to avoid confusing glob-parent.
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
// BAD
|
|
105
|
+
globParent('foo \\[bar]') // 'foo '
|
|
106
|
+
globParent('foo \\[bar]*') // 'foo '
|
|
107
|
+
|
|
108
|
+
// GOOD
|
|
109
|
+
globParent('./foo \\[bar]') // 'foo [bar]'
|
|
110
|
+
globParent('./foo \\[bar]*') // '.'
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
ISC
|
|
116
|
+
|
|
117
|
+
[expand-braces]: https://github.com/jonschlinkert/expand-braces
|
|
118
|
+
[expand-brackets]: https://github.com/jonschlinkert/expand-brackets
|
|
119
|
+
|
|
120
|
+
[downloads-image]: https://img.shields.io/npm/dm/glob-parent.svg
|
|
121
|
+
[npm-url]: https://www.npmjs.com/package/glob-parent
|
|
122
|
+
[npm-image]: https://img.shields.io/npm/v/glob-parent.svg
|
|
123
|
+
|
|
124
|
+
[azure-pipelines-url]: https://dev.azure.com/gulpjs/gulp/_build/latest?definitionId=2&branchName=master
|
|
125
|
+
[azure-pipelines-image]: https://dev.azure.com/gulpjs/gulp/_apis/build/status/glob-parent?branchName=master
|
|
126
|
+
|
|
127
|
+
[travis-url]: https://travis-ci.org/gulpjs/glob-parent
|
|
128
|
+
[travis-image]: https://img.shields.io/travis/gulpjs/glob-parent.svg?label=travis-ci
|
|
129
|
+
|
|
130
|
+
[appveyor-url]: https://ci.appveyor.com/project/gulpjs/glob-parent
|
|
131
|
+
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/glob-parent.svg?label=appveyor
|
|
132
|
+
|
|
133
|
+
[coveralls-url]: https://coveralls.io/r/gulpjs/glob-parent
|
|
134
|
+
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/glob-parent/master.svg
|
|
135
|
+
|
|
136
|
+
[gitter-url]: https://gitter.im/gulpjs/gulp
|
|
137
|
+
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var isGlob = require('is-glob');
|
|
4
|
+
var pathPosixDirname = require('path').posix.dirname;
|
|
5
|
+
var isWin32 = require('os').platform() === 'win32';
|
|
6
|
+
|
|
7
|
+
var slash = '/';
|
|
8
|
+
var backslash = /\\/g;
|
|
9
|
+
var enclosure = /[\{\[].*[\}\]]$/;
|
|
10
|
+
var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/;
|
|
11
|
+
var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} str
|
|
15
|
+
* @param {Object} opts
|
|
16
|
+
* @param {boolean} [opts.flipBackslashes=true]
|
|
17
|
+
* @returns {string}
|
|
18
|
+
*/
|
|
19
|
+
module.exports = function globParent(str, opts) {
|
|
20
|
+
var options = Object.assign({ flipBackslashes: true }, opts);
|
|
21
|
+
|
|
22
|
+
// flip windows path separators
|
|
23
|
+
if (options.flipBackslashes && isWin32 && str.indexOf(slash) < 0) {
|
|
24
|
+
str = str.replace(backslash, slash);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// special case for strings ending in enclosure containing path separator
|
|
28
|
+
if (enclosure.test(str)) {
|
|
29
|
+
str += slash;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// preserves full path in case of trailing path separator
|
|
33
|
+
str += 'a';
|
|
34
|
+
|
|
35
|
+
// remove path parts that are globby
|
|
36
|
+
do {
|
|
37
|
+
str = pathPosixDirname(str);
|
|
38
|
+
} while (isGlob(str) || globby.test(str));
|
|
39
|
+
|
|
40
|
+
// remove escape chars and return result
|
|
41
|
+
return str.replace(escaped, '$1');
|
|
42
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "glob-parent",
|
|
3
|
+
"version": "5.1.2",
|
|
4
|
+
"description": "Extract the non-magic parent path from a glob string.",
|
|
5
|
+
"author": "Gulp Team <team@gulpjs.com> (https://gulpjs.com/)",
|
|
6
|
+
"contributors": [
|
|
7
|
+
"Elan Shanker (https://github.com/es128)",
|
|
8
|
+
"Blaine Bublitz <blaine.bublitz@gmail.com>"
|
|
9
|
+
],
|
|
10
|
+
"repository": "gulpjs/glob-parent",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">= 6"
|
|
14
|
+
},
|
|
15
|
+
"main": "index.js",
|
|
16
|
+
"files": [
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"index.js"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"lint": "eslint .",
|
|
22
|
+
"pretest": "npm run lint",
|
|
23
|
+
"test": "nyc mocha --async-only",
|
|
24
|
+
"azure-pipelines": "nyc mocha --async-only --reporter xunit -O output=test.xunit",
|
|
25
|
+
"coveralls": "nyc report --reporter=text-lcov | coveralls"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"is-glob": "^4.0.1"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"coveralls": "^3.0.11",
|
|
32
|
+
"eslint": "^2.13.1",
|
|
33
|
+
"eslint-config-gulp": "^3.0.1",
|
|
34
|
+
"expect": "^1.20.2",
|
|
35
|
+
"mocha": "^6.0.2",
|
|
36
|
+
"nyc": "^13.3.0"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"glob",
|
|
40
|
+
"parent",
|
|
41
|
+
"strip",
|
|
42
|
+
"path",
|
|
43
|
+
"dirname",
|
|
44
|
+
"directory",
|
|
45
|
+
"base",
|
|
46
|
+
"wildcard"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Copyright (c) 2013 Kael Zhang <i@kael.me>, contributors
|
|
2
|
+
http://kael.me/
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
5
|
+
a copy of this software and associated documentation files (the
|
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
10
|
+
the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be
|
|
13
|
+
included in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
| Linux / MacOS / Windows | Coverage | Downloads |
|
|
2
|
+
| ----------------------- | -------- | --------- |
|
|
3
|
+
| [![build][bb]][bl] | [![coverage][cb]][cl] | [![downloads][db]][dl] |
|
|
4
|
+
|
|
5
|
+
[bb]: https://github.com/kaelzhang/node-ignore/actions/workflows/nodejs.yml/badge.svg
|
|
6
|
+
[bl]: https://github.com/kaelzhang/node-ignore/actions/workflows/nodejs.yml
|
|
7
|
+
|
|
8
|
+
[cb]: https://codecov.io/gh/kaelzhang/node-ignore/branch/master/graph/badge.svg
|
|
9
|
+
[cl]: https://codecov.io/gh/kaelzhang/node-ignore
|
|
10
|
+
|
|
11
|
+
[db]: http://img.shields.io/npm/dm/ignore.svg
|
|
12
|
+
[dl]: https://www.npmjs.org/package/ignore
|
|
13
|
+
|
|
14
|
+
# ignore
|
|
15
|
+
|
|
16
|
+
`ignore` is a manager, filter and parser which implemented in pure JavaScript according to the [.gitignore spec 2.22.1](http://git-scm.com/docs/gitignore).
|
|
17
|
+
|
|
18
|
+
`ignore` is used by eslint, gitbook and [many others](https://www.npmjs.com/browse/depended/ignore).
|
|
19
|
+
|
|
20
|
+
Pay **ATTENTION** that [`minimatch`](https://www.npmjs.org/package/minimatch) (which used by `fstream-ignore`) does not follow the gitignore spec.
|
|
21
|
+
|
|
22
|
+
To filter filenames according to a .gitignore file, I recommend this npm package, `ignore`.
|
|
23
|
+
|
|
24
|
+
To parse an `.npmignore` file, you should use `minimatch`, because an `.npmignore` file is parsed by npm using `minimatch` and it does not work in the .gitignore way.
|
|
25
|
+
|
|
26
|
+
### Tested on
|
|
27
|
+
|
|
28
|
+
`ignore` is fully tested, and has more than **five hundreds** of unit tests.
|
|
29
|
+
|
|
30
|
+
- Linux + Node: `0.8` - `7.x`
|
|
31
|
+
- Windows + Node: `0.10` - `7.x`, node < `0.10` is not tested due to the lack of support of appveyor.
|
|
32
|
+
|
|
33
|
+
Actually, `ignore` does not rely on any versions of node specially.
|
|
34
|
+
|
|
35
|
+
Since `4.0.0`, ignore will no longer support `node < 6` by default, to use in node < 6, `require('ignore/legacy')`. For details, see [CHANGELOG](https://github.com/kaelzhang/node-ignore/blob/master/CHANGELOG.md).
|
|
36
|
+
|
|
37
|
+
## Table Of Main Contents
|
|
38
|
+
|
|
39
|
+
- [Usage](#usage)
|
|
40
|
+
- [`Pathname` Conventions](#pathname-conventions)
|
|
41
|
+
- See Also:
|
|
42
|
+
- [`glob-gitignore`](https://www.npmjs.com/package/glob-gitignore) matches files using patterns and filters them according to gitignore rules.
|
|
43
|
+
- [Upgrade Guide](#upgrade-guide)
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npm i ignore
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import ignore from 'ignore'
|
|
55
|
+
const ig = ignore().add(['.abc/*', '!.abc/d/'])
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Filter the given paths
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
const paths = [
|
|
62
|
+
'.abc/a.js', // filtered out
|
|
63
|
+
'.abc/d/e.js' // included
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
ig.filter(paths) // ['.abc/d/e.js']
|
|
67
|
+
ig.ignores('.abc/a.js') // true
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### As the filter function
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
paths.filter(ig.createFilter()); // ['.abc/d/e.js']
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Win32 paths will be handled
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
ig.filter(['.abc\\a.js', '.abc\\d\\e.js'])
|
|
80
|
+
// if the code above runs on windows, the result will be
|
|
81
|
+
// ['.abc\\d\\e.js']
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Why another ignore?
|
|
85
|
+
|
|
86
|
+
- `ignore` is a standalone module, and is much simpler so that it could easy work with other programs, unlike [isaacs](https://npmjs.org/~isaacs)'s [fstream-ignore](https://npmjs.org/package/fstream-ignore) which must work with the modules of the fstream family.
|
|
87
|
+
|
|
88
|
+
- `ignore` only contains utility methods to filter paths according to the specified ignore rules, so
|
|
89
|
+
- `ignore` never try to find out ignore rules by traversing directories or fetching from git configurations.
|
|
90
|
+
- `ignore` don't cares about sub-modules of git projects.
|
|
91
|
+
|
|
92
|
+
- Exactly according to [gitignore man page](http://git-scm.com/docs/gitignore), fixes some known matching issues of fstream-ignore, such as:
|
|
93
|
+
- '`/*.js`' should only match '`a.js`', but not '`abc/a.js`'.
|
|
94
|
+
- '`**/foo`' should match '`foo`' anywhere.
|
|
95
|
+
- Prevent re-including a file if a parent directory of that file is excluded.
|
|
96
|
+
- Handle trailing whitespaces:
|
|
97
|
+
- `'a '`(one space) should not match `'a '`(two spaces).
|
|
98
|
+
- `'a \ '` matches `'a '`
|
|
99
|
+
- All test cases are verified with the result of `git check-ignore`.
|
|
100
|
+
|
|
101
|
+
# Methods
|
|
102
|
+
|
|
103
|
+
## .add(pattern: string | Ignore): this
|
|
104
|
+
## .add(patterns: Array<string | Ignore>): this
|
|
105
|
+
## .add({pattern: string, mark?: string}): this since 7.0.0
|
|
106
|
+
|
|
107
|
+
- **pattern** `string | Ignore` An ignore pattern string, or the `Ignore` instance
|
|
108
|
+
- **patterns** `Array<string | Ignore>` Array of ignore patterns.
|
|
109
|
+
- **mark?** `string` Pattern mark, which is used to associate the pattern with a certain marker, such as the line no of the `.gitignore` file. Actually it could be an arbitrary string and is optional.
|
|
110
|
+
|
|
111
|
+
Adds a rule or several rules to the current manager.
|
|
112
|
+
|
|
113
|
+
Returns `this`
|
|
114
|
+
|
|
115
|
+
Notice that a line starting with `'#'`(hash) is treated as a comment. Put a backslash (`'\'`) in front of the first hash for patterns that begin with a hash, if you want to ignore a file with a hash at the beginning of the filename.
|
|
116
|
+
|
|
117
|
+
```js
|
|
118
|
+
ignore().add('#abc').ignores('#abc') // false
|
|
119
|
+
ignore().add('\\#abc').ignores('#abc') // true
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`pattern` could either be a line of ignore pattern or a string of multiple ignore patterns, which means we could just `ignore().add()` the content of a ignore file:
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
ignore()
|
|
126
|
+
.add(fs.readFileSync(filenameOfGitignore).toString())
|
|
127
|
+
.filter(filenames)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`pattern` could also be an `ignore` instance, so that we could easily inherit the rules of another `Ignore` instance.
|
|
131
|
+
|
|
132
|
+
## .ignores(pathname: [Pathname](#pathname-conventions)): boolean
|
|
133
|
+
|
|
134
|
+
> new in 3.2.0
|
|
135
|
+
|
|
136
|
+
Returns `Boolean` whether `pathname` should be ignored.
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
ig.ignores('.abc/a.js') // true
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Please **PAY ATTENTION** that `.ignores()` is **NOT** equivalent to `git check-ignore` although in most cases they return equivalent results.
|
|
143
|
+
|
|
144
|
+
However, for the purposes of imitating the behavior of `git check-ignore`, please use `.checkIgnore()` instead.
|
|
145
|
+
|
|
146
|
+
### `Pathname` Conventions:
|
|
147
|
+
|
|
148
|
+
#### 1. `Pathname` should be a `path.relative()`d pathname
|
|
149
|
+
|
|
150
|
+
`Pathname` should be a string that have been `path.join()`ed, or the return value of `path.relative()` to the current directory,
|
|
151
|
+
|
|
152
|
+
```js
|
|
153
|
+
// WRONG, an error will be thrown
|
|
154
|
+
ig.ignores('./abc')
|
|
155
|
+
|
|
156
|
+
// WRONG, for it will never happen, and an error will be thrown
|
|
157
|
+
// If the gitignore rule locates at the root directory,
|
|
158
|
+
// `'/abc'` should be changed to `'abc'`.
|
|
159
|
+
// ```
|
|
160
|
+
// path.relative('/', '/abc') -> 'abc'
|
|
161
|
+
// ```
|
|
162
|
+
ig.ignores('/abc')
|
|
163
|
+
|
|
164
|
+
// WRONG, that it is an absolute path on Windows, an error will be thrown
|
|
165
|
+
ig.ignores('C:\\abc')
|
|
166
|
+
|
|
167
|
+
// Right
|
|
168
|
+
ig.ignores('abc')
|
|
169
|
+
|
|
170
|
+
// Right
|
|
171
|
+
ig.ignores(path.join('./abc')) // path.join('./abc') -> 'abc'
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
In other words, each `Pathname` here should be a relative path to the directory of the gitignore rules.
|
|
175
|
+
|
|
176
|
+
Suppose the dir structure is:
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
/path/to/your/repo
|
|
180
|
+
|-- a
|
|
181
|
+
| |-- a.js
|
|
182
|
+
|
|
|
183
|
+
|-- .b
|
|
184
|
+
|
|
|
185
|
+
|-- .c
|
|
186
|
+
|-- .DS_store
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Then the `paths` might be like this:
|
|
190
|
+
|
|
191
|
+
```js
|
|
192
|
+
[
|
|
193
|
+
'a/a.js'
|
|
194
|
+
'.b',
|
|
195
|
+
'.c/.DS_store'
|
|
196
|
+
]
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### 2. filenames and dirnames
|
|
200
|
+
|
|
201
|
+
`node-ignore` does NO `fs.stat` during path matching, so `node-ignore` treats
|
|
202
|
+
- `foo` as a file
|
|
203
|
+
- **`foo/` as a directory**
|
|
204
|
+
|
|
205
|
+
For the example below:
|
|
206
|
+
|
|
207
|
+
```js
|
|
208
|
+
// First, we add a ignore pattern to ignore a directory
|
|
209
|
+
ig.add('config/')
|
|
210
|
+
|
|
211
|
+
// `ig` does NOT know if 'config', in the real world,
|
|
212
|
+
// is a normal file, directory or something.
|
|
213
|
+
|
|
214
|
+
ig.ignores('config')
|
|
215
|
+
// `ig` treats `config` as a file, so it returns `false`
|
|
216
|
+
|
|
217
|
+
ig.ignores('config/')
|
|
218
|
+
// returns `true`
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Specially for people who develop some library based on `node-ignore`, it is important to understand that.
|
|
222
|
+
|
|
223
|
+
Usually, you could use [`glob`](http://npmjs.org/package/glob) with `option.mark = true` to fetch the structure of the current directory:
|
|
224
|
+
|
|
225
|
+
```js
|
|
226
|
+
import glob from 'glob'
|
|
227
|
+
|
|
228
|
+
glob('**', {
|
|
229
|
+
// Adds a / character to directory matches.
|
|
230
|
+
mark: true
|
|
231
|
+
}, (err, files) => {
|
|
232
|
+
if (err) {
|
|
233
|
+
return console.error(err)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
let filtered = ignore().add(patterns).filter(files)
|
|
237
|
+
console.log(filtered)
|
|
238
|
+
})
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
## .filter(paths: Array<Pathname>): Array<Pathname>
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
type Pathname = string
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Filters the given array of pathnames, and returns the filtered array.
|
|
249
|
+
|
|
250
|
+
- **paths** `Array.<Pathname>` The array of `pathname`s to be filtered.
|
|
251
|
+
|
|
252
|
+
## .createFilter()
|
|
253
|
+
|
|
254
|
+
Creates a filter function which could filter an array of paths with `Array.prototype.filter`.
|
|
255
|
+
|
|
256
|
+
Returns `function(path)` the filter function.
|
|
257
|
+
|
|
258
|
+
## .test(pathname: Pathname): TestResult
|
|
259
|
+
|
|
260
|
+
> New in 5.0.0
|
|
261
|
+
|
|
262
|
+
Returns `TestResult`
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
// Since 5.0.0
|
|
266
|
+
interface TestResult {
|
|
267
|
+
ignored: boolean
|
|
268
|
+
// true if the `pathname` is finally unignored by some negative pattern
|
|
269
|
+
unignored: boolean
|
|
270
|
+
// The `IgnoreRule` which ignores the pathname
|
|
271
|
+
rule?: IgnoreRule
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Since 7.0.0
|
|
275
|
+
interface IgnoreRule {
|
|
276
|
+
// The original pattern
|
|
277
|
+
pattern: string
|
|
278
|
+
// Whether the pattern is a negative pattern
|
|
279
|
+
negative: boolean
|
|
280
|
+
// Which is used for other packages to build things upon `node-ignore`
|
|
281
|
+
mark?: string
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
- `{ignored: true, unignored: false}`: the `pathname` is ignored
|
|
286
|
+
- `{ignored: false, unignored: true}`: the `pathname` is unignored
|
|
287
|
+
- `{ignored: false, unignored: false}`: the `pathname` is never matched by any ignore rules.
|
|
288
|
+
|
|
289
|
+
## .checkIgnore(target: string): TestResult
|
|
290
|
+
|
|
291
|
+
> new in 7.0.0
|
|
292
|
+
|
|
293
|
+
Debugs gitignore / exclude files, which is equivalent to `git check-ignore -v`. Usually this method is used for other packages to implement the function of `git check-ignore -v` upon `node-ignore`
|
|
294
|
+
|
|
295
|
+
- **target** `string` the target to test.
|
|
296
|
+
|
|
297
|
+
Returns `TestResult`
|
|
298
|
+
|
|
299
|
+
```js
|
|
300
|
+
ig.add({
|
|
301
|
+
pattern: 'foo/*',
|
|
302
|
+
mark: '60'
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
const {
|
|
306
|
+
ignored,
|
|
307
|
+
rule
|
|
308
|
+
} = checkIgnore('foo/')
|
|
309
|
+
|
|
310
|
+
if (ignored) {
|
|
311
|
+
console.log(`.gitignore:${result}:${rule.mark}:${rule.pattern} foo/`)
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// .gitignore:60:foo/* foo/
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Please pay attention that this method does not have a strong built-in cache mechanism.
|
|
318
|
+
|
|
319
|
+
The purpose of introducing this method is to make it possible to implement the `git check-ignore` command in JavaScript based on `node-ignore`.
|
|
320
|
+
|
|
321
|
+
So do not use this method in those situations where performance is extremely important.
|
|
322
|
+
|
|
323
|
+
## static `isPathValid(pathname): boolean` since 5.0.0
|
|
324
|
+
|
|
325
|
+
Check whether the `pathname` is an valid `path.relative()`d path according to the [convention](#1-pathname-should-be-a-pathrelatived-pathname).
|
|
326
|
+
|
|
327
|
+
This method is **NOT** used to check if an ignore pattern is valid.
|
|
328
|
+
|
|
329
|
+
```js
|
|
330
|
+
import {isPathValid} from 'ignore'
|
|
331
|
+
|
|
332
|
+
isPathValid('./foo') // false
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## <strike>.addIgnoreFile(path)</strike>
|
|
336
|
+
|
|
337
|
+
REMOVED in `3.x` for now.
|
|
338
|
+
|
|
339
|
+
To upgrade `ignore@2.x` up to `3.x`, use
|
|
340
|
+
|
|
341
|
+
```js
|
|
342
|
+
import fs from 'fs'
|
|
343
|
+
|
|
344
|
+
if (fs.existsSync(filename)) {
|
|
345
|
+
ignore().add(fs.readFileSync(filename).toString())
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
instead.
|
|
350
|
+
|
|
351
|
+
## ignore(options)
|
|
352
|
+
|
|
353
|
+
### `options.ignorecase` since 4.0.0
|
|
354
|
+
|
|
355
|
+
Similar to the `core.ignorecase` option of [git-config](https://git-scm.com/docs/git-config), `node-ignore` will be case insensitive if `options.ignorecase` is set to `true` (the default value), otherwise case sensitive.
|
|
356
|
+
|
|
357
|
+
```js
|
|
358
|
+
const ig = ignore({
|
|
359
|
+
ignorecase: false
|
|
360
|
+
})
|
|
361
|
+
|
|
362
|
+
ig.add('*.png')
|
|
363
|
+
|
|
364
|
+
ig.ignores('*.PNG') // false
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### `options.ignoreCase?: boolean` since 5.2.0
|
|
368
|
+
|
|
369
|
+
Which is an alternative to `options.ignoreCase`
|
|
370
|
+
|
|
371
|
+
### `options.allowRelativePaths?: boolean` since 5.2.0
|
|
372
|
+
|
|
373
|
+
This option brings backward compatibility with projects which based on `ignore@4.x`. If `options.allowRelativePaths` is `true`, `ignore` will not check whether the given path to be tested is [`path.relative()`d](#pathname-conventions).
|
|
374
|
+
|
|
375
|
+
However, passing a relative path, such as `'./foo'` or `'../foo'`, to test if it is ignored or not is not a good practise, which might lead to unexpected behavior
|
|
376
|
+
|
|
377
|
+
```js
|
|
378
|
+
ignore({
|
|
379
|
+
allowRelativePaths: true
|
|
380
|
+
}).ignores('../foo/bar.js') // And it will not throw
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
****
|
|
384
|
+
|
|
385
|
+
# Upgrade Guide
|
|
386
|
+
|
|
387
|
+
## Upgrade 4.x -> 5.x
|
|
388
|
+
|
|
389
|
+
Since `5.0.0`, if an invalid `Pathname` passed into `ig.ignores()`, an error will be thrown, unless `options.allowRelative = true` is passed to the `Ignore` factory.
|
|
390
|
+
|
|
391
|
+
While `ignore < 5.0.0` did not make sure what the return value was, as well as
|
|
392
|
+
|
|
393
|
+
```ts
|
|
394
|
+
.ignores(pathname: Pathname): boolean
|
|
395
|
+
|
|
396
|
+
.filter(pathnames: Array<Pathname>): Array<Pathname>
|
|
397
|
+
|
|
398
|
+
.createFilter(): (pathname: Pathname) => boolean
|
|
399
|
+
|
|
400
|
+
.test(pathname: Pathname): {ignored: boolean, unignored: boolean}
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
See the convention [here](#1-pathname-should-be-a-pathrelatived-pathname) for details.
|
|
404
|
+
|
|
405
|
+
If there are invalid pathnames, the conversion and filtration should be done by users.
|
|
406
|
+
|
|
407
|
+
```js
|
|
408
|
+
import {isPathValid} from 'ignore' // introduced in 5.0.0
|
|
409
|
+
|
|
410
|
+
const paths = [
|
|
411
|
+
// invalid
|
|
412
|
+
//////////////////
|
|
413
|
+
'',
|
|
414
|
+
false,
|
|
415
|
+
'../foo',
|
|
416
|
+
'.',
|
|
417
|
+
//////////////////
|
|
418
|
+
|
|
419
|
+
// valid
|
|
420
|
+
'foo'
|
|
421
|
+
]
|
|
422
|
+
.filter(isPathValid)
|
|
423
|
+
|
|
424
|
+
ig.filter(paths)
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
## Upgrade 3.x -> 4.x
|
|
428
|
+
|
|
429
|
+
Since `4.0.0`, `ignore` will no longer support node < 6, to use `ignore` in node < 6:
|
|
430
|
+
|
|
431
|
+
```js
|
|
432
|
+
var ignore = require('ignore/legacy')
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
## Upgrade 2.x -> 3.x
|
|
436
|
+
|
|
437
|
+
- All `options` of 2.x are unnecessary and removed, so just remove them.
|
|
438
|
+
- `ignore()` instance is no longer an [`EventEmitter`](nodejs.org/api/events.html), and all events are unnecessary and removed.
|
|
439
|
+
- `.addIgnoreFile()` is removed, see the [.addIgnoreFile](#addignorefilepath) section for details.
|
|
440
|
+
|
|
441
|
+
****
|
|
442
|
+
|
|
443
|
+
# Collaborators
|
|
444
|
+
|
|
445
|
+
- [@whitecolor](https://github.com/whitecolor) *Alex*
|
|
446
|
+
- [@SamyPesse](https://github.com/SamyPesse) *Samy Pessé*
|
|
447
|
+
- [@azproduction](https://github.com/azproduction) *Mikhail Davydov*
|
|
448
|
+
- [@TrySound](https://github.com/TrySound) *Bogdan Chadkin*
|
|
449
|
+
- [@JanMattner](https://github.com/JanMattner) *Jan Mattner*
|
|
450
|
+
- [@ntwb](https://github.com/ntwb) *Stephen Edgar*
|
|
451
|
+
- [@kasperisager](https://github.com/kasperisager) *Kasper Isager*
|
|
452
|
+
- [@sandersn](https://github.com/sandersn) *Nathan Shively-Sanders*
|