Improved process management

This commit is contained in:
Mateusz Tymek
2026-02-14 16:57:42 +01:00
parent f2c31a0c6f
commit adc34d31f1
10 changed files with 407 additions and 78 deletions

View File

@@ -1,4 +1,5 @@
import { ChildProcess, spawn, SpawnOptions } from "child_process";
import { existsSync } from "fs";
import { OpenCodeProcess } from "./OpenCodeProcess";
export class PosixProcess implements OpenCodeProcess {
@@ -46,12 +47,16 @@ export class PosixProcess implements OpenCodeProcess {
async verifyCommand(command: string): Promise<string | null> {
// Check if command is absolute path - verify it exists and is executable
if (command.startsWith('/') || command.startsWith('./')) {
const fs = require('fs');
try {
const fs = require('fs');
fs.accessSync(command, fs.constants.X_OK);
return null;
} catch {
return `Executable not found at '${command}'`;
} catch (err: any) {
// Check if file exists but isn't executable
if (existsSync(command)) {
return `'${command}' exists but is not executable. Run: chmod +x ${command}`;
}
return `Executable not found at '${command}'. Check Settings → OpenCode path, or click "Autodetect"`;
}
}
// For non-absolute paths, let spawn handle it (will fire ENOENT if not found)