From c5194e4aa98559c9786e5982d3ca81a47ad6ed32 Mon Sep 17 00:00:00 2001 From: mlnchk Date: Tue, 18 Aug 2026 17:59:43 +0500 Subject: [PATCH] fix: only open browser in interactive (TTY) sessions auth login and asa connect called open() unconditionally, launching a browser during tests and piped/non-interactive runs. Guard both on process.stdin.isTTY; the verification URL is still printed. --- src/commands/asa/connect.ts | 2 +- src/commands/auth/login.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/commands/asa/connect.ts b/src/commands/asa/connect.ts index 7206e39..4a693e1 100644 --- a/src/commands/asa/connect.ts +++ b/src/commands/asa/connect.ts @@ -25,7 +25,7 @@ export default class AsaConnect extends Command { this.log('The link is valid for one hour. Sign in to the Adapty dashboard in that browser first — the last') this.log('step is authorized by the dashboard session, not by this CLI.') - await open(authUrl).catch(() => false) + if (process.stdin.isTTY === true) await open(authUrl).catch(() => false) if (!flags.wait) return {auth_url: authUrl} diff --git a/src/commands/auth/login.ts b/src/commands/auth/login.ts index 6d37f8b..297ee3a 100644 --- a/src/commands/auth/login.ts +++ b/src/commands/auth/login.ts @@ -56,10 +56,12 @@ static examples = ['<%= config.bin %> auth login'] this.log(`\nYour code: ${device.user_code}\n`) this.log(`If browser doesn't open, visit: ${device.verification_uri_complete}\n`) - try { - await open(device.verification_uri_complete) - } catch { - // browser open failed silently — URL already printed + if (process.stdin.isTTY === true) { + try { + await open(device.verification_uri_complete) + } catch { + // browser open failed silently — URL already printed + } } this.log('Waiting for authorization...')