()
| 17 | * then committed to git as normal. |
| 18 | */ |
| 19 | export 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 | |
| 42 | const snippetIds = [ |
| 43 | "betterErrors", |
no test coverage detected
searching dependent graphs…