mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-23 00:05:27 +00:00
pre-bash-dev-server-block.js refuses a dev server outside tmux and auto-tmux-dev.js is what puts it in tmux, so a command one recognises and the other does not is the worst outcome: refused, and never detached. Both carried a copy of the same raw-text regex, each with a comment asking the other to stay byte-identical — which is exactly how the previous commit left them, since widening the blocker to quoted and option-separated spellings did not reach the wrapper. The classification now lives in scripts/lib/dev-command.js and both hooks call it. pre-bash-dev-server-block.js drops from 304 lines to 34.
35 lines
908 B
JavaScript
Executable File
35 lines
908 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
'use strict';
|
|
|
|
const MAX_STDIN = 1024 * 1024;
|
|
const { isDevServerCommand } = require('../lib/dev-command');
|
|
|
|
let raw = '';
|
|
process.stdin.setEncoding('utf8');
|
|
process.stdin.on('data', chunk => {
|
|
if (raw.length < MAX_STDIN) {
|
|
const remaining = MAX_STDIN - raw.length;
|
|
raw += chunk.substring(0, remaining);
|
|
}
|
|
});
|
|
|
|
process.stdin.on('end', () => {
|
|
try {
|
|
const input = JSON.parse(raw);
|
|
const cmd = String(input.tool_input?.command || '');
|
|
|
|
if (process.platform !== 'win32') {
|
|
if (isDevServerCommand(cmd)) {
|
|
console.error('[Hook] BLOCKED: Dev server must run in tmux for log access');
|
|
console.error('[Hook] Use: tmux new-session -d -s dev "npm run dev"');
|
|
console.error('[Hook] Then: tmux attach -t dev');
|
|
process.exit(2);
|
|
}
|
|
}
|
|
} catch {
|
|
// ignore parse errors and pass through
|
|
}
|
|
|
|
process.stdout.write(raw);
|
|
});
|