UNPKG

629 BJavaScriptView Raw
1let fetch = require('node-fetch')
2let utils = require('../utils/utils')
3let localV = utils.getVer()
4let log = utils.log
5let child_process = require('child_process');
6
7(async function () {
8 // search on npm
9 let res = await fetch('https://registry.npmjs.com/@linhun%2Fjane-cli').then(res => res.json())
10 let onlineV = res['dist-tags'].latest
11 // diff
12 if (localV < onlineV) {
13 log.info(`线上最新为${onlineV},升级中...`)
14 log.info(`请输入密码,赋予读写权限`)
15 child_process.execSync("sudo npm install @linhun/jane-cli -g", {stdio: [0, 1, 2]})
16 }
17 else {
18 log.info('已是最新版')
19 }
20})()