generator-mico-cli 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/mico.js +9 -5
- package/package.json +1 -1
package/bin/mico.js
CHANGED
|
@@ -98,9 +98,10 @@ function askForUpdate(current, latest) {
|
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* 执行更新
|
|
101
|
+
* @param {string} latestVersion - 要更新到的版本号
|
|
101
102
|
* @returns {boolean} 是否更新成功
|
|
102
103
|
*/
|
|
103
|
-
function performUpdate() {
|
|
104
|
+
function performUpdate(latestVersion) {
|
|
104
105
|
console.log('');
|
|
105
106
|
console.log(' ⏳ Updating mico-cli...');
|
|
106
107
|
|
|
@@ -113,12 +114,15 @@ function performUpdate() {
|
|
|
113
114
|
pm = 'yarn';
|
|
114
115
|
}
|
|
115
116
|
|
|
117
|
+
// 指定具体版本号,避免 npm 缓存问题
|
|
118
|
+
const packageSpec = latestVersion ? `${pkg.name}@${latestVersion}` : `${pkg.name}@latest`;
|
|
119
|
+
|
|
116
120
|
// 执行全局安装
|
|
117
121
|
const installCmd = pm === 'yarn' ? 'yarn' : pm;
|
|
118
122
|
const installArgs =
|
|
119
123
|
pm === 'yarn'
|
|
120
|
-
? ['global', 'add',
|
|
121
|
-
: ['install', '-g',
|
|
124
|
+
? ['global', 'add', packageSpec]
|
|
125
|
+
: ['install', '-g', packageSpec];
|
|
122
126
|
|
|
123
127
|
const result = spawnSync(installCmd, installArgs, {
|
|
124
128
|
stdio: 'inherit',
|
|
@@ -224,7 +228,7 @@ async function main() {
|
|
|
224
228
|
if (command === 'update') {
|
|
225
229
|
const updateInfo = await checkForUpdate();
|
|
226
230
|
if (updateInfo && updateInfo.hasUpdate) {
|
|
227
|
-
performUpdate();
|
|
231
|
+
performUpdate(updateInfo.latest);
|
|
228
232
|
} else if (updateInfo) {
|
|
229
233
|
console.log(` ✅ You are using the latest version (v${updateInfo.current})`);
|
|
230
234
|
} else {
|
|
@@ -250,7 +254,7 @@ async function main() {
|
|
|
250
254
|
updateInfo.latest
|
|
251
255
|
);
|
|
252
256
|
if (shouldUpdate) {
|
|
253
|
-
const success = performUpdate();
|
|
257
|
+
const success = performUpdate(updateInfo.latest);
|
|
254
258
|
if (success) {
|
|
255
259
|
process.exit(0);
|
|
256
260
|
}
|