UNPKG

426 BJavaScriptView Raw
1const { readFileSync, existsSync } = require('fs')
2
3function readJSFiles (files) {
4 return Array.from(Array.isArray(files) ? files : [files])
5 .map(path => {
6 path = this.nuxt.resolver.resolvePath(path)
7 if (path && existsSync(path)) {
8 return readFileSync(path, 'utf8')
9 } else {
10 throw new Error('Can not read ' + path)
11 }
12 })
13 .join('\n\n')
14}
15
16module.exports = {
17 readJSFiles
18}