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

Function packageBinDir

node/src/locate.ts:71–84  ·  view source on GitHub ↗

* Find the package root (the dir containing `bin/`). The built bundle lives in * `dist/`, so the package root is one level up; but be robust to either layout * by checking `./bin` and `../bin` relative to the module dir.

()

Source from the content-addressed store, hash-verified

69 * by checking `./bin` and `../bin` relative to the module dir.
70 */
71function packageBinDir(): string {
72 const here = moduleDir();
73 const candidates = [
74 join(here, "bin"), // module sits at package root (unbundled / tests)
75 join(here, "..", "bin"), // module sits in dist/ (the published bundle)
76 join(here, "..", "..", "bin"),
77 ];
78 for (const c of candidates) {
79 if (existsSync(c)) return c;
80 }
81 // Default to the dist/.. layout even if the dir does not yet exist, so the
82 // error below names a sensible path.
83 return join(here, "..", "bin");
84}
85
86export function locateBinary(): string {
87 const override = process.env.CMDOP_CORE_BINARY;

Callers 1

locateBinaryFunction · 0.85

Calls 1

moduleDirFunction · 0.85

Tested by

no test coverage detected