microsoft/typespec
Publicmirrored from https://github.com/microsoft/typespecAvailable
packages/compiler/scripts/watch-tmlanguage.js
16lines · modecode
| 1 | import { runWatch } from "@typespec/internal-build-utils"; |
| 2 | import { copyFile, mkdir } from "fs/promises"; |
| 3 | import { resolve } from "path"; |
| 4 | import { pathToFileURL } from "url"; |
| 5 | |
| 6 | let count = 0; |
| 7 | const scriptPath = resolve("dist/src/server/tmlanguage.js"); |
| 8 | |
| 9 | async function regenerate() { |
| 10 | const script = await import(`${pathToFileURL(scriptPath)}?q=${count++}`); |
| 11 | await script.main(); |
| 12 | await mkdir("../typespec-vscode/dist", { recursive: true }); |
| 13 | await copyFile("dist/typespec.tmLanguage", "../typespec-vscode/dist/typespec.tmLanguage"); |
| 14 | } |
| 15 | |
| 16 | runWatch("dist/src/server/tmlanguage.js", regenerate, {}); |