Download packages/core/src/util/which.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 536 Bytes
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/core/src/util/which.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/core/src/util/which.ts
-
curl -L -o which.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/core/src/util/which.ts
536 Bytes
| import whichPkg from "which" | |
| import path from "path" | |
| import { Global } from "../global" | |
| export function which(cmd: string, env?: NodeJS.ProcessEnv) { | |
| const base = env?.PATH ?? env?.Path ?? process.env.PATH ?? process.env.Path ?? "" | |
| const full = base ? base + path.delimiter + Global.Path.bin : Global.Path.bin | |
| const result = whichPkg.sync(cmd, { | |
| nothrow: true, | |
| path: full, | |
| pathExt: env?.PATHEXT ?? env?.PathExt ?? process.env.PATHEXT ?? process.env.PathExt, | |
| }) | |
| return typeof result === "string" ? result : null | |
| } | |