MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / waitForStudioDist

Function waitForStudioDist

packages/cli/scripts/build-copy.mjs:20–34  ·  view source on GitHub ↗
(dir)

Source from the content-addressed store, hash-verified

18
19// fallow-ignore-next-line complexity
20async function waitForStudioDist(dir) {
21 const deadline = Date.now() + STUDIO_WAIT_TIMEOUT_MS;
22 while (Date.now() < deadline) {
23 try {
24 const entries = new Set(readdirSync(dir));
25 // vite emits `assets/` before rewriting `index.html` at the end of the
26 // build — so once both are present, the tree is complete.
27 if (entries.has("index.html") && entries.has("assets")) return;
28 } catch {
29 // dir doesn't exist yet — vite will create it
30 }
31 await sleep(STUDIO_POLL_INTERVAL_MS);
32 }
33 throw new Error(`[build-copy] timed out waiting for studio dist at ${dir}`);
34}
35
36function copyDir(src, dest) {
37 cpSync(src, dest, { recursive: true, force: true });

Callers 1

mainFunction · 0.85

Calls 2

nowMethod · 0.80
sleepFunction · 0.50

Tested by

no test coverage detected