mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(cli): mode deprecation with explicit spa or universal flag (#8134)
This commit is contained in:
parent
34f32113b4
commit
202f35584b
@ -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({
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user