UNPKG

1.36 kBJavaScriptView Raw
1const exec = require('child_process').exec;
2//const util = require('../util');
3
4
5function upgradeCLI (cb) {
6 let cmd = 'npm install wepy-cli -g';
7 util.log('升级中,可能需要几分钟, 请耐心等待...', '信息');
8 util.log('执行命令: ' + cmd, '执行');
9 let fcmd = exec(cmd, () => {
10 util.log('完成安装最新版本wepy-cli', '完成');
11 cb && cb();
12 });
13 fcmd.stdout.on('data', (d) => {
14 console.log(d.substring(d, d.length - 1));
15 });
16}
17
18function upgradeWepy (cb) {
19 let cmd = 'npm install wepy --save';
20 util.log('升级中,可能需要几分钟, 请耐心等待...', '信息');
21 util.log('执行命令: ' + cmd, '执行');
22 let fcmd = exec(cmd, () => {
23 util.log('完成安装最新版本wepy', '完成');
24
25 let cmd = 'wepy build --no-cache';
26 util.log('执行命令: ' + cmd, '执行');
27
28 let fcmd3 = exec(cmd, () => {
29 util.log('完成升级', '完成');
30 cb && cb();
31 });
32 fcmd3.stdout.on('data', (d) => {
33 console.log(d.substring(d, d.length - 1));
34 });
35 });
36 fcmd.stdout.on('data', (d) => {
37 console.log(d.substring(d, d.length - 1));
38 });
39}
40
41exports = module.exports = (program) => {
42 if (program.cli) {
43 upgradeCLI();
44 } else {
45 upgradeWepy();
46 }
47};
\No newline at end of file