UNPKG

530 BJavaScriptView Raw
1// Following is adapted from Vue CLI v2 "init" command
2
3const match = require('minimatch')
4const evaluate = require('./eval')
5
6module.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}