(path: string)
| 55 | if (exe) return exe |
| 56 | |
| 57 | const resolveCmd = async (path: string) => { |
| 58 | const content = await readFile(path, "utf8") |
| 59 | for (const token of content.split('"').map((value: string) => value.trim())) { |
| 60 | const lower = token.toLowerCase() |
| 61 | if (!lower.includes(".exe")) continue |
| 62 | |
| 63 | const index = lower.indexOf("%~dp0") |
| 64 | if (index >= 0) { |
| 65 | const base = dirname(path) |
| 66 | const suffix = token.slice(index + 5) |
| 67 | const resolved = suffix |
| 68 | .replace(/\//g, "\\") |
| 69 | .split("\\") |
| 70 | .filter((part: string) => part && part !== ".") |
| 71 | .reduce((current: string, part: string) => { |
| 72 | if (part === "..") return dirname(current) |
| 73 | return join(current, part) |
| 74 | }, base) |
| 75 | |
| 76 | if (await exists(resolved)) return resolved |
| 77 | } |
| 78 | |
| 79 | if (await exists(token)) return token |
| 80 | } |
| 81 | |
| 82 | return null |
| 83 | } |
| 84 | |
| 85 | for (const path of paths) { |
| 86 | if (hasExt(path, "cmd") || hasExt(path, "bat")) { |
no test coverage detected