MCPcopy Create free account
hub / github.com/blockmatic/basilic / waitForFile

Function waitForFile

packages/core/scripts/wait-and-watch.mjs:11–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9const scriptDir = import.meta.dirname;
10const openapiPath = join(scriptDir, "../../../apps/api/openapi/openapi.json");
11
12function waitForFile() {
13 if (existsSync(openapiPath)) {
14 logger.info("✅ openapi.json found, starting watcher...");
15 const child = exec(
16 `chokidar "${openapiPath}" -c "pnpm generate" --initial`,
17 { cwd: join(scriptDir, "..") },
18 (error) => {
19 if (error) {
20 logger.error({ error }, "❌ Watcher error");
21 process.exit(1);
22 }
23 }
24 );
25 child.stdout?.pipe(process.stdout);
26 child.stderr?.pipe(process.stderr);
27 } else {
28 logger.info("⏳ Waiting for openapi.json...");
29 setTimeout(waitForFile, 500);
30 }
31}
32
33waitForFile();

Callers 1

wait-and-watch.mjsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected