Skip to content

Commit

Permalink
fix:add auth fail message
Browse files Browse the repository at this point in the history
  • Loading branch information
szmxx committed Nov 16, 2023
1 parent 9ae2d9d commit 5b0fd9c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/utils/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@ export async function initREPO(pkg: Record<string, unknown>) {
auth?.stdout?.toString?.()
);
const result = await res?.json();
const { ssh_url, html_url } = result;
const { ssh_url, html_url, message } = result;
pkg.homepage = `${html_url}#readme`;
if (pkg?.repository?.url) pkg.repository.url = html_url;
if (pkg?.bugs?.url) pkg.bugs.url = `${html_url}/issues`;
if (ssh_url) {
spinner.succeed(chalk.green("创建远程仓库成功"));
return ssh_url;
} else {
if (message === "Bad credentials") {
spinner.fail(chalk.red("授权失败"));
throw new Error("授权失败,请检查权限");
}
spinner.fail(chalk.red("远程仓库或已存在"));
throw new Error("创建远程仓库失败,仓库或已存在");
}
Expand Down

0 comments on commit 5b0fd9c

Please sign in to comment.