1 | const { readFileSync, existsSync } = require('fs')
|
2 |
|
3 | function 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 |
|
16 | module.exports = {
|
17 | readJSFiles
|
18 | }
|