fix(cli): avoid looping infinitely and avoid prompt if interactive

This commit is contained in:
Ruben Fiszel
2023-05-24 17:38:38 +02:00
parent 42af2854b2
commit 97b4403b7a
2 changed files with 8 additions and 0 deletions
+4
View File
@@ -3,6 +3,10 @@ import { colors, getAvailablePort, log, open, Secret, Select } from "./deps.ts";
export async function loginInteractive(remote: string) {
let token: string | undefined;
if (!Deno.isatty(Deno.stdin.rid)) {
log.info("Not a TTY, can't login interactively.");
return undefined;
}
if (
(await Select.prompt({
message: "How do you want to login",
+4
View File
@@ -208,6 +208,10 @@ export async function add(
remote = new URL(remote).toString(); // add trailing slash in all cases!
let token = await tryGetLoginInfo(opts);
if (!token && !Deno.isatty(Deno.stdin.rid)) {
log.info("Not a TTY, can't login interactively. Pass the token in --token");
return;
}
while (!token) {
token = await loginInteractive(remote);
}