INNER CODE UNIT · JavaScript
log
karanb192/claude-code-hooks · plugins/auto-stage/auto-stage.js:37
function log(data) {
try {
if (!fs.existsSync(LOG_DIR)) fs.mkdirSync(LOG_DIR, { recursive: true });
const file = path.join(LOG_DIR, `${new Date().toISOString().slice(0, 10)}.jsonl`);
fs.appendFileSync(file, JSON.stringify({ ts: new Date().toISOString(), hook: 'auto-stage', ...data }) + '\n');
} catch {}
}
function isInGitRepo(filePath) {
try {
const dir = path.dirname(filePath);
execSync('git rev-parse --git-dir', { cwd: dir, stdio: 'pipe' });
return true;
} catch {
return false;
}
}