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

Function packageTarget

src/resolution/workspace-packages.ts:276–284  ·  view source on GitHub ↗

A package-relative target (`./src/index.ts`) → projectRoot-relative posix, or null if it leaves the package.

(projectRoot: string, dirRel: string, target: string)

Source from the content-addressed store, hash-verified

274
275/** A package-relative target (`./src/index.ts`) → projectRoot-relative posix, or null if it leaves the package. */
276function packageTarget(projectRoot: string, dirRel: string, target: string): string | null {
277 const trimmed = target.trim();
278 if (!trimmed) return null;
279 const packageDir = path.resolve(projectRoot, dirRel);
280 const abs = path.resolve(packageDir, trimmed);
281 const inside = path.relative(packageDir, abs);
282 if (inside.startsWith('..') || path.isAbsolute(inside)) return null;
283 return path.relative(projectRoot, abs).replace(/\\/g, '/');
284}
285
286/**
287 * Read an ohpm member's declared entry file: `<dir>/oh-package.json5`'s

Callers 1

inPackageFunction · 0.85

Calls 1

resolveMethod · 0.65

Tested by

no test coverage detected