Skip to content

Commit

Permalink
fix: allow module to be disabled with enabled: false
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Oct 31, 2024
1 parent 75ff60f commit d11f193
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/module/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export interface ModuleOptions extends SiteConfigInput {
global?: boolean
prefix?: string
}
/**
* Enable the module.
*
* @default true
*/
enabled?: boolean
/**
* Enable debug mode.
*
Expand Down Expand Up @@ -50,15 +56,19 @@ export default defineNuxtModule<ModuleOptions>({
},
defaults(nuxt) {
return {
enabled: true,
debug: nuxt.options.debug || false,
}
},
async setup(config, nuxt) {
const { resolve } = createResolver(import.meta.url)
const { name, version } = await readPackageJSON(resolve('../package.json'))

const logger = useLogger(name)
logger.level = config.debug ? 4 : 3
if (config.enabled === false) {
logger.debug('The module is disabled, skipping setup.')
return
}

await initSiteConfig()
// the module config should have the highest priority
Expand Down

0 comments on commit d11f193

Please sign in to comment.