shouldLaunchBrowser function
Whether an OAuth/SSO flow may auto-launch the system browser (gh-1450).
Precedence: an explicit noBrowserFlag (--no-browser) beats the
truthy FA_NO_BROWSER env var, which beats the headless/remote
auto-detect (isHeadlessOrRemoteSession). false means the flow skips
the launch (openBrowserFn is never called) and prints the
authorization URL prominently instead — the URL is never suppressed.
Implementation
bool shouldLaunchBrowser({
bool noBrowserFlag = false,
Map<String, String>? environment,
bool? stdoutHasTerminal,
bool? isLinux,
}) {
if (noBrowserFlag) return false;
if (isTruthyEnvValue(
(environment ?? Platform.environment)[noBrowserEnvVar],
)) {
return false;
}
return !isHeadlessOrRemoteSession(
environment: environment,
stdoutHasTerminal: stdoutHasTerminal,
isLinux: isLinux,
);
}