Skip to content

Commit

Permalink
fix: add getVueMajor util
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang committed Feb 7, 2022
1 parent 37f16cc commit 2142e1f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/@vue/cli-service/lib/util/getVueMajor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { semver, loadModule } = require('@vue/cli-shared-utils')

/**
* Get the major Vue version that the user project uses
* @param {string} cwd the user project root
* @returns {2|3}
*/
module.exports = function getVueMajor (cwd) {
const vue = loadModule('vue', cwd)
// TODO: make Vue 3 the default version
const vueMajor = vue ? semver.major(vue.version) : 2
return vueMajor
}

0 comments on commit 2142e1f

Please sign in to comment.