Skip to content

Commit fa653d5

Browse files
committed
fix(prompts): 优化版本检查逻辑和提示信息
- 增加对远程版本为空的判断,避免在 package 尚未发布时显示错误信息 - 修改版本不匹配时的提示信息,使其更加友好和简洁 - 保持最新的版本提示信息不变
1 parent b1b458b commit fa653d5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/prompts.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,11 @@ export async function checkUpdate(options: PkgMeta & { version: string; projectP
139139
throw new ExitError(`Failed to check for updates: ${err.message}`, 1);
140140
}
141141

142-
if (localVersion !== remoteVersion) {
142+
// 如果当前 package 还没有发布,则远程版本为空
143+
if (remoteVersion && localVersion !== remoteVersion) {
144+
spinner.stop(`New version ${remoteVersion} is available`, 1);
143145
const command = ['npm', 'create', `${name}@${distTag}`, projectPath].filter(Boolean).join(' ');
144-
throw new ExitError(`New version ${remoteVersion} is available, please use \`${command}\` command instead.`, 1);
146+
throw new ExitError(`Please use \`${command}\` command instead.`, 1);
145147
}
146148

147149
spinner.stop('Currently using the latest version', 0);

0 commit comments

Comments
 (0)