MCPcopy
hub / github.com/arktypeio/arktype / updateSnippetsEntrypoint

Function updateSnippetsEntrypoint

ark/docs/lib/writeSnippetsEntrypoint.ts:19–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17 * then committed to git as normal.
18 */
19export const updateSnippetsEntrypoint = () => {
20 const snippetContentsById = flatMorph(snippetIds, (i, id) => {
21 const tsPath = snippetPath(`${id}.twoslash.ts`)
22 const jsPath = snippetPath(`${id}.twoslash.js`)
23
24 const path =
25 existsSync(tsPath) ? tsPath
26 : existsSync(jsPath) ? jsPath
27 : throwInternalError(
28 `Expected a snippet file at ${tsPath} or ${jsPath} (neither existed).`
29 )
30 // don't include trailing newline
31 return [id, readFile(path).trimEnd()]
32 })
33
34 const toPath = snippetPath("contentsById.ts")
35
36 const contents = `// prettier-ignore\nexport default ${JSON.stringify(snippetContentsById, null, 4)}\n`
37
38 if (!existsSync(toPath) || readFile(toPath) !== contents)
39 writeFile(toPath, contents)
40}
41
42const snippetIds = [
43 "betterErrors",

Callers 1

next.config.tsFile · 0.90

Calls 6

flatMorphFunction · 0.90
throwInternalErrorFunction · 0.90
readFileFunction · 0.90
writeFileFunction · 0.90
snippetPathFunction · 0.85
stringifyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…