chore(config): warn on unknown mode (#4303)

This commit is contained in:
Alexander Lichter 2018-11-11 11:21:53 +00:00 committed by Pooya Parsa
parent f9b199873f
commit d280bd8d5b
3 changed files with 10 additions and 2 deletions

View File

@ -237,7 +237,11 @@ export function getNuxtConfig(_options) {
// Apply mode preset // Apply mode preset
const modePreset = options.modes[options.mode || 'universal'] const modePreset = options.modes[options.mode || 'universal']
defaultsDeep(options, modePreset)
if (!modePreset) {
consola.warn(`Unknown mode: ${options.mode}. Falling back to universal`)
}
defaultsDeep(options, modePreset || options.modes.universal)
if (options.modern === true) { if (options.modern === true) {
options.modern = 'server' options.modern = 'server'

View File

@ -2,6 +2,7 @@ import path from 'path'
import compression from 'compression' import compression from 'compression'
export default { export default {
mode: 'unknown',
srcDir: __dirname, srcDir: __dirname,
server: { server: {
port: 8000, port: 8000,

View File

@ -14,9 +14,12 @@ const hooks = [
describe('with-config', () => { describe('with-config', () => {
buildFixture('with-config', () => { buildFixture('with-config', () => {
expect(consola.warn).toHaveBeenCalledTimes(3) expect(consola.warn).toHaveBeenCalledTimes(4)
expect(consola.fatal).toHaveBeenCalledTimes(0) expect(consola.fatal).toHaveBeenCalledTimes(0)
expect(consola.warn.mock.calls).toMatchObject([ expect(consola.warn.mock.calls).toMatchObject([
[
'Unknown mode: unknown. Falling back to universal'
],
[{ [{
message: 'Found 2 plugins that match the configuration, suggest to specify extension:', message: 'Found 2 plugins that match the configuration, suggest to specify extension:',
additional: expect.stringContaining('plugins/test.json') additional: expect.stringContaining('plugins/test.json')