import { homedir } from "node:os"; import { join } from "node:path"; export function cacheHome(): string { const xdgCache = process.env.XDG_CACHE_HOME?.trim(); if (xdgCache) { return xdgCache; } return join(requireHome(), ".cache"); } export function configHome(): string { const xdgConfig = process.env.XDG_CONFIG_HOME?.trim(); if (xdgConfig) { return xdgConfig; } return join(requireHome(), ".config"); } function requireHome(): string { const value = process.env.HOME?.trim() || homedir().trim(); if (!value) { throw new Error("HOME is not set"); } return value; }