fix: honor CLAUDE_CONFIG_DIR in hooks (#37)

ponytail-activate.js and ponytail-runtime.js hardcoded ~/.claude for the
flag file and settings lookup, ignoring CLAUDE_CONFIG_DIR. Add a shared
getClaudeDir() to ponytail-config.js and use it in both. Regression test
added to hooks.test.js.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
DietrichGebert
2026-06-15 00:00:01 +02:00
committed by GitHub
co-authored by Claude Opus 4.8
parent 6d990f8c54
commit 01578c0cd4
4 changed files with 35 additions and 5 deletions
+25
View File
@@ -16,6 +16,10 @@ function run(script, env, input = '') {
});
}
// Keep the base env clean so the default-dir checks are deterministic; the
// CLAUDE_CONFIG_DIR case sets it explicitly.
delete process.env.CLAUDE_CONFIG_DIR;
const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'ponytail-hooks-'));
const home = path.join(temp, 'home');
const pluginData = path.join(temp, 'plugin-data');
@@ -74,5 +78,26 @@ assert.equal(
'full',
);
// CLAUDE_CONFIG_DIR overrides ~/.claude for the flag file (issue #34).
const home2 = path.join(temp, 'home2');
fs.mkdirSync(home2, { recursive: true });
const customConfigDir = path.join(temp, 'custom-claude');
result = run('ponytail-activate.js', {
HOME: home2,
USERPROFILE: home2,
CLAUDE_CONFIG_DIR: customConfigDir,
PONYTAIL_DEFAULT_MODE: 'lite',
});
assert.equal(result.status, 0, result.stderr);
assert.equal(
fs.readFileSync(path.join(customConfigDir, '.ponytail-active'), 'utf8'),
'lite',
);
assert.equal(
fs.existsSync(path.join(home2, '.claude', '.ponytail-active')),
false,
'flag must not land in ~/.claude when CLAUDE_CONFIG_DIR is set',
);
fs.rmSync(temp, { recursive: true, force: true });
console.log('hook compatibility checks passed');