Skip to content

Commit

Permalink
fix(wizard): use object options instead, close #206
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Apr 29, 2023
1 parent 73ef44c commit d63cf58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 2 additions & 3 deletions packages/devtools-wizard/src/builtin.ts
Expand Up @@ -42,9 +42,8 @@ async function toggleConfig(cwd: string, value?: boolean) {
? mod.exports.default.$args[0]
: mod.exports.default

if (config.devtools == null || typeof config.devtools === 'boolean')
config.devtools = true
else if (typeof config.devtools === 'object')
config.devtools ||= {}
if (typeof config.devtools === 'object')
config.devtools.enabled = true

const generated = mod.generate().code
Expand Down
5 changes: 4 additions & 1 deletion packages/devtools/src/module.ts
Expand Up @@ -12,6 +12,9 @@ export default defineNuxtModule<ModuleOptions>({
},
defaults: defaultOptions,
setup(options, nuxt) {
if (typeof options === 'boolean')
options = { enabled: options }

// Explicitly disabled
if (options.enabled === false)
return
Expand All @@ -30,6 +33,6 @@ export default defineNuxtModule<ModuleOptions>({
* - Installed locally
* - Installed globally, and enabled via `nuxi enable devtools`, or `enabled` is explicitly set to true
*/
return import('./module-main').then(({ enableModule }) => enableModule(options, nuxt))
return import('./module-main').then(({ enableModule }) => enableModule(options as ModuleOptions, nuxt))
},
})

0 comments on commit d63cf58

Please sign in to comment.