fix: exact byte pass-through in post-edit-console-warn, add 7 tests

Replace console.log(data) with process.stdout.write(data) in both
pass-through paths to prevent appending a trailing newline that
corrupts the hook output. Add 7 tests covering exact byte fidelity,
malformed JSON, missing file_path, non-existent files, exclusion
patterns in check-console-log, non-git repo handling, and empty stdin.
This commit is contained in:
Affaan Mustafa
2026-02-13 02:49:33 -08:00
parent f4758ff8f0
commit 6bbcbec23d
2 changed files with 68 additions and 2 deletions

View File

@@ -28,7 +28,7 @@ process.stdin.on('end', () => {
if (filePath && /\.(ts|tsx|js|jsx)$/.test(filePath)) {
const content = readFile(filePath);
if (!content) { console.log(data); return; }
if (!content) { process.stdout.write(data); return; }
const lines = content.split('\n');
const matches = [];
@@ -48,5 +48,5 @@ process.stdin.on('end', () => {
// Invalid input — pass through
}
console.log(data);
process.stdout.write(data);
});