Skip to content

Commit a07faea

Browse files
author
huzijie.sea
committed
fix(release): 更新发布脚本错误处理
1 parent 9fbd18e commit a07faea

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

scripts/release.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -420,14 +420,8 @@ function publishToNpm() {
420420
console.log(chalk.yellow('📦 发布到 npm...'));
421421

422422
try {
423-
// 检查是否已登录 npm
424-
exec('npm whoami', { allowInDryRun: true });
425-
426423
// 构建发布命令
427-
let publishCmd = 'npm publish';
428-
if (config.publish?.npmConfig?.access) {
429-
publishCmd += ` --access ${config.publish.npmConfig.access}`;
430-
}
424+
let publishCmd = 'npm publish --access public';
431425
if (config.publish?.npmConfig?.registry) {
432426
publishCmd += ` --registry ${config.publish.npmConfig.registry}`;
433427
}
@@ -438,7 +432,12 @@ function publishToNpm() {
438432
console.log(chalk.green('✅ 已发布到 npm'));
439433
} catch (error) {
440434
console.log(chalk.red('❌ 发布失败'));
441-
throw error;
435+
// 如果发布失败,提示用户手动登录后重试
436+
console.log(chalk.yellow('💡 请手动登录 npm 后重试:'));
437+
console.log(chalk.yellow(' npm login --registry https://registry.npmjs.org/'));
438+
console.log(chalk.yellow(' npm publish --access public --registry https://registry.npmjs.org/'));
439+
440+
// 不抛出错误,让后续的git推送仍能执行
442441
}
443442
}
444443

0 commit comments

Comments
 (0)