mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-02 15:13:28 +08:00
fix: add cwd to prettier hook, consistent process.exit(0), and stdout pass-through
- post-edit-format.js: add cwd based on file directory so npx resolves correct local prettier binary - post-edit-typecheck.js, post-edit-format.js: replace console.log(data) with process.stdout.write(data) to avoid trailing newline corruption - Add process.exit(0) to 4 hooks for consistent termination (check-console-log, post-edit-console-warn, post-edit-format, post-edit-typecheck) - run-all.js: switch from execSync to spawnSync so stderr is visible on the success path (hook warnings were silently discarded) - Add 21 tests: cwd verification, process.exit(0) checks, exact stdout pass-through, extension edge cases, exclusion pattern matching, threshold boundary values (630 → 651)
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* Usage: node tests/run-all.js
|
||||
*/
|
||||
|
||||
const { execSync } = require('child_process');
|
||||
const { spawnSync } = require('child_process');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
@@ -46,32 +46,25 @@ for (const testFile of testFiles) {
|
||||
|
||||
console.log(`\n━━━ Running ${testFile} ━━━`);
|
||||
|
||||
try {
|
||||
const output = execSync(`node "${testPath}"`, {
|
||||
encoding: 'utf8',
|
||||
stdio: ['pipe', 'pipe', 'pipe']
|
||||
});
|
||||
console.log(output);
|
||||
const result = spawnSync('node', [testPath], {
|
||||
encoding: 'utf8',
|
||||
stdio: ['pipe', 'pipe', 'pipe']
|
||||
});
|
||||
|
||||
// Parse results from output
|
||||
const passedMatch = output.match(/Passed:\s*(\d+)/);
|
||||
const failedMatch = output.match(/Failed:\s*(\d+)/);
|
||||
const stdout = result.stdout || '';
|
||||
const stderr = result.stderr || '';
|
||||
|
||||
if (passedMatch) totalPassed += parseInt(passedMatch[1], 10);
|
||||
if (failedMatch) totalFailed += parseInt(failedMatch[1], 10);
|
||||
// Show both stdout and stderr so hook warnings are visible
|
||||
if (stdout) console.log(stdout);
|
||||
if (stderr) console.log(stderr);
|
||||
|
||||
} catch (err) {
|
||||
console.log(err.stdout || '');
|
||||
console.log(err.stderr || '');
|
||||
// Parse results from combined output
|
||||
const combined = stdout + stderr;
|
||||
const passedMatch = combined.match(/Passed:\s*(\d+)/);
|
||||
const failedMatch = combined.match(/Failed:\s*(\d+)/);
|
||||
|
||||
// Parse results even on failure
|
||||
const output = (err.stdout || '') + (err.stderr || '');
|
||||
const passedMatch = output.match(/Passed:\s*(\d+)/);
|
||||
const failedMatch = output.match(/Failed:\s*(\d+)/);
|
||||
|
||||
if (passedMatch) totalPassed += parseInt(passedMatch[1], 10);
|
||||
if (failedMatch) totalFailed += parseInt(failedMatch[1], 10);
|
||||
}
|
||||
if (passedMatch) totalPassed += parseInt(passedMatch[1], 10);
|
||||
if (failedMatch) totalFailed += parseInt(failedMatch[1], 10);
|
||||
}
|
||||
|
||||
totalTests = totalPassed + totalFailed;
|
||||
|
||||
Reference in New Issue
Block a user