Skip to content

Commit

Permalink
feat(nuxi): add initial support for enabling/disabling devtools (#18864)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
danielroe and antfu committed Feb 8, 2023
1 parent 113ce71 commit c936bc7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/nuxi/src/commands/devtools.ts
Original file line number Diff line number Diff line change
@@ -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 })
}
})
1 change: 1 addition & 0 deletions packages/nuxi/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit c936bc7

Please sign in to comment.