@makuja/peek 1.6.6 → 1.7.0

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.
Files changed (2) hide show
  1. package/dist/index.mjs +23 -8
  2. package/package.json +4 -2
package/dist/index.mjs CHANGED
@@ -307,7 +307,8 @@ function createFileWatcher(debounceMs = 100) {
307
307
  debounced(filePath, () => callback(filePath));
308
308
  if (eventType === "rename") watcher.close();
309
309
  });
310
- watcher.on("error", () => {
310
+ watcher.on("error", (error) => {
311
+ logger.warn(`File watcher error for ${filePath}:`, error);
311
312
  watcher.close();
312
313
  });
313
314
  watchers.push(watcher);
@@ -319,7 +320,8 @@ function createFileWatcher(debounceMs = 100) {
319
320
  const filePath = filename.toString();
320
321
  if (isSupportedFile(filePath)) debounced(filePath, () => callback(filePath));
321
322
  });
322
- watcher.on("error", () => {
323
+ watcher.on("error", (error) => {
324
+ logger.warn(`Directory watcher error for ${dirPath}:`, error);
323
325
  watcher.close();
324
326
  });
325
327
  watchers.push(watcher);
@@ -1310,14 +1312,20 @@ async function startServer(config) {
1310
1312
  server.close((err) => err ? reject(err) : resolve());
1311
1313
  });
1312
1314
  const sseCloseAll = () => sse.closeAll();
1315
+ let shutdownPromise;
1313
1316
  return {
1314
1317
  close,
1315
1318
  watcher,
1316
1319
  sseCloseAll,
1317
- async shutdown() {
1318
- sseCloseAll();
1319
- watcher.close();
1320
- await close();
1320
+ shutdown() {
1321
+ if (shutdownPromise) return shutdownPromise;
1322
+ shutdownPromise = (async () => {
1323
+ sseCloseAll();
1324
+ watcher.close();
1325
+ if ("closeAllConnections" in server) server.closeAllConnections();
1326
+ await close();
1327
+ })();
1328
+ return shutdownPromise;
1321
1329
  }
1322
1330
  };
1323
1331
  }
@@ -1432,11 +1440,18 @@ $ peek README.md --css ./custom.css --no-open`,
1432
1440
  outro(pc.dim("Press Ctrl+C to stop"));
1433
1441
  let shuttingDown = false;
1434
1442
  const shutdown = async () => {
1435
- if (shuttingDown) return;
1443
+ if (shuttingDown) {
1444
+ console.error("\nForce exiting...");
1445
+ process.exit(1);
1446
+ }
1436
1447
  shuttingDown = true;
1437
1448
  console.log();
1438
1449
  intro(pc.bgYellow(pc.black(" Shutting down... ")));
1439
- await server.shutdown();
1450
+ try {
1451
+ await server.shutdown();
1452
+ } catch (e) {
1453
+ logger.error("Failed to shut down server:", e);
1454
+ }
1440
1455
  outro(pc.green("Server stopped. Bye!"));
1441
1456
  process.exit(0);
1442
1457
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makuja/peek",
3
- "version": "1.6.6",
3
+ "version": "1.7.0",
4
4
  "description": "Markdown and HTML preview CLI with live reload",
5
5
  "type": "module",
6
6
  "bin": {
@@ -26,6 +26,7 @@
26
26
  "typecheck": "tsgo",
27
27
  "test": "vitest run",
28
28
  "test:watch": "vitest",
29
+ "test:coverage": "vitest run --coverage",
29
30
  "prepublishOnly": "pnpm build"
30
31
  },
31
32
  "keywords": [
@@ -72,12 +73,13 @@
72
73
  "@types/markdown-it": "^14.1.2",
73
74
  "@types/node": "^25.3.3",
74
75
  "@typescript/native-preview": "7.0.0-dev.20260318.1",
76
+ "@vitest/coverage-v8": "^4.1.1",
75
77
  "esbuild": "^0.27.3",
76
78
  "postcss": "^8.5.6",
77
79
  "postcss-cli": "^11.0.1",
78
80
  "semantic-release": "^25.0.3",
79
81
  "tailwindcss": "^4.2.1",
80
- "tsdown": "0.21.2",
82
+ "tsdown": "0.21.4",
81
83
  "tsx": "^4.21.0",
82
84
  "typescript": "^5.9.3",
83
85
  "vitest": "^4.0.18"