UNPKG

658 BJavaScriptView Raw
1const fs = require('fs')
2const bytes = require('bytes')
3const glob = require('glob')
4const gzip = require('gzip-size')
5const { error } = require('prettycli')
6const config = require('./config')
7const debug = require('./debug')
8
9const files = []
10
11config.map(file => {
12 const paths = glob.sync(file.path)
13 if (!paths.length) {
14 error('There is no matching file for ' + file.path, { silent: true })
15 } else {
16 paths.map(path => {
17 const size = gzip.sync(fs.readFileSync(path, 'utf8'))
18 const maxSize = bytes(file.threshold || file.maxSize)
19 files.push({ maxSize, path, size })
20 })
21 }
22})
23
24debug('files', files)
25
26module.exports = files