MCPcopy
hub / github.com/coder/mux / isCommandAvailable

Method isCommandAvailable

src/node/services/editorService.ts:154–167  ·  view source on GitHub ↗

* Check if a command is available in the system PATH. * Inherits enriched PATH from process.env (set by initShellEnv at startup).

(command: string)

Source from the content-addressed store, hash-verified

152 * Inherits enriched PATH from process.env (set by initShellEnv at startup).
153 */
154 private async isCommandAvailable(command: string): Promise<boolean> {
155 try {
156 if (looksLikePath(command)) {
157 await fsPromises.access(command);
158 return true;
159 }
160
161 const lookupCommand = process.platform === "win32" ? "where" : "which";
162 const result = spawnSync(lookupCommand, [command], { encoding: "utf8" });
163 return result.status === 0;
164 } catch {
165 return false;
166 }
167 }
168}

Callers 2

openInEditorMethod · 0.95
isCandidateAvailableFunction · 0.80

Calls 1

looksLikePathFunction · 0.85

Tested by

no test coverage detected