fix(cli): mode deprecation with explicit spa or universal flag (#8134)

This commit is contained in:
Xin Du (Clark) 2020-10-08 15:30:02 +01:00 committed by GitHub
parent 34f32113b4
commit 202f35584b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -1,7 +1,6 @@
import path from 'path'
import defaultsDeep from 'lodash/defaultsDeep'
import { loadNuxtConfig as _loadNuxtConfig, getDefaultNuxtConfig } from '@nuxt/config'
import { MODES } from '@nuxt/utils'
export async function loadNuxtConfig (argv, configContext) {
const rootDir = path.resolve(argv._[0] || '.')
@ -18,9 +17,11 @@ export async function loadNuxtConfig (argv, configContext) {
}
})
// Nuxt Mode
options.mode =
(argv.spa && MODES.spa) || (argv.universal && MODES.universal) || options.mode
if (argv.spa === true) {
options.ssr = false
} else if (argv.universal === true) {
options.ssr = true
}
// Server options
options.server = defaultsDeep({

View File

@ -1,5 +1,5 @@
import { getDefaultNuxtConfig } from '@nuxt/config'
import { TARGETS, MODES } from '@nuxt/utils'
import { TARGETS } from '@nuxt/utils'
import { consola } from '../utils'
import { loadNuxtConfig } from '../../src/utils/config'
import * as utils from '../../src/utils'
@ -25,7 +25,8 @@ describe('cli/utils', () => {
const options = await loadNuxtConfig(argv)
expect(options.rootDir).toBe(process.cwd())
expect(options.mode).toBe(MODES.universal)
expect(options.mode).toBeUndefined()
expect(options.ssr).toBe(true)
expect(options.server.host).toBe('localhost')
expect(options.server.port).toBe(3000)
expect(options.server.socket).not.toBeDefined()
@ -41,7 +42,8 @@ describe('cli/utils', () => {
const options = await loadNuxtConfig(argv)
expect(options.testOption).toBe(true)
expect(options.rootDir).toBe('/some/path')
expect(options.mode).toBe(MODES.spa)
expect(options.mode).toBe('supercharged')
expect(options.ssr).toBe(false)
expect(options.server.host).toBe('nuxt-host')
expect(options.server.port).toBe(3001)
expect(options.server.socket).toBe('/var/run/nuxt.sock')