MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / requireSdk

Function requireSdk

__tests__/npm-sdk.test.ts:65–75  ·  view source on GitHub ↗
(mainPkg: string, env: Record<string, string> = {})

Source from the content-addressed store, hash-verified

63
64// require() the SDK in a child process so each case gets a fresh module cache.
65function requireSdk(mainPkg: string, env: Record<string, string> = {}) {
66 const code =
67 `try { const m = require(${JSON.stringify(path.join(mainPkg, 'npm-sdk.js'))});` +
68 ` process.stdout.write(JSON.stringify({ sentinel: m.SENTINEL, cg: typeof m.CodeGraph })); }` +
69 ` catch (e) { process.stderr.write(String(e && e.message || e)); process.exit(7); }`;
70 const r = spawnSync(process.execPath, ['-e', code], {
71 encoding: 'utf8',
72 env: { ...process.env, ...env },
73 });
74 return { status: r.status, stdout: r.stdout, stderr: r.stderr };
75}
76
77describe('npm-sdk programmatic entry', () => {
78 it('re-exports the installed platform bundle library', () => {

Callers 1

npm-sdk.test.tsFile · 0.85

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected