mirror of
https://github.com/jarrodwatts/claude-hud.git
synced 2026-04-27 06:42:41 +00:00
* 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
28 lines
823 B
TypeScript
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');
|
|
}
|