Add support to --config-file to nuxt-dev

This commit is contained in:
Alex M 2017-04-19 17:01:26 -03:00 committed by GitHub
parent 0bea10b857
commit c177354633

View File

@ -10,9 +10,25 @@ var fs = require('fs')
var Nuxt = require('../')
var chokidar = require('chokidar')
var resolve = require('path').resolve
var without = require('lodash').without
var nuxtConfigFileName = 'nuxt.config.js'
// --config-file option
var indexOfConfig = false
if (process.argv.indexOf('--config-file') !== -1) {
indexOfConfig = process.argv.indexOf('--config-file')
} else if (process.argv.indexOf('-c') !== -1) {
indexOfConfig = process.argv.indexOf('-c')
}
if (indexOfConfig !== false) {
nuxtConfigFileName = process.argv.slice(indexOfConfig)[1]
process.argv = without(process.argv, '--config-file', '-c', nuxtConfigFileName)
}
var rootDir = resolve(process.argv.slice(2)[0] || '.')
var nuxtConfigFile = resolve(rootDir, 'nuxt.config.js')
var nuxtConfigFile = resolve(rootDir, nuxtConfigFileName)
var options = {}
if (fs.existsSync(nuxtConfigFile)) {
@ -62,7 +78,7 @@ function listenOnConfigChanges (nuxt, server) {
process.exit(1)
})
}, 200)
var nuxtConfigFile = resolve(rootDir, 'nuxt.config.js')
var nuxtConfigFile = resolve(rootDir, nuxtConfigFileName)
chokidar.watch(nuxtConfigFile, Object.assign({}, nuxt.options.watchers.chokidar, { ignoreInitial: true }))
.on('all', build)
}