mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 09:02:03 +00:00
feat(nuxi): add initial support for enabling/disabling devtools (#18864)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
This commit is contained in:
parent
113ce71c34
commit
c936bc7187
25
packages/nuxi/src/commands/devtools.ts
Normal file
25
packages/nuxi/src/commands/devtools.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { resolve } from 'pathe'
|
||||
import { execa } from 'execa'
|
||||
import { showHelp } from '../utils/help'
|
||||
import { defineNuxtCommand } from './index'
|
||||
|
||||
export default defineNuxtCommand({
|
||||
meta: {
|
||||
name: 'enable',
|
||||
usage: 'npx nuxi devtools enable|disable [rootDir]',
|
||||
description: 'Enable or disable features in a Nuxt project'
|
||||
},
|
||||
async invoke (args) {
|
||||
const [command, _rootDir = '.'] = args._
|
||||
const rootDir = resolve(_rootDir)
|
||||
|
||||
if (!['enable', 'disable'].includes(command)) {
|
||||
console.error(`Unknown command \`${command}\`.`)
|
||||
showHelp(this.meta)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Defer to feature setup
|
||||
await execa('npx', ['@nuxt/devtools@latest', command, rootDir], { stdio: 'inherit', cwd: rootDir })
|
||||
}
|
||||
})
|
@ -18,6 +18,7 @@ export const commands = {
|
||||
info: () => import('./info').then(_rDefault),
|
||||
init: () => import('./init').then(_rDefault),
|
||||
create: () => import('./init').then(_rDefault),
|
||||
devtools: () => import('./devtools').then(_rDefault),
|
||||
upgrade: () => import('./upgrade').then(_rDefault),
|
||||
test: () => import('./test').then(_rDefault),
|
||||
add: () => import('./add').then(_rDefault),
|
||||
|
Loading…
Reference in New Issue
Block a user