.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / node_modules / globby / readme.md
1 # globby [![Build Status](https://travis-ci.org/sindresorhus/globby.svg?branch=master)](https://travis-ci.org/sindresorhus/globby)
2
3 > User-friendly glob matching
4
5 Based on [`glob`](https://github.com/isaacs/node-glob), but adds a bunch of useful features and a nicer API.
6
7
8 ## Features
9
10 - Promise API
11 - Multiple patterns
12 - Negated patterns: `['foo*', '!foobar']`
13 - Expands directories: `dir` → `dir/**/*`
14 - Supports `.gitignore`
15
16
17 ## Install
18
19 ```
20 $ npm install globby
21 ```
22
23
24 ## Usage
25
26 ```
27 ├── unicorn
28 ├── cake
29 └── rainbow
30 ```
31
32 ```js
33 const globby = require('globby');
34
35 (async () => {
36         const paths = await globby(['*', '!cake']);
37
38         console.log(paths);
39         //=> ['unicorn', 'rainbow']
40 })();
41 ```
42
43
44 ## API
45
46 ### globby(patterns, [options])
47
48 Returns a `Promise<Array>` of matching paths.
49
50 #### patterns
51
52 Type: `string` `Array`
53
54 See supported `minimatch` [patterns](https://github.com/isaacs/minimatch#usage).
55
56 #### options
57
58 Type: `Object`
59
60 See the [`node-glob` options](https://github.com/isaacs/node-glob#options) in addition to the ones below.
61
62 One difference is that `nodir` is `true` by default here.
63
64 ##### expandDirectories
65
66 Type: `boolean` `Array` `Object`<br>
67 Default: `true`
68
69 If set to `true`, `globby` will automatically glob directories for you. If you define an `Array` it will only glob files that matches the patterns inside the `Array`. You can also define an `Object` with `files` and `extensions` like below:
70
71 ```js
72 (async () => {
73         const paths = await globby('images', {
74                 expandDirectories: {
75                         files: ['cat', 'unicorn', '*.jpg'],
76                         extensions: ['png']
77                 }
78         });
79
80         console.log(paths);
81         //=> ['cat.png', 'unicorn.png', 'cow.jpg', 'rainbow.jpg']
82 })();
83 ```
84
85 Note that if you set this option to `false`, you won't get back matched directories unless you set `nodir: false`.
86
87 ##### gitignore
88
89 Type: `boolean`<br>
90 Default: `false`
91
92 Respect ignore patterns in `.gitignore` files that apply to the globbed files.
93
94 ### globby.sync(patterns, [options])
95
96 Returns an `Array` of matching paths.
97
98 ### globby.generateGlobTasks(patterns, [options])
99
100 Returns an `Array<Object>` in the format `{pattern: string, opts: Object}`, which can be passed as arguments to [`node-glob`](https://github.com/isaacs/node-glob). This is useful for other globbing-related packages.
101
102 Note that you should avoid running the same tasks multiple times as they contain a file system cache. Instead, run this method each time to ensure file system changes are taken into consideration.
103
104 ### globby.hasMagic(patterns, [options])
105
106 Returns a `boolean` of whether there are any special glob characters in the `patterns`.
107
108 Note that the options affect the results. If `noext: true` is set, then `+(a|b)` will not be considered a magic pattern. If the pattern has a brace expansion, like `a/{b/c,x/y}`, then that is considered magical, unless `nobrace: true` is set.
109
110 ### globby.gitignore([options])
111
112 Returns a `Promise<(path: string) => boolean>` indicating wether a given path is ignored via a `.gitignore` file.
113
114 Takes `cwd?: string` and `ignore?: string[]` as options. `.gitignore` files matched by the ignore config are not
115 used for the resulting filter function.
116
117 ```js
118 const {gitignore} = require('globby');
119
120 (async () => {
121         const isIgnored = await gitignore();
122         console.log(isIgnored('some/file'));
123 })();
124 ```
125
126 ### globby.gitignore.sync([options])
127
128 Returns a `(path: string) => boolean` indicating wether a given path is ignored via a `.gitignore` file.
129
130 Takes the same options as `globby.gitignore`.
131
132
133 ## Globbing patterns
134
135 Just a quick overview.
136
137 - `*` matches any number of characters, but not `/`
138 - `?` matches a single character, but not `/`
139 - `**` matches any number of characters, including `/`, as long as it's the only thing in a path part
140 - `{}` allows for a comma-separated list of "or" expressions
141 - `!` at the beginning of a pattern will negate the match
142
143 [Various patterns and expected matches.](https://github.com/sindresorhus/multimatch/blob/master/test/test.js)
144
145
146 ## Related
147
148 - [multimatch](https://github.com/sindresorhus/multimatch) - Match against a list instead of the filesystem
149 - [matcher](https://github.com/sindresorhus/matcher) - Simple wildcard matching
150 - [del](https://github.com/sindresorhus/del) - Delete files and directories
151 - [make-dir](https://github.com/sindresorhus/make-dir) - Make a directory and its parents if needed
152
153
154 ## License
155
156 MIT © [Sindre Sorhus](https://sindresorhus.com)