mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-06 21:10:38 +00:00
fixed modulesDir is not initialized with correct default value (#2258)
This commit is contained in:
parent
5bacd36590
commit
b31b0f250c
@ -43,13 +43,13 @@ Options.from = function (_options) {
|
||||
options.cacheDir = resolve(options.rootDir, options.cacheDir)
|
||||
|
||||
// Normalize modulesDir
|
||||
/* istanbul ignore if */
|
||||
if (!options.modulesDir) {
|
||||
options.modulesDir = ['node_modules']
|
||||
}
|
||||
if (!Array.isArray(options.modulesDir)) {
|
||||
options.modulesDir = [options.modulesDir]
|
||||
}
|
||||
/* istanbul ignore if */
|
||||
if (!options.modulesDir.length) {
|
||||
options.modulesDir = ['node_modules']
|
||||
}
|
||||
options.modulesDir = options.modulesDir.filter(dir => hasValue(dir)).map(dir => resolve(options.rootDir, dir))
|
||||
|
||||
// If app.html is defined, set the template path to the user template
|
||||
|
9
test/basic.config.defaults.test.js
Normal file
9
test/basic.config.defaults.test.js
Normal file
@ -0,0 +1,9 @@
|
||||
import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
import { Options } from '../index'
|
||||
|
||||
test('modulesDir uses /node_modules as default if not set', async t => {
|
||||
const options = Options.from({})
|
||||
const currentNodeModulesDir = resolve(__dirname, '..', 'node_modules')
|
||||
t.true(options.modulesDir.includes(currentNodeModulesDir))
|
||||
})
|
Loading…
Reference in New Issue
Block a user