refactor: centralize daemon path resolution

This commit is contained in:
Peter Steinberger
2026-01-15 23:09:08 +00:00
parent 4a99b9b651
commit db9be87d94
9 changed files with 130 additions and 56 deletions

View File

@@ -10,6 +10,7 @@ import {
} from "./constants.js";
import { parseKeyValueOutput } from "./runtime-parse.js";
import type { GatewayServiceRuntime } from "./service-runtime.js";
import { resolveHomeDir } from "./paths.js";
import {
enableSystemdUserLinger,
readSystemdUserLingerStatus,
@@ -28,12 +29,6 @@ const formatLine = (label: string, value: string) => {
return `${colorize(rich, theme.muted, `${label}:`)} ${colorize(rich, theme.command, value)}`;
};
function resolveHomeDir(env: Record<string, string | undefined>): string {
const home = env.HOME?.trim() || env.USERPROFILE?.trim();
if (!home) throw new Error("Missing HOME");
return home;
}
function resolveSystemdUnitPathForName(
env: Record<string, string | undefined>,
name: string,