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