MCPcopy Index your code
hub / github.com/anomalyco/opencode / resolveCmd

Function resolveCmd

packages/desktop/src/main/apps.ts:57–83  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

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")) {

Callers 1

resolveWindowsAppPathFunction · 0.85

Calls 3

readFileFunction · 0.85
joinFunction · 0.85
existsFunction · 0.70

Tested by

no test coverage detected