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

Function packageOfFile

ark/aot/unplugin.ts:3262–3274  ·  view source on GitHub ↗
(file: string)

Source from the content-addressed store, hash-verified

3260
3261// a workspace's linked packages have their package.json outside node_modules
3262const packageOfFile = (file: string): string | undefined => {
3263 const dir = dirname(file)
3264 if (packagesByDir.has(dir)) return packagesByDir.get(dir)
3265 let name: string | undefined
3266 try {
3267 const manifest = join(dir, "package.json")
3268 name = parsePackageManifest(readFileSync(manifest, "utf8"), manifest).name
3269 } catch {
3270 name = dir === dirname(dir) ? undefined : packageOfFile(dir)
3271 }
3272 packagesByDir.set(dir, name)
3273 return name
3274}
3275
3276const externalizableSpecifiers = [
3277 ...runtimeSpecifiers,

Callers 1

unsharedExternalOfFunction · 0.85

Calls 5

parsePackageManifestFunction · 0.90
joinFunction · 0.85
getMethod · 0.65
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected