Skip to content

Commit

Permalink
fix: catch error if vue is not found
Browse files Browse the repository at this point in the history
closes #1295
  • Loading branch information
elevatebart committed Mar 18, 2022
1 parent b6605d9 commit b2f9a5c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/vue-inbrowser-compiler-demi/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
const pkg = require('vue/package.json')
const path = require('path')
const fs = require('fs')

function getVuePackageVersion() {
try {
const pkg = require('vue/package.json')
return pkg.version
} catch {
return 'unknown'
}
}

function updateIndexForVue3() {
// commonjs
const indexPath = path.join(__dirname, './index.cjs.js')
Expand Down Expand Up @@ -31,6 +39,8 @@ function updateIndexForVue3() {
})
}

const pkg = getVuePackageVersion()

if (pkg.version.startsWith('3.')) {
updateIndexForVue3()
}

0 comments on commit b2f9a5c

Please sign in to comment.