Files
claude-hud/src/claude-config-dir.ts
Jarrod Watts 9ae17fb644 fix: consolidate CLAUDE_CONFIG_DIR handling and keychain fallback (#160)
* fix: consolidate CLAUDE_CONFIG_DIR handling and keychain fallback

* chore: remove dist artifacts from this PR

* chore: bump version to 0.0.8

* docs: expand 0.0.8 changelog from post-0.0.7 commits
2026-03-03 16:47:15 +11:00

28 lines
823 B
TypeScript

import * as path from 'node:path';
function expandHomeDirPrefix(inputPath: string, homeDir: string): string {
if (inputPath === '~') {
return homeDir;
}
if (inputPath.startsWith('~/') || inputPath.startsWith('~\\')) {
return path.join(homeDir, inputPath.slice(2));
}
return inputPath;
}
export function getClaudeConfigDir(homeDir: string): string {
const envConfigDir = process.env.CLAUDE_CONFIG_DIR?.trim();
if (!envConfigDir) {
return path.join(homeDir, '.claude');
}
return path.resolve(expandHomeDirPrefix(envConfigDir, homeDir));
}
export function getClaudeConfigJsonPath(homeDir: string): string {
return `${getClaudeConfigDir(homeDir)}.json`;
}
export function getHudPluginDir(homeDir: string): string {
return path.join(getClaudeConfigDir(homeDir), 'plugins', 'claude-hud');
}