MCPcopy Create free account
hub / github.com/arktypeio/arktype / nodeModulesOf

Function nodeModulesOf

ark/aot/nextProgram.ts:56–68  ·  view source on GitHub ↗
(root: string)

Source from the content-addressed store, hash-verified

54// node_modules/.cache/ark-units, where a build resolves them and Turbopack
55// doesn't deny them as it does .next
56const nodeModulesOf = (root: string): string | undefined => {
57 let cacheOnly: string | undefined
58 for (let dir = root; ; dir = dirname(dir)) {
59 const modules = join(dir, "node_modules")
60 if (existsSync(modules)) {
61 // skip a node_modules created only for .cache/ark-programs so warm builds
62 // keep resolving the same package-manager node_modules as cold builds
63 if (readdirSync(modules).some(name => name !== ".cache")) return modules
64 cacheOnly ??= modules
65 }
66 if (dir === dirname(dir)) return cacheOnly
67 }
68}
69
70export const isProgramUnit = (id: string): boolean =>
71 /[/\\]node_modules[/\\]\.cache[/\\]ark-units[/\\]/.test(id)

Callers 1

readProgramFunction · 0.85

Calls 1

joinFunction · 0.85

Tested by

no test coverage detected