mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
fix(cli): prevent both nuxt
& nuxt-edge
being installed (#6020)
This commit is contained in:
parent
ac723e6ca6
commit
e6acdbc9bf
@ -1,10 +1,21 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import execa from 'execa'
|
||||
import { name as pkgName } from '../package.json'
|
||||
import NuxtCommand from './command'
|
||||
import setup from './setup'
|
||||
import getCommand from './commands'
|
||||
|
||||
function checkDuplicateNuxt() {
|
||||
const dupPkg = pkgName === '@nuxt/cli' ? 'cli-edge' : 'cli'
|
||||
if (fs.existsSync(path.resolve(__dirname, '..', '..', dupPkg))) {
|
||||
throw new Error('Both `nuxt` and `nuxt-edge` are installed! This is unsupported, please choose one and remove the other one from dependencies.')
|
||||
}
|
||||
}
|
||||
|
||||
export default async function run(_argv) {
|
||||
checkDuplicateNuxt()
|
||||
|
||||
// Read from process.argv
|
||||
const argv = _argv ? Array.from(_argv) : process.argv.slice(2)
|
||||
|
||||
|
12
packages/cli/test/unit/run-edge.test.js
Normal file
12
packages/cli/test/unit/run-edge.test.js
Normal file
@ -0,0 +1,12 @@
|
||||
import run from '../../src/run'
|
||||
|
||||
jest.mock('../../package.json', () => ({
|
||||
name: 'cli-edge'
|
||||
}))
|
||||
|
||||
describe('run in edge', () => {
|
||||
test('throws error if nuxt and nuxt-edge are installed', async () => {
|
||||
await expect(run())
|
||||
.rejects.toThrow('Both `nuxt` and `nuxt-edge` are installed! This is unsupported, please choose one and remove the other one from dependencies.')
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user