MCPcopy Create free account
hub / github.com/arktypeio/arktype / unwrapWindowsCmdShim

Function unwrapWindowsCmdShim

ark/type/cli.ts:628–653  ·  view source on GitHub ↗
(
	shimPath: string,
	nodeExecPath = process.execPath
)

Source from the content-addressed store, hash-verified

626const winRunnableExts = new Set([".exe", ".com", ".cmd", ".bat"])
627
628export const unwrapWindowsCmdShim = (
629 shimPath: string,
630 nodeExecPath = process.execPath
631): AgentCommand | undefined => {
632 let text: string
633 try {
634 text = readFileSync(shimPath, "utf8")
635 } catch {
636 return undefined
637 }
638 const dir = dirname(shimPath)
639 const resolveTarget = (raw: string) =>
640 resolve(dir, ...raw.split(/[/\\]+/).filter(Boolean))
641 for (const match of text.matchAll(winShimJsPattern)) {
642 const target = resolveTarget(match[1])
643 if (statSync(target, { throwIfNoEntry: false })?.isFile())
644 return { command: nodeExecPath, args: [target] }
645 }
646 for (const match of text.matchAll(winShimExePattern)) {
647 const target = resolveTarget(match[1])
648 if (basename(target).toLowerCase() === "node.exe") continue
649 if (statSync(target, { throwIfNoEntry: false })?.isFile())
650 return { command: target, args: [] }
651 }
652 return undefined
653}
654
655export const resolveWindowsAgentCandidates = (
656 cmd: string,

Callers 2

cli.test.tsFile · 0.90

Calls 1

resolveTargetFunction · 0.85

Tested by

no test coverage detected