quick-create-app-cli
Version:
前端基础建设模版脚手架,快速搭建PC、HybridApp、微信小程序、微前端等项目
26 lines (23 loc) • 777 B
JavaScript
const { chalk, updateNotifier } = require('./utils/dependencies')
const pkg = require('../package.json')
const notifier = updateNotifier({
// 从 package.json 获取 name 和 version 进行查询
pkg,
// 设定检查更新周期,默认为 1000 * 60 * 60 * 24(1 天)
// 这里设定为 1000 毫秒(1秒)
updateCheckInterval: 1000
})
// 当检测到版本时,notifier.update 会返回 Object
// 此时可以用 notifier.update.latest 获取最新版本号
module.exports = function () {
if (notifier.update) {
console.log(
`New version available: ${chalk.cyan(
notifier.update.latest
)}, it's recommended that you update before using.`
)
notifier.notify()
} else {
console.log('No new version is available.')
}
}