1 | // Following is adapted from Vue CLI v2 "init" command
|
2 |
|
3 | const match = require('minimatch')
|
4 | const evaluate = require('./eval')
|
5 |
|
6 | module.exports = (files, filters, data, done) => {
|
7 | if (!filters) {
|
8 | return done()
|
9 | }
|
10 |
|
11 | const fileNames = Object.keys(files)
|
12 | Object.keys(filters).forEach(glob => {
|
13 | fileNames.forEach(file => {
|
14 | if (match(file, glob, { dot: true })) {
|
15 | const condition = filters[glob]
|
16 | if (!evaluate(condition, data)) {
|
17 | delete files[file]
|
18 | }
|
19 | }
|
20 | })
|
21 | })
|
22 |
|
23 | done()
|
24 | }
|