refactor: migrated binary detection to $which() utility across codebase

- Replaced all Bun.which() calls with $which() utility from @oh-my-pi/pi-utils across 22 files.
- Removed findBashOnPath() wrapper function from procmgr.ts, consolidating binary path resolution.
- Updated AGENTS.md documentation to reflect new $which() API usage pattern.
- Centralized binary detection logic through shared utility, reducing code duplication.
This commit is contained in:
can1357
2026-04-08 05:28:22 +02:00
parent 528d8225b7
commit 6d07944654
23 changed files with 93 additions and 81 deletions
+4 -4
View File
@@ -4,7 +4,7 @@
* Handles `omp setup <component>` to install dependencies for optional features.
*/
import * as path from "node:path";
import { APP_NAME, getPythonEnvDir } from "@oh-my-pi/pi-utils";
import { $which, APP_NAME, getPythonEnvDir } from "@oh-my-pi/pi-utils";
import { $ } from "bun";
import chalk from "chalk";
import { theme } from "../modes/theme/theme";
@@ -90,12 +90,12 @@ async function checkPythonSetup(): Promise<PythonCheckResult> {
managedEnvPath: MANAGED_PYTHON_ENV,
};
const systemPythonPath = Bun.which("python") ?? Bun.which("python3");
const systemPythonPath = $which("python") ?? $which("python3");
const managedPath = managedPythonPath();
const hasManagedEnv = await Bun.file(managedPath).exists();
result.uvPath = Bun.which("uv") ?? undefined;
result.pipPath = Bun.which("pip3") ?? Bun.which("pip") ?? undefined;
result.uvPath = $which("uv") ?? undefined;
result.pipPath = $which("pip3") ?? $which("pip") ?? undefined;
const candidates = [systemPythonPath, hasManagedEnv ? managedPath : undefined].filter(
(candidate): candidate is string => !!candidate,