@mandujs/core 0.9.14 → 0.9.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/generator/generate.ts +7 -0
- package/src/watcher/watcher.ts +14 -0
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import { computeHash } from "../spec/lock";
|
|
|
5
5
|
import { getWatcher } from "../watcher/watcher";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import fs from "fs/promises";
|
|
8
|
+
import fsSync from "fs";
|
|
8
9
|
|
|
9
10
|
async function fileExists(filePath: string): Promise<boolean> {
|
|
10
11
|
try {
|
|
@@ -345,6 +346,12 @@ export async function generateRoutes(
|
|
|
345
346
|
|
|
346
347
|
// Resume watcher after generation
|
|
347
348
|
watcher?.resume();
|
|
349
|
+
// Cross-process timestamp: watcher skips warnings if generate finished recently
|
|
350
|
+
const stampDir = path.join(rootDir, ".mandu");
|
|
351
|
+
if (!fsSync.existsSync(stampDir)) {
|
|
352
|
+
fsSync.mkdirSync(stampDir, { recursive: true });
|
|
353
|
+
}
|
|
354
|
+
fsSync.writeFileSync(path.join(stampDir, "generate.stamp"), Date.now().toString());
|
|
348
355
|
|
|
349
356
|
return result;
|
|
350
357
|
}
|
package/src/watcher/watcher.ts
CHANGED
|
@@ -285,6 +285,20 @@ export class FileWatcher {
|
|
|
285
285
|
|
|
286
286
|
const { rootDir } = this.config;
|
|
287
287
|
|
|
288
|
+
// Cross-process: skip if generate finished within last 2 seconds
|
|
289
|
+
// Walk up from the changed file to find nearest .mandu/generate.stamp
|
|
290
|
+
let stampDir = path.dirname(filePath);
|
|
291
|
+
while (stampDir !== path.dirname(stampDir)) {
|
|
292
|
+
const stampFile = path.join(stampDir, ".mandu", "generate.stamp");
|
|
293
|
+
try {
|
|
294
|
+
const stamp = parseInt(fs.readFileSync(stampFile, "utf-8"), 10);
|
|
295
|
+
if (Date.now() - stamp < 2000) return;
|
|
296
|
+
break;
|
|
297
|
+
} catch {}
|
|
298
|
+
stampDir = path.dirname(stampDir);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
|
|
288
302
|
// Validate file against rules
|
|
289
303
|
try {
|
|
290
304
|
const warnings = await validateFile(filePath, event, rootDir);
|