-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
37 lines (30 loc) · 953 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env node
// Show logs
process.env.DEBUG = 'nuxt:*'
var fs = require('fs')
var Nuxt = require('nuxt')
var resolve = require('path').resolve
var rootDir = resolve('.')
var nuxtConfigFilePath = resolve('.', 'nuxt.config.js')
var options = {}
if (fs.existsSync(nuxtConfigFilePath)) {
options = require(nuxtConfigFilePath)
} else {
console.log(`Could not locate ${nuxtConfigFilePath}`) // eslint-disable-line no-console
}
if (typeof options.rootDir !== 'string') {
options.rootDir = rootDir
}
options.dev = false // Create production build when calling `nuxt build`
options.build = options.build || {}
console.log('[nuxt] Generating...') // eslint-disable-line no-console
var nuxt = new Nuxt(options)
nuxt.generate()
.then(() => {
console.log('[nuxt] Generate done') // eslint-disable-line no-console
process.exit(0)
})
.catch((err) => {
console.error(err) // eslint-disable-line no-console
process.exit(1)
})