fixed modulesDir is not initialized with correct default value (#2258)

This commit is contained in:
Ralph Huwiler 2017-11-27 18:00:23 +01:00 committed by Pooya Parsa
parent 5bacd36590
commit b31b0f250c
2 changed files with 13 additions and 4 deletions

View File

@ -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

View 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))
})