forked from vuejs/vue-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check version when installing remote template
Showing
3 changed files
with
38 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
var request = require('request') | ||
var semver = require('semver') | ||
var chalk = require('chalk') | ||
|
||
module.exports = function (done) { | ||
request({ | ||
url: 'http://registry.npmjs.org/vue-cli', | ||
timeout: 1000 | ||
}, function (err, res, body) { | ||
if (!err && res.statusCode == 200) { | ||
var latestVersion = JSON.parse(body)['dist-tags'].latest | ||
var localVersion = require('../package.json').version | ||
if (semver.lt(localVersion, latestVersion)) { | ||
console.log(chalk.yellow(' A newer version of vue-cli is available.')) | ||
console.log() | ||
console.log(' latest: ' + chalk.green(latestVersion)) | ||
console.log(' installed: ' + chalk.red(localVersion)) | ||
console.log() | ||
} | ||
} | ||
done() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters