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

Function settingsFileOf

ark/aot/settings.ts:62–79  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

60
61// ark.json, or the package.json whose "ark" key holds the same settings
62export const settingsFileOf = (cwd: string): string | undefined => {
63 for (let dir = realPathOf(cwd); ; dir = dirname(dir)) {
64 const manifest = join(dir, "package.json")
65 if (existsSync(manifest)) {
66 const path = join(dir, settingsFile)
67 const { ark } = readJson(manifest) as { ark?: unknown }
68 if (!existsSync(path)) return ark === undefined ? undefined : manifest
69 // a library's "aot" is for its consumers, so it may build with ark.json
70 if (ark !== undefined) {
71 validated(validators.PackageArk, ark, `${manifest}: ark.`)
72 if ((ark as { precompile?: unknown }).precompile !== undefined)
73 throw new Error(writeSettingsConflictMessage(manifest, path))
74 }
75 return path
76 }
77 if (dirname(dir) === dir) return
78 }
79}
80
81const readSettingsFile = (path: string): PrecompilePluginOptions => {
82 const json = readJson(path)

Callers 3

turbopack.tsFile · 0.90
checkSettingsFunction · 0.90
withSettingsFileFunction · 0.85

Calls 5

realPathOfFunction · 0.90
joinFunction · 0.85
validatedFunction · 0.85
readJsonFunction · 0.70

Tested by

no test coverage detected