qunitx-cli 0.23.5 → 0.23.7

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 +38 -15
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -374,7 +374,7 @@ var init_package = __esm({
374
374
  package_default = {
375
375
  name: "qunitx-cli",
376
376
  type: "module",
377
- version: "0.23.5",
377
+ version: "0.23.7",
378
378
  description: "Browser runner for QUnitx: run your qunitx tests in google-chrome",
379
379
  author: "Izel Nakri",
380
380
  license: "MIT",
@@ -892,9 +892,9 @@ async function pingDaemon() {
892
892
  socket.end();
893
893
  return pong;
894
894
  }
895
- async function shutdownDaemon() {
896
- const pid = await readDaemonPid();
897
- const socket = await tryConnect();
895
+ async function shutdownDaemon(cwd = process.cwd()) {
896
+ const pid = await readDaemonPid(cwd);
897
+ const socket = await tryConnect(cwd);
898
898
  if (!socket) return false;
899
899
  attachLineParser(socket, () => {
900
900
  });
@@ -903,9 +903,9 @@ async function shutdownDaemon() {
903
903
  if (pid !== null) await waitForPidExit(pid, SHUTDOWN_PID_WAIT_MS);
904
904
  return true;
905
905
  }
906
- async function readDaemonPid() {
906
+ async function readDaemonPid(cwd = process.cwd()) {
907
907
  try {
908
- const info = JSON.parse(await fs6.readFile(daemonInfoPath(), "utf8"));
908
+ const info = JSON.parse(await fs6.readFile(daemonInfoPath(cwd), "utf8"));
909
909
  return typeof info.pid === "number" ? info.pid : null;
910
910
  } catch {
911
911
  return null;
@@ -1137,7 +1137,7 @@ function parseCliFlags(projectRoot) {
1137
1137
  return result2;
1138
1138
  }
1139
1139
  result2.inputs.add(
1140
- arg.startsWith(projectRoot) || arg.startsWith("/") ? arg : path5.join(process.cwd(), arg)
1140
+ arg.startsWith(projectRoot) || path5.isAbsolute(arg) ? arg : path5.join(process.cwd(), arg)
1141
1141
  );
1142
1142
  return result2;
1143
1143
  },
@@ -3329,15 +3329,16 @@ async function runTestInsideHTMLFile(filePath, { page, server, browser }, config
3329
3329
  let targetError;
3330
3330
  let timeoutHandle;
3331
3331
  let wsConnected = false;
3332
+ let resolveTestRace;
3333
+ const testRaceResult = new Promise((resolve) => {
3334
+ resolveTestRace = resolve;
3335
+ });
3336
+ page.on("close", resolveTestRace);
3332
3337
  try {
3333
3338
  console.log("#", blue(`QUnitX running: http://localhost:${config.port}${filePath}`));
3334
3339
  const navMs = Math.max(config.timeout + NAV_GRACE_MS, MIN_NAV_MS);
3335
3340
  const startupMs = Math.max(config.timeout * STARTUP_TIMEOUT_FACTOR, navMs);
3336
3341
  const testsJsMs = Math.max(config.timeout * TESTS_JS_TIMEOUT_FACTOR, navMs);
3337
- let resolveTestRace;
3338
- const testRaceResult = new Promise((resolve) => {
3339
- resolveTestRace = resolve;
3340
- });
3341
3342
  config._testRunDone = resolveTestRace;
3342
3343
  config._onWsOpen = () => {
3343
3344
  wsConnected = true;
@@ -3370,6 +3371,7 @@ async function runTestInsideHTMLFile(filePath, { page, server, browser }, config
3370
3371
  console.error(error);
3371
3372
  } finally {
3372
3373
  clearTimeout(timeoutHandle);
3374
+ page.off("close", resolveTestRace);
3373
3375
  config._onWsOpen = null;
3374
3376
  config._onTestsJsServed = null;
3375
3377
  config._resetTestTimeout = null;
@@ -3532,6 +3534,7 @@ function setupFileWatchers(testFileLookupPaths, config, onEventFunc, onFinishFun
3532
3534
  const rescanTimers = [];
3533
3535
  const fileWatchers = {};
3534
3536
  const symlinkPollers = /* @__PURE__ */ new Map();
3537
+ const pendingChangeTimers = /* @__PURE__ */ new Map();
3535
3538
  function trackSymlink(filePath) {
3536
3539
  if (symlinkPollers.has(filePath)) return;
3537
3540
  const handler = (curr, prev) => {
@@ -3543,7 +3546,15 @@ function setupFileWatchers(testFileLookupPaths, config, onEventFunc, onFinishFun
3543
3546
  }
3544
3547
  } else if ((process.platform === "win32" || process.platform === "darwin") && curr.mtimeMs !== prev.mtimeMs) {
3545
3548
  if (filePath in config.fsTree) {
3546
- handleWatchEvent(config, extensions, "change", filePath, onEventFunc, onFinishFunc);
3549
+ const existing = pendingChangeTimers.get(filePath);
3550
+ if (existing) clearTimeout(existing);
3551
+ pendingChangeTimers.set(
3552
+ filePath,
3553
+ setTimeout(() => {
3554
+ pendingChangeTimers.delete(filePath);
3555
+ handleWatchEvent(config, extensions, "change", filePath, onEventFunc, onFinishFunc);
3556
+ }, CHANGE_COALESCE_MS)
3557
+ );
3547
3558
  }
3548
3559
  }
3549
3560
  };
@@ -3591,7 +3602,16 @@ function setupFileWatchers(testFileLookupPaths, config, onEventFunc, onFinishFun
3591
3602
  return;
3592
3603
  } catch {
3593
3604
  }
3594
- return handleWatchEvent(config, extensions, "change", fullPath, onEventFunc, onFinishFunc);
3605
+ const existing = pendingChangeTimers.get(fullPath);
3606
+ if (existing) clearTimeout(existing);
3607
+ pendingChangeTimers.set(
3608
+ fullPath,
3609
+ setTimeout(() => {
3610
+ pendingChangeTimers.delete(fullPath);
3611
+ handleWatchEvent(config, extensions, "change", fullPath, onEventFunc, onFinishFunc);
3612
+ }, CHANGE_COALESCE_MS)
3613
+ );
3614
+ return;
3595
3615
  }
3596
3616
  const event = await classifyRenameEvent(fullPath, config.fsTree);
3597
3617
  if (!event) return;
@@ -3681,6 +3701,8 @@ function setupFileWatchers(testFileLookupPaths, config, onEventFunc, onFinishFun
3681
3701
  rescanTimers.forEach((t) => clearInterval(t));
3682
3702
  symlinkPollers.forEach((cancel) => cancel());
3683
3703
  symlinkPollers.clear();
3704
+ pendingChangeTimers.forEach((t) => clearTimeout(t));
3705
+ pendingChangeTimers.clear();
3684
3706
  return fileWatchers;
3685
3707
  }
3686
3708
  };
@@ -3815,7 +3837,7 @@ function colorEvent(event) {
3815
3837
  if (event === "add" || event === "addDir") return green("ADDED:");
3816
3838
  return red("REMOVED:");
3817
3839
  }
3818
- var CHANGE_DEDUPE_MS, SYMLINK_POLL_INTERVAL_MS, OVERLAYFS_RENAME_RETRY_MS, RESCAN_INTERVAL_MS, ADD_SUPPRESS_WINDOW_MS, justAddedAt;
3840
+ var CHANGE_DEDUPE_MS, SYMLINK_POLL_INTERVAL_MS, OVERLAYFS_RENAME_RETRY_MS, RESCAN_INTERVAL_MS, CHANGE_COALESCE_MS, ADD_SUPPRESS_WINDOW_MS, justAddedAt;
3819
3841
  var init_file_watcher = __esm({
3820
3842
  "lib/setup/file-watcher.ts"() {
3821
3843
  init_color();
@@ -3824,6 +3846,7 @@ var init_file_watcher = __esm({
3824
3846
  SYMLINK_POLL_INTERVAL_MS = 500;
3825
3847
  OVERLAYFS_RENAME_RETRY_MS = 50;
3826
3848
  RESCAN_INTERVAL_MS = 1e3;
3849
+ CHANGE_COALESCE_MS = 50;
3827
3850
  ADD_SUPPRESS_WINDOW_MS = 1e3;
3828
3851
  justAddedAt = /* @__PURE__ */ new WeakMap();
3829
3852
  }
@@ -4378,7 +4401,7 @@ var init_run = __esm({
4378
4401
  init_close_with_grace();
4379
4402
  init_daemon_hint();
4380
4403
  WATCH_NAV_TIMEOUT_MS = 5e3;
4381
- STDOUT_FLUSH_GRACE_MS = 5e3;
4404
+ STDOUT_FLUSH_GRACE_MS = 3e4;
4382
4405
  KEEP_ALIVE_INTERVAL_MS = 1e4;
4383
4406
  EXIT_CODE_SIGTERM = 128 + 15;
4384
4407
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qunitx-cli",
3
3
  "type": "module",
4
- "version": "0.23.5",
4
+ "version": "0.23.7",
5
5
  "description": "Browser runner for QUnitx: run your qunitx tests in google-chrome",
6
6
  "author": "Izel Nakri",
7
7
  "license": "MIT",