feat: add dry-run mode for hook execution (#2116) (#2188)

- Global --dry-run flag and ECC_DRY_RUN=1 env var
- Enriched preview: shows target file path, tool name, and command
- --dry-run stripped from argv so command routing works correctly
- Handles non-JSON and empty stdin gracefully (session/stop hooks)
- 10 tests covering isDryRun(), hook gating, enriched output, CLI routing
This commit is contained in:
Naomi
2026-06-15 19:01:21 +01:00
committed by GitHub
parent d24c7185fc
commit 48608863ea
4 changed files with 326 additions and 2 deletions
+5
View File
@@ -50,6 +50,10 @@ function parseProfiles(rawProfiles, fallback = ['standard', 'strict']) {
return parsed.length > 0 ? parsed : [...fallback];
}
function isDryRun() {
return process.env.ECC_DRY_RUN === '1';
}
function isHookEnabled(hookId, options = {}) {
const id = normalizeId(hookId);
if (!id) return true;
@@ -71,4 +75,5 @@ module.exports = {
getDisabledHookIds,
parseProfiles,
isHookEnabled,
isDryRun,
};