commit 5368a261b7beda8dd754a80c4f0c1f236206e053
parent 2bff196c5c961185f4c0b714370c3f54ad5a7029
Author: Henry Unite <unitehenry@gmail.com>
Date: Sat, 24 Oct 2026 23:13:18 +0000
refactor(context): make isCommandAvailable private inside init()
- Move isCommandAvailable from context/command.ts into init() scope as a local function
- Delete context/command.ts (no longer needed)
- Import execSync directly in context/index.ts
- isCommandAvailable is now private to the init() function
Diffstat:
2 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/context/command.ts b/context/command.ts
@@ -1,17 +0,0 @@
-import { execSync } from "node:child_process";
-
-export function isCommandAvailable(command: string): boolean {
- try {
- if (process.platform === "win32") {
- execSync(`where ${command}`, { stdio: "ignore" });
- } else {
- execSync(`command -v ${command}`, {
- stdio: "ignore",
- shell: "/bin/sh",
- });
- }
- return true;
- } catch {
- return false;
- }
-}
diff --git a/context/index.ts b/context/index.ts
@@ -1,8 +1,8 @@
import * as os from "node:os";
import * as path from "node:path";
+import { execSync } from "node:child_process";
import { initLogger, type Logger } from "./log";
-import { isCommandAvailable } from "./command";
import { initCleanup, type Cleanup } from "./cleanup";
export type OpenpodContext = {
@@ -17,6 +17,22 @@ export async function init(): Promise<OpenpodContext> {
const logger = initLogger(openpodRoot);
const cleanup = initCleanup(openpodRoot, logger);
+ function isCommandAvailable(command: string): boolean {
+ try {
+ if (process.platform === "win32") {
+ execSync(`where ${command}`, { stdio: "ignore" });
+ } else {
+ execSync(`command -v ${command}`, {
+ stdio: "ignore",
+ shell: "/bin/sh",
+ });
+ }
+ return true;
+ } catch {
+ return false;
+ }
+ }
+
if (!isCommandAvailable("limactl")) {
logger.log(
"`limactl` is not installed. Lima is required for openpod. See https://lima-vm.io/",