adc62957a7
CI / Multi-repo Path Gate (AST-grep) (windows-latest) (push) Has been cancelled
CI / Version Consistency Check (push) Has been cancelled
CI / npm pack + install test (push) Has been cancelled
CI / Lint & Type Check (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Test (Windows path suite) (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / No Committed Build Artifacts (push) Has been cancelled
CI / Multi-repo Path Gate (AST-grep) (ubuntu-latest) (push) Has been cancelled
Upgrade Test / omc update + session-start hook (push) Has been cancelled
40 lines
975 B
JavaScript
40 lines
975 B
JavaScript
const { homedir } = require('node:os');
|
|
const { join, normalize, parse, sep } = require('node:path');
|
|
|
|
function stripTrailingSep(p) {
|
|
if (!p.endsWith(sep)) {
|
|
return p;
|
|
}
|
|
|
|
return p === parse(p).root ? p : p.slice(0, -1);
|
|
}
|
|
|
|
function getClaudeConfigDir() {
|
|
const home = homedir();
|
|
const configured = process.env.CLAUDE_CONFIG_DIR?.trim();
|
|
|
|
if (!configured) {
|
|
return stripTrailingSep(normalize(join(home, '.claude')));
|
|
}
|
|
|
|
if (configured === '~') {
|
|
return stripTrailingSep(normalize(home));
|
|
}
|
|
|
|
if (configured.startsWith('~/') || configured.startsWith('~\\')) {
|
|
return stripTrailingSep(normalize(join(home, configured.slice(2))));
|
|
}
|
|
|
|
return stripTrailingSep(normalize(configured));
|
|
}
|
|
|
|
function getOmcConfigDir() {
|
|
return join(getClaudeConfigDir(), '.omc');
|
|
}
|
|
|
|
function getUpdateCheckCachePath() {
|
|
return join(getOmcConfigDir(), 'update-check.json');
|
|
}
|
|
|
|
module.exports = { getClaudeConfigDir, getOmcConfigDir, getUpdateCheckCachePath };
|