MCPcopy Create free account
hub / github.com/anomalyco/opencode / linkBinary

Function linkBinary

nix/scripts/normalize-bun-binaries.ts:85–104  ·  view source on GitHub ↗
(binRoot: string, name: string, packageDir: string, target: string, seen: Set<string>)

Source from the content-addressed store, hash-verified

83}
84
85async function linkBinary(binRoot: string, name: string, packageDir: string, target: string, seen: Set<string>) {
86 if (!name || !target) {
87 return
88 }
89 const normalizedName = normalizeBinName(name)
90 if (seen.has(normalizedName)) {
91 return
92 }
93 const resolved = join(packageDir, target)
94 const script = Bun.file(resolved)
95 if (!(await script.exists())) {
96 return
97 }
98 seen.add(normalizedName)
99 const destination = join(binRoot, normalizedName)
100 const relativeTarget = relative(binRoot, resolved) || "."
101 await rm(destination, { force: true })
102 await symlink(relativeTarget, destination)
103 rewritten++
104}
105
106async function exists(path: string) {
107 try {

Callers 1

Calls 7

normalizeBinNameFunction · 0.85
joinFunction · 0.85
symlinkFunction · 0.85
fileMethod · 0.80
addMethod · 0.65
rmFunction · 0.50
existsMethod · 0.45

Tested by

no test coverage detected