(cmd: string)
| 207 | } |
| 208 | |
| 209 | export async function whichCmd(cmd: string): Promise<boolean> { |
| 210 | const candidate = normalizeExecutableLookup(cmd); |
| 211 | if (!candidate) return false; |
| 212 | |
| 213 | if (path.isAbsolute(candidate)) { |
| 214 | return isExecutablePath(candidate); |
| 215 | } |
| 216 | |
| 217 | const pathValue = process.env.PATH; |
| 218 | if (!pathValue) return false; |
| 219 | const pathExtensions = resolvePathExtensions(); |
| 220 | for (const directory of pathValue.split(path.delimiter)) { |
| 221 | const trimmedDirectory = directory.trim(); |
| 222 | if (!trimmedDirectory) continue; |
| 223 | for (const entry of resolveExecutableCandidates(candidate, pathExtensions)) { |
| 224 | if (await isExecutablePath(path.join(trimmedDirectory, entry))) { |
| 225 | return true; |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | return false; |
| 231 | } |
| 232 | |
| 233 | export async function resolveExecutableOverridePath( |
| 234 | rawPath: string | undefined, |
no test coverage detected