qunitx-cli 0.21.0 → 0.21.2

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/cli.js +43 -4
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2588,7 +2588,7 @@ var init_tests_in_browser = __esm({
2588
2588
 
2589
2589
  // lib/setup/file-watcher.ts
2590
2590
  import fs10 from "node:fs";
2591
- import { stat, lstat } from "node:fs/promises";
2591
+ import { readdir, stat, lstat } from "node:fs/promises";
2592
2592
  import path8 from "node:path";
2593
2593
  function setupFileWatchers(testFileLookupPaths, config, onEventFunc, onFinishFunc) {
2594
2594
  const extensions = config.extensions || ["js", "ts"];
@@ -2623,7 +2623,20 @@ function setupFileWatchers(testFileLookupPaths, config, onEventFunc, onFinishFun
2623
2623
  const lastEventMs = {};
2624
2624
  const seenMtimeMs = {};
2625
2625
  const childWatcher = fs10.watch(watchPath, { recursive: true }, async (eventType, filename) => {
2626
- if (!ready || !filename) return;
2626
+ if (!ready) return;
2627
+ if (!filename) {
2628
+ if (process.platform === "darwin") {
2629
+ await rescanDirectoryForDelta(
2630
+ watchPath,
2631
+ config,
2632
+ extensions,
2633
+ onEventFunc,
2634
+ onFinishFunc,
2635
+ trackSymlink
2636
+ );
2637
+ }
2638
+ return;
2639
+ }
2627
2640
  const fullPath = filename === path8.basename(watchPath) ? watchPath : path8.join(watchPath, filename);
2628
2641
  if (eventType === "change") {
2629
2642
  const now = Date.now();
@@ -2759,6 +2772,28 @@ function handleWatchEvent(config, extensions, event, filePath, onEventFunc, onFi
2759
2772
  }
2760
2773
  });
2761
2774
  }
2775
+ async function rescanDirectoryForDelta(watchPath, config, extensions, onEventFunc, onFinishFunc, trackSymlinkFn) {
2776
+ try {
2777
+ const entries = await readdir(watchPath, { withFileTypes: true, recursive: true });
2778
+ const presentPaths = /* @__PURE__ */ new Set();
2779
+ for (const entry of entries) {
2780
+ if (!entry.isFile() && !entry.isSymbolicLink()) continue;
2781
+ const entryPath = path8.join(entry.parentPath, entry.name);
2782
+ if (!extensions.some((ext) => entryPath.endsWith(`.${ext}`))) continue;
2783
+ presentPaths.add(entryPath);
2784
+ if (!(entryPath in config.fsTree)) {
2785
+ if (entry.isSymbolicLink()) trackSymlinkFn?.(entryPath);
2786
+ handleWatchEvent(config, extensions, "add", entryPath, onEventFunc, onFinishFunc);
2787
+ }
2788
+ }
2789
+ const watchPrefix = watchPath + path8.sep;
2790
+ for (const trackedPath of Object.keys(config.fsTree)) {
2791
+ if (trackedPath.startsWith(watchPrefix) && !presentPaths.has(trackedPath))
2792
+ handleWatchEvent(config, extensions, "unlink", trackedPath, onEventFunc, onFinishFunc);
2793
+ }
2794
+ } catch {
2795
+ }
2796
+ }
2762
2797
  function mutateFSTree(fsTree, event, filePath) {
2763
2798
  if (event === "add") {
2764
2799
  fsTree[filePath] = null;
@@ -2918,6 +2953,9 @@ async function run(config) {
2918
2953
  ]);
2919
2954
  config.webServer = connections.server;
2920
2955
  setupKeyboardEvents(config, cachedContent, connections);
2956
+ process.once("SIGTERM", () => {
2957
+ connections.server.close().finally(() => process.exit(EXIT_CODE_SIGTERM));
2958
+ });
2921
2959
  const isHeadedWatchMode = config.open === true && config.watch;
2922
2960
  if (config.open && !isHeadedWatchMode) {
2923
2961
  void openOutputInBrowser(config);
@@ -3261,7 +3299,7 @@ function normalizeInternalAssetPathFromHTML(projectRoot, assetPath, htmlPath) {
3261
3299
  const currentDirectory = htmlPath ? htmlPath.split("/").slice(0, -1).join("/") : projectRoot;
3262
3300
  return assetPath.startsWith("./") ? normalize(`${currentDirectory}/${assetPath.slice(2)}`) : normalize(`${currentDirectory}/${assetPath}`);
3263
3301
  }
3264
- var WATCH_NAV_TIMEOUT_MS, PAGE_CLOSE_GRACE_MS, STDOUT_FLUSH_GRACE_MS, KEEP_ALIVE_INTERVAL_MS;
3302
+ var WATCH_NAV_TIMEOUT_MS, PAGE_CLOSE_GRACE_MS, STDOUT_FLUSH_GRACE_MS, KEEP_ALIVE_INTERVAL_MS, EXIT_CODE_SIGTERM;
3265
3303
  var init_run = __esm({
3266
3304
  "lib/commands/run.ts"() {
3267
3305
  init_browser();
@@ -3285,6 +3323,7 @@ var init_run = __esm({
3285
3323
  PAGE_CLOSE_GRACE_MS = 1e4;
3286
3324
  STDOUT_FLUSH_GRACE_MS = 5e3;
3287
3325
  KEEP_ALIVE_INTERVAL_MS = 1e4;
3326
+ EXIT_CODE_SIGTERM = 128 + 15;
3288
3327
  }
3289
3328
  });
3290
3329
 
@@ -3299,7 +3338,7 @@ init_color();
3299
3338
  var package_default = {
3300
3339
  name: "qunitx-cli",
3301
3340
  type: "module",
3302
- version: "0.21.0",
3341
+ version: "0.21.2",
3303
3342
  description: "Browser runner for QUnitx: run your qunitx tests in google-chrome",
3304
3343
  author: "Izel Nakri",
3305
3344
  license: "MIT",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qunitx-cli",
3
3
  "type": "module",
4
- "version": "0.21.0",
4
+ "version": "0.21.2",
5
5
  "description": "Browser runner for QUnitx: run your qunitx tests in google-chrome",
6
6
  "author": "Izel Nakri",
7
7
  "license": "MIT",