MCPcopy Create free account
hub / github.com/commandoperator/cmdop-sdk / locateBinary

Function locateBinary

node/src/locate.ts:86–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

84}
85
86export function locateBinary(): string {
87 const override = process.env.CMDOP_CORE_BINARY;
88 if (override) {
89 if (!existsSync(override)) {
90 throw new Error(`CMDOP_CORE_BINARY points at a missing file: ${override}`);
91 }
92 makeExecutable(override);
93 return override;
94 }
95
96 const key = `${process.platform}-${process.arch}`;
97 if (!SUPPORTED_PLATFORMS.has(key)) {
98 throw new Error(
99 `cmdop-core has no prebuilt binary for ${key}. ` +
100 "Set CMDOP_CORE_BINARY to a `go build -o /path/cmdop-core ./cmd/cmdop-core` output.",
101 );
102 }
103
104 const binPath = join(packageBinDir(), binaryName());
105 if (!existsSync(binPath)) {
106 throw new Error(
107 `cmdop-core binary not found at ${binPath}. ` +
108 "Reinstall @cmdop/sdk (the 5 baked binaries ship in its bin/ dir), " +
109 "or set CMDOP_CORE_BINARY to a local `go build` output.",
110 );
111 }
112 makeExecutable(binPath);
113 return binPath;
114}
115
116function makeExecutable(path: string): void {
117 if (process.platform === "win32") return;

Callers 2

constructorMethod · 0.90
locate.test.tsFile · 0.90

Calls 3

makeExecutableFunction · 0.85
packageBinDirFunction · 0.85
binaryNameFunction · 0.85

Tested by

no test coverage detected