Skip to content

Commit

Permalink
chore: make anu install options optional with defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-solanki committed Dec 26, 2022
1 parent 3a664f8 commit 27ec07b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/anu-vue/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { defu } from 'defu'
import type { App } from 'vue'
import * as components from './components'
import { provideAppSpacing } from '@/composables/useSpacing'
Expand All @@ -7,12 +8,17 @@ export interface PluginOptions {
registerComponents: boolean
}

const optionsDefaults: Partial<PluginOptions> = {
registerComponents: true,
}

const plugin = {
install(app: App, options?: PluginOptions) {
install(app: App, options: Partial<PluginOptions> = {}) {
provideAppSpacing(app)

// console.log('components :>> ', components);
if (options && options.registerComponents) {
const _options = defu(options, optionsDefaults)

if (_options.registerComponents) {
for (const prop in components) {
// @ts-expect-error: I want to index import using string
const component = components[prop]
Expand Down

0 comments on commit 27ec07b

Please sign in to comment.