mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-21 00:02:23 +00:00
fix(cli): avoid looping infinitely and avoid prompt if interactive
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user