refactor: extract magic number to named constant in execFile utility

Extracted the magic number `10 * 1024 * 1024` to a named constant
`EXEC_MAX_BUFFER` for better code clarity and maintainability. Added
explanatory comment documenting the 10MB buffer size limit.

- Created EXEC_MAX_BUFFER constant at module top
- Replaced inline magic number with constant reference
- Added documentation comment

Resolves housekeeping task #26
This commit is contained in:
Pedram Amini
2025-11-23 23:48:59 -06:00
parent 4e79701cce
commit 17f44f2a8e

View File

@@ -3,6 +3,9 @@ import { promisify } from 'util';
const execFileAsync = promisify(execFile);
// Maximum buffer size for command output (10MB)
const EXEC_MAX_BUFFER = 10 * 1024 * 1024;
export interface ExecResult {
stdout: string;
stderr: string;
@@ -22,7 +25,7 @@ export async function execFileNoThrow(
const { stdout, stderr } = await execFileAsync(command, args, {
cwd,
encoding: 'utf8',
maxBuffer: 10 * 1024 * 1024, // 10MB buffer
maxBuffer: EXEC_MAX_BUFFER,
});
return {