MCPcopy Create free account
hub / github.com/PhantomKnight287/frameground / getModuleDir

Function getModuleDir

apps/web/utils/path.ts:5–16  ·  view source on GitHub ↗
(moduleEntry: string)

Source from the content-addressed store, hash-verified

3import { createRequire } from "module";
4
5export const getModuleDir = (moduleEntry: string) => {
6 const packageName = moduleEntry.includes("/")
7 ? moduleEntry.startsWith("@")
8 ? moduleEntry.split("/").slice(0, 2).join("/")
9 : moduleEntry.split("/")[0]
10 : moduleEntry;
11 const require = createRequire(import.meta.url);
12 const lookupPaths = require.resolve
13 .paths(moduleEntry)!
14 .map((p) => path.join(p, packageName));
15 return lookupPaths.find((p) => fs.existsSync(p));
16};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected