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

Function checkArktypeVersion

ark/aot/version.ts:14–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12// lacking what the precompiler imports, as arktype 2 lacks arktype/codecs, so
13// each entry checks it before loading a module that imports arktype
14export const checkArktypeVersion = (): void => {
15 for (
16 let root = dirname(fileURLToPath(import.meta.resolve("arktype")));
17 root !== dirname(root);
18 root = dirname(root)
19 ) {
20 const path = join(root, "package.json")
21 if (!existsSync(path)) continue
22 const { name, version, arkAotVersion } = parsePackageManifest(
23 readFileSync(path, "utf8"),
24 path
25 )
26 if (name !== "arktype") continue
27 if (version === arktypeVersion) return
28 throwBuildError(
29 `arktype resolves to ${version}, but @ark/aot runs on ${arktypeVersion}\n ${version} at ${printablePathOf(process.cwd(), root)}, which @ark/aot imports\n ${version && arkAotVersion ? writeVersionHint(version, arkAotVersion) : writeArktypeHint(arktypeVersion)}`
30 )
31 }
32}

Callers 5

createKeyedPrecompilerFunction · 0.90
readAndWriteFunction · 0.90
createSyncPrecompilerFunction · 0.90
createAsyncPrecompilerFunction · 0.90
cli.tsFile · 0.90

Calls 5

parsePackageManifestFunction · 0.90
throwBuildErrorFunction · 0.90
printablePathOfFunction · 0.90
joinFunction · 0.85
resolveMethod · 0.65

Tested by

no test coverage detected