| 29 | }; |
| 30 | |
| 31 | async function runCommand(cmd: string, args: string[], cwd: string): Promise<LintResult> { |
| 32 | try { |
| 33 | const { stdout, stderr } = await execFileAsync(cmd, args, { cwd, timeout: 30000, maxBuffer: 1024 * 512 }); |
| 34 | return { tool: cmd, output: (stdout + stderr).trim(), exitCode: 0 }; |
| 35 | } catch (err: any) { |
| 36 | return { tool: cmd, output: (err.stdout ?? "") + (err.stderr ?? ""), exitCode: err.code ?? 1 }; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | async function detectAvailableLinter(rootDir: string, ext: string): Promise<{ cmd: string; args: string[] } | null> { |
| 41 | const config = LINTER_MAP[ext]; |