@theholocron/kyber 5.0.0-alpha.365 → 5.0.0-alpha.366

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.
@@ -8,6 +8,10 @@ interface CliRun {
8
8
  stderr: string;
9
9
  /** The exit code; -1 if the process was killed by the timeout. */
10
10
  code: number;
11
+ /** True only when the timeout killed the run; `stderr` then ends with a line saying how long it ran and what it printed. */
12
+ timedOut: boolean;
13
+ /** How long the run took, from spawn to close, in milliseconds. */
14
+ elapsedMs: number;
11
15
  }
12
16
  /** What one run of the CLI is given. */
13
17
  interface RunCliOptions {
package/dist/testing.mjs CHANGED
@@ -44,14 +44,28 @@ function createCliRunner(options) {
44
44
  let stderr = "";
45
45
  child.stdout.on("data", (d) => stdout += d);
46
46
  child.stderr.on("data", (d) => stderr += d);
47
- const timer = setTimeout(() => child.kill("SIGKILL"), run.timeoutMs ?? 2e4);
47
+ const timeoutMs = run.timeoutMs ?? 2e4;
48
+ const started = Date.now();
49
+ let timedOut = false;
50
+ const timer = setTimeout(() => {
51
+ timedOut = true;
52
+ child.kill("SIGKILL");
53
+ }, timeoutMs);
48
54
  child.on("error", reject);
49
- child.on("close", (code) => {
55
+ child.on("close", (code, signal) => {
50
56
  clearTimeout(timer);
57
+ const elapsedMs = Date.now() - started;
58
+ if (timedOut) {
59
+ const note = `[cli-runner] killed after ${elapsedMs} ms (timeout ${timeoutMs} ms, ${signal}), pid ${child.pid}; stdout ${stdout.length} chars, stderr ${stderr.length} chars before this line; args: [${args.join(" ")}]`;
60
+ stderr += `\n${note}`;
61
+ console.error(note);
62
+ }
51
63
  resolve({
52
64
  stdout,
53
65
  stderr,
54
- code: code ?? -1
66
+ code: code ?? -1,
67
+ timedOut,
68
+ elapsedMs
55
69
  });
56
70
  });
57
71
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/kyber",
3
- "version": "5.0.0-alpha.365",
3
+ "version": "5.0.0-alpha.366",
4
4
  "description": "The reusable parts of a command-line tool: terminal output, prompts, the interactive menu, the update notifier, safe handling of tokens, a test harness and the global flags.",
5
5
  "keywords": [
6
6
  "cli",
@@ -105,12 +105,12 @@
105
105
  "typescript": "^5.9.3",
106
106
  "vitest": "^5.0.5",
107
107
  "yargs": "^18.1.0",
108
- "@theholocron/datapad": "5.0.0-alpha.365",
108
+ "@theholocron/datapad": "5.0.0-alpha.366",
109
109
  "@theholocron/eslint-config": "^8.9.0-alpha.11",
110
110
  "@theholocron/tsconfig": "^8.9.0-alpha.11",
111
- "@theholocron/tsdown-config": "^8.9.0-alpha.11",
111
+ "@theholocron/observability": "0.7.0-alpha.2",
112
112
  "@theholocron/vitest-config": "^8.9.0-alpha.11",
113
- "@theholocron/observability": "0.7.0-alpha.2"
113
+ "@theholocron/tsdown-config": "^8.9.0-alpha.11"
114
114
  },
115
115
  "peerDependencies": {
116
116
  "@inquirer/prompts": "^8.0.0",
@@ -121,7 +121,7 @@
121
121
  "dotenv": "^17.0.0",
122
122
  "ora": "^9.0.0",
123
123
  "yargs": "^18.0.0",
124
- "@theholocron/datapad": "^5.0.0-alpha.365",
124
+ "@theholocron/datapad": "^5.0.0-alpha.366",
125
125
  "@theholocron/observability": "^0.7.0-alpha.2"
126
126
  },
127
127
  "peerDependenciesMeta": {