refactor: dedupe config cli command trimmed readers

This commit is contained in:
Peter Steinberger
2026-04-08 00:47:02 +01:00
parent 3ff56020b1
commit 63e00b811e
43 changed files with 216 additions and 151 deletions

View File

@@ -4,7 +4,10 @@ import path from "node:path";
import { Command, Option } from "commander";
import { resolveStateDir } from "../config/paths.js";
import { routeLogsToStderr } from "../logging/console.js";
import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
import {
normalizeLowercaseStringOrEmpty,
normalizeOptionalString,
} from "../shared/string-coerce.js";
import { formatDocsLink } from "../terminal/links.js";
import { theme } from "../terminal/theme.js";
import { pathExists } from "../utils.js";
@@ -24,7 +27,7 @@ function isCompletionShell(value: string): value is CompletionShell {
}
export function resolveShellFromEnv(env: NodeJS.ProcessEnv = process.env): CompletionShell {
const shellPath = env.SHELL?.trim() ?? "";
const shellPath = normalizeOptionalString(env.SHELL) ?? "";
const shellName = shellPath ? normalizeLowercaseStringOrEmpty(path.basename(shellPath)) : "";
if (shellName === "zsh") {
return "zsh";