1 | # dir-glob [![Build Status](https://travis-ci.org/kevva/dir-glob.svg?branch=master)](https://travis-ci.org/kevva/dir-glob)
|
---|
2 |
|
---|
3 | > Convert directories to glob compatible strings
|
---|
4 |
|
---|
5 |
|
---|
6 | ## Install
|
---|
7 |
|
---|
8 | ```
|
---|
9 | $ npm install dir-glob
|
---|
10 | ```
|
---|
11 |
|
---|
12 |
|
---|
13 | ## Usage
|
---|
14 |
|
---|
15 | ```js
|
---|
16 | const dirGlob = require('dir-glob');
|
---|
17 |
|
---|
18 | (async () => {
|
---|
19 | console.log(await dirGlob(['index.js', 'test.js', 'fixtures']));
|
---|
20 | //=> ['index.js', 'test.js', 'fixtures/**']
|
---|
21 |
|
---|
22 | console.log(await dirGlob(['index.js', 'inner_folder'], {cwd: 'fixtures'}));
|
---|
23 | //=> ['index.js', 'inner_folder/**']
|
---|
24 |
|
---|
25 | console.log(await dirGlob(['lib/**', 'fixtures'], {
|
---|
26 | files: ['test', 'unicorn']
|
---|
27 | extensions: ['js']
|
---|
28 | }));
|
---|
29 | //=> ['lib/**', 'fixtures/**/test.js', 'fixtures/**/unicorn.js']
|
---|
30 |
|
---|
31 | console.log(await dirGlob(['lib/**', 'fixtures'], {
|
---|
32 | files: ['test', 'unicorn', '*.jsx'],
|
---|
33 | extensions: ['js', 'png']
|
---|
34 | }));
|
---|
35 | //=> ['lib/**', 'fixtures/**/test.{js,png}', 'fixtures/**/unicorn.{js,png}', 'fixtures/**/*.jsx']
|
---|
36 | })();
|
---|
37 | ```
|
---|
38 |
|
---|
39 |
|
---|
40 | ## API
|
---|
41 |
|
---|
42 | ### dirGlob(input, options?)
|
---|
43 |
|
---|
44 | Returns a `Promise<string[]>` with globs.
|
---|
45 |
|
---|
46 | ### dirGlob.sync(input, options?)
|
---|
47 |
|
---|
48 | Returns a `string[]` with globs.
|
---|
49 |
|
---|
50 | #### input
|
---|
51 |
|
---|
52 | Type: `string | string[]`
|
---|
53 |
|
---|
54 | Paths.
|
---|
55 |
|
---|
56 | #### options
|
---|
57 |
|
---|
58 | Type: `object`
|
---|
59 |
|
---|
60 | ##### extensions
|
---|
61 |
|
---|
62 | Type: `string[]`
|
---|
63 |
|
---|
64 | Append extensions to the end of your globs.
|
---|
65 |
|
---|
66 | ##### files
|
---|
67 |
|
---|
68 | Type: `string[]`
|
---|
69 |
|
---|
70 | Only glob for certain files.
|
---|
71 |
|
---|
72 | ##### cwd
|
---|
73 |
|
---|
74 | Type: `string[]`
|
---|
75 |
|
---|
76 | Test in specific directory.
|
---|