mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +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 path from 'path'
|
||||||
import defaultsDeep from 'lodash/defaultsDeep'
|
import defaultsDeep from 'lodash/defaultsDeep'
|
||||||
import { loadNuxtConfig as _loadNuxtConfig, getDefaultNuxtConfig } from '@nuxt/config'
|
import { loadNuxtConfig as _loadNuxtConfig, getDefaultNuxtConfig } from '@nuxt/config'
|
||||||
import { MODES } from '@nuxt/utils'
|
|
||||||
|
|
||||||
export async function loadNuxtConfig (argv, configContext) {
|
export async function loadNuxtConfig (argv, configContext) {
|
||||||
const rootDir = path.resolve(argv._[0] || '.')
|
const rootDir = path.resolve(argv._[0] || '.')
|
||||||
@ -18,9 +17,11 @@ export async function loadNuxtConfig (argv, configContext) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Nuxt Mode
|
if (argv.spa === true) {
|
||||||
options.mode =
|
options.ssr = false
|
||||||
(argv.spa && MODES.spa) || (argv.universal && MODES.universal) || options.mode
|
} else if (argv.universal === true) {
|
||||||
|
options.ssr = true
|
||||||
|
}
|
||||||
|
|
||||||
// Server options
|
// Server options
|
||||||
options.server = defaultsDeep({
|
options.server = defaultsDeep({
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { getDefaultNuxtConfig } from '@nuxt/config'
|
import { getDefaultNuxtConfig } from '@nuxt/config'
|
||||||
import { TARGETS, MODES } from '@nuxt/utils'
|
import { TARGETS } from '@nuxt/utils'
|
||||||
import { consola } from '../utils'
|
import { consola } from '../utils'
|
||||||
import { loadNuxtConfig } from '../../src/utils/config'
|
import { loadNuxtConfig } from '../../src/utils/config'
|
||||||
import * as utils from '../../src/utils'
|
import * as utils from '../../src/utils'
|
||||||
@ -25,7 +25,8 @@ describe('cli/utils', () => {
|
|||||||
|
|
||||||
const options = await loadNuxtConfig(argv)
|
const options = await loadNuxtConfig(argv)
|
||||||
expect(options.rootDir).toBe(process.cwd())
|
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.host).toBe('localhost')
|
||||||
expect(options.server.port).toBe(3000)
|
expect(options.server.port).toBe(3000)
|
||||||
expect(options.server.socket).not.toBeDefined()
|
expect(options.server.socket).not.toBeDefined()
|
||||||
@ -41,7 +42,8 @@ describe('cli/utils', () => {
|
|||||||
const options = await loadNuxtConfig(argv)
|
const options = await loadNuxtConfig(argv)
|
||||||
expect(options.testOption).toBe(true)
|
expect(options.testOption).toBe(true)
|
||||||
expect(options.rootDir).toBe('/some/path')
|
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.host).toBe('nuxt-host')
|
||||||
expect(options.server.port).toBe(3001)
|
expect(options.server.port).toBe(3001)
|
||||||
expect(options.server.socket).toBe('/var/run/nuxt.sock')
|
expect(options.server.socket).toBe('/var/run/nuxt.sock')
|
||||||
|
Loading…
Reference in New Issue
Block a user