Skip to content

Commit

Permalink
fix: nuxt install (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
productdevbook committed Oct 15, 2023
1 parent 8fe9e7a commit 2ae7614
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/primitives-nuxt/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@oku-ui/primitives-nuxt",
"type": "module",
"version": "0.2.0",
"version": "0.2.2",
"description": "Oku Primitives for Nuxt Module",
"license": "MIT",
"funding": "https://github.com/sponsors/productdevbook",
Expand Down
24 changes: 15 additions & 9 deletions packages/primitives-nuxt/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,27 @@ export default defineNuxtModule<ModuleOptions>({
checkbox: true,
},
splash: true,
autoInstall: true,
},
async setup(options, nuxt) {
const resolver = createResolver(import.meta.url)
const rootDir = resolve(nuxt.options.rootDir)

let isInstall = false

const data = await getMainPackageJSON(nuxt)
if (data) {
const { isInstall: install } = await installPackage({
packageJson: data,
rootDir,
installComponents: options.installComponents,
})
isInstall = install
if (options.autoInstall) {
const data = await getMainPackageJSON(nuxt)
if (data) {
const { isInstall: install } = await installPackage({
packageJson: data,
rootDir,
installComponents: options.installComponents,
})
isInstall = install
}
}
else {
isInstall = true
}

if (isInstall) {
Expand All @@ -56,7 +62,7 @@ export default defineNuxtModule<ModuleOptions>({
addComponent({
name: component,
export: component,
filePath: `@oku-ui/${key}`,
filePath: '@oku-ui/primitives',
})
})
})
Expand Down
1 change: 1 addition & 0 deletions packages/primitives-nuxt/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ export interface ModuleOptions {
* @default true
*/
splash?: boolean
autoInstall?: boolean
}

0 comments on commit 2ae7614

Please sign in to comment.