refactor(core): consolidate filesystem services (#30447)

This commit is contained in:
Dax 2026-06-02 16:09:26 -04:00 committed by GitHub
commit 604a5f781f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
153 changed files with 2542 additions and 4301 deletions

View file

@ -0,0 +1,14 @@
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
}