mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
Merge pull request #392 from PierreRambaud/feature-391
Add config file option
This commit is contained in:
commit
d782b1c516
@ -15,13 +15,32 @@ if (process.argv.indexOf('--analyze') !== -1 || process.argv.indexOf('-a') !== -
|
|||||||
process.argv = without(process.argv, '--analyze', '-a')
|
process.argv = without(process.argv, '--analyze', '-a')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Root directory parameter
|
||||||
var rootDir = resolve(process.argv.slice(2)[0] || '.')
|
var rootDir = resolve(process.argv.slice(2)[0] || '.')
|
||||||
var nuxtConfigFile = resolve(rootDir, 'nuxt.config.js')
|
var nuxtConfigFilePath = resolve(rootDir, nuxtConfigFileName)
|
||||||
|
|
||||||
var options = {}
|
var options = {}
|
||||||
if (fs.existsSync(nuxtConfigFile)) {
|
if (fs.existsSync(nuxtConfigFilePath)) {
|
||||||
options = require(nuxtConfigFile)
|
options = require(nuxtConfigFilePath)
|
||||||
|
} else {
|
||||||
|
console.log(`Could not locate ${nuxtConfigFilePath}`) // eslint-disable-line no-console
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof options.rootDir !== 'string') {
|
if (typeof options.rootDir !== 'string') {
|
||||||
options.rootDir = rootDir
|
options.rootDir = rootDir
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user