Skip to content

Commit

Permalink
Update check-version.js (vuejs#264)
Browse files Browse the repository at this point in the history
* Update check-version.js

Simplify node version check

* Update check-version.js

code style
  • Loading branch information
FDiskas authored and yyx990803 committed Dec 20, 2016
1 parent 178f138 commit 55d8222
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions lib/check-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@ var chalk = require('chalk')
var packageConfig = require('../package.json')

module.exports = function (done) {
// Parse version number from strings such as 'v4.2.0' or `>=4.0.0'
function parseVersionNumber (versionString) {
return parseFloat(versionString.replace(/[^\d\.]/g, ''))
}

// Ensure minimum supported node version is used
var minNodeVersion = parseVersionNumber(packageConfig.engines.node)
var currentNodeVersion = parseVersionNumber(process.version)
if (minNodeVersion > currentNodeVersion) {
if (!semver.satisfies(process.version, packageConfig.engines.node)) {
return console.log(chalk.red(
' You must upgrade node to >=' + minNodeVersion + '.x to use vue-cli'
' You must upgrade node to >=' + packageConfig.engines.node + '.x to use vue-cli'
))
}

Expand Down

0 comments on commit 55d8222

Please sign in to comment.