cliprobe 0.5.0 → 0.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.
- package/README.md +24 -18
- package/dist/cli.js +201 -65
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ npx cliprobe -- esbuild
|
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
cliprobe 0.
|
|
10
|
+
cliprobe 0.6.0: closed-pipe, color, pipe-escapes, stdin, ctrl-c, restore, control-chars checks for esbuild
|
|
11
11
|
|
|
12
12
|
closed-pipe
|
|
13
13
|
FAIL esbuild --version crashed when stdout was closed (exit 0 -> 1)
|
|
@@ -28,7 +28,7 @@ stdin
|
|
|
28
28
|
PASS esbuild --help finished without waiting for stdin
|
|
29
29
|
|
|
30
30
|
ctrl-c
|
|
31
|
-
SKIP esbuild needs probe args that keep it running, such as a watch or serve command
|
|
31
|
+
SKIP esbuild needs probe args that keep it running, such as a watch or serve command, or --bare
|
|
32
32
|
|
|
33
33
|
restore
|
|
34
34
|
PASS esbuild --version left no terminal mode switched on when it exited
|
|
@@ -57,20 +57,22 @@ npx cliprobe -- node ./dist/cli.js list # test your own CLI before publishing
|
|
|
57
57
|
npx cliprobe --json -- <command> # machine-readable results
|
|
58
58
|
npx cliprobe --format junit -o report.xml -- <command> # JUnit file for CI; human report on stdout
|
|
59
59
|
npx cliprobe -- ls {fixture} # {fixture}: a directory of hostile file names
|
|
60
|
+
npx cliprobe --bare -- htop # the command alone: a REPL, a full-screen program, a server
|
|
60
61
|
npx cliprobe --check startup,baseline -- node ./dist/cli.js # info checks, only when named
|
|
61
62
|
```
|
|
62
63
|
|
|
63
64
|
| Option | Meaning |
|
|
64
65
|
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
|
|
66
|
+
| `--bare` | Probe the command with no arguments instead of `--version` and `--help`, as a probe you wrote |
|
|
65
67
|
| `--check <name>` | Run only this check; repeat it or use commas for several |
|
|
66
68
|
| `--format <name>` | Output format: `human` (default), `json`, `markdown` (a GitHub job summary or PR comment) or `junit` (XML for CI test reports) |
|
|
67
69
|
| `--json` | Same as `--format json` |
|
|
68
70
|
| `-o`, `--output-file <path>` | Write the `--format` report to a file (atomically, creating parent folders); the human report still prints |
|
|
69
|
-
| `--timeout <ms>` | Kill a probe after this long (default 15000)
|
|
71
|
+
| `--timeout <ms>` | Kill a probe after this long (default 15000); a command still running then is judged on what it did so far |
|
|
70
72
|
| `-h`, `--help` | Show help |
|
|
71
73
|
| `-v`, `--version` | Show the version |
|
|
72
74
|
|
|
73
|
-
Exit codes: `0` no failures, `1` a check failed, `2` usage error or the command could not run. That makes it usable as a CI gate.
|
|
75
|
+
Exit codes: `0` no failures, `1` a check failed, `2` usage error or the command could not run. A command that isn't on `PATH` is reported once, before any check runs, with exit `2` and no report. That makes it usable as a CI gate.
|
|
74
76
|
|
|
75
77
|
### In CI
|
|
76
78
|
|
|
@@ -98,14 +100,18 @@ In JUnit, each check is a test suite and each probe a test case: `FAIL` is a fai
|
|
|
98
100
|
|
|
99
101
|
A default run does the seven checks below: closed-pipe, color, pipe-escapes, stdin, ctrl-c, restore and control-chars. Each one reports evidence, never a score. Two info checks, startup and baseline, run only when you name them with `--check`.
|
|
100
102
|
|
|
103
|
+
A command that keeps running, such as a server, a watcher or a full-screen program, is what ctrl-c and restore need. The other checks judge it on what it did before the timeout (`--timeout`, 15 seconds by default): a crash once stdout is closed still fails, color or a spinner in a pipe still counts, and stdin is skipped. The timeout is paid once: after the first check sees the command still running, the others watch it for 3 seconds.
|
|
104
|
+
|
|
101
105
|
**closed-pipe**. cliprobe runs the command twice: once normally, then with stdout set to a pipe whose reading end is already closed, so the first write fails every time, even for fast native programs. Results:
|
|
102
106
|
|
|
103
|
-
| Verdict | Meaning
|
|
104
|
-
| ------- |
|
|
105
|
-
| `PASS` | Exited quietly, or was stopped by SIGPIPE (the Unix convention)
|
|
106
|
-
| `FAIL` | Printed an EPIPE error or stack trace and changed its exit code, or hung
|
|
107
|
-
| `WARN` | Printed a write error but kept its exit code
|
|
108
|
-
| `SKIP` | Wrote nothing to stdout for this invocation, so pass args that print something
|
|
107
|
+
| Verdict | Meaning |
|
|
108
|
+
| ------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
109
|
+
| `PASS` | Exited quietly, or was stopped by SIGPIPE (the Unix convention), or kept running without a write error |
|
|
110
|
+
| `FAIL` | Printed an EPIPE error or stack trace and changed its exit code, or hung, or crashed on it while a normal run kept running |
|
|
111
|
+
| `WARN` | Printed a write error but kept its exit code |
|
|
112
|
+
| `SKIP` | Wrote nothing to stdout for this invocation (or before the timeout), so pass args that print something |
|
|
113
|
+
|
|
114
|
+
Servers and watchers crash the same way. Among 38 watch and serve modes of popular npm tools, 8 died with `Error: write EPIPE` as soon as their stdout reader went away, each confirmed by hand: `jest --watchAll`, `live-server`, `mocha --watch`, `nodemon`, `parcel`, `rolldown -w`, `srvx` and `vite build --watch`. None was flagged falsely.
|
|
109
115
|
|
|
110
116
|
**color**. cliprobe runs the command up to three times: into a pipe, under a real terminal (a pseudo-terminal through the system's `script` command, 80×24), and under a terminal with `NO_COLOR=1`. Every run gets `TERM=xterm-256color` and no `CI` variable, so a program can't pass just because the terminal type looks colorless, and color libraries that force color in CI don't fail it. Color codes in piped output end up in log files and agent transcripts as `\x1b[31m` noise. Results:
|
|
111
117
|
|
|
@@ -126,7 +132,7 @@ Many classic tools (git, BSD `ls` and `grep`) color correctly but don't implemen
|
|
|
126
132
|
| `WARN` | One or more reached stdout or stderr; the reason lists which kinds |
|
|
127
133
|
| `SKIP` | Printed nothing |
|
|
128
134
|
|
|
129
|
-
It only warns for now, never fails. In the census of the top 100 npm CLIs, no `--help` or `--version` printed any of these codes, which says nothing about their spinners: probe a command that does real work, such as an install or a build.
|
|
135
|
+
It only warns for now, never fails. In the census of the top 100 npm CLIs, no `--help` or `--version` printed any of these codes, which says nothing about their spinners: probe a command that does real work, such as an install or a build. With `{fixture}` in the args, the hostile file names themselves are left to the control-chars check: a lister that prints them raw into a pipe, as `ls` does, isn't warned about.
|
|
130
136
|
|
|
131
137
|
**stdin**. Agents and CI runners often start a command with stdin as a pipe that stays open and never receives anything. A program that reads stdin, or asks a question, then waits forever. cliprobe runs the command three ways: with stdin closed (`/dev/null`), with an open pipe, and, if that hangs for 3 seconds, with a pipe it closes after 1 second. Finishing right after the close proves stdin was the cause. Results:
|
|
132
138
|
|
|
@@ -162,12 +168,12 @@ It only warns: a terminal left in the wrong mode is a nuisance you can undo, not
|
|
|
162
168
|
|
|
163
169
|
**control-chars**. Put `{fixture}` in the arguments where your command takes a path, for example `npx cliprobe -- ls {fixture}` or `npx cliprobe -- node ./dist/cli.js scan --dir={fixture}`. cliprobe replaces it with a temporary directory of file names holding escape sequences (one sets the window title, one clears the screen), a C1 control character, a carriage return, a newline and a bidirectional override. It runs the command under a terminal and looks for those characters, unescaped, in what reaches it. A file name that can clear someone's screen or retitle their window is a terminal injection, the same bug class as the `ls`/`find` escaping that GNU coreutils added years ago. Reports show `{fixture}`, never the temporary path, and the directory is removed afterwards. Results:
|
|
164
170
|
|
|
165
|
-
| Verdict | Meaning
|
|
166
|
-
| ------- |
|
|
167
|
-
| `PASS` | Escaped or replaced the control characters (a raw bidi override is mentioned, not judged)
|
|
168
|
-
| `FAIL` | Sent an escape sequence from a file name to the terminal unescaped
|
|
169
|
-
| `WARN` | Printed a C1 control, carriage return or newline from a file name unescaped, which can hide or forge output
|
|
170
|
-
| `SKIP` | No `{fixture}` in the arguments, the command never printed the file names, or no usable `script`
|
|
171
|
+
| Verdict | Meaning |
|
|
172
|
+
| ------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
173
|
+
| `PASS` | Escaped or replaced the control characters (a raw bidi override is mentioned, not judged) |
|
|
174
|
+
| `FAIL` | Sent an escape sequence from a file name to the terminal unescaped |
|
|
175
|
+
| `WARN` | Printed a C1 control, carriage return or newline from a file name unescaped, which can hide or forge output |
|
|
176
|
+
| `SKIP` | No `{fixture}` in the arguments, the command never printed the file names (before the timeout, for one that keeps running), or no usable `script` |
|
|
171
177
|
|
|
172
178
|
Only the terminal run is judged. Into a pipe, `ls` and `find` print names exactly, by design; that is recorded in the JSON (`pipeRaw`) but doesn't affect the verdict. BSD `find` on macOS fails this check: unlike GNU `find`, it prints names raw even to a terminal.
|
|
173
179
|
|
|
@@ -235,7 +241,7 @@ Also escape U+2028, U+2029 and the bidi controls (U+202A to U+202E, U+2066 to U+
|
|
|
235
241
|
|
|
236
242
|
## Safety
|
|
237
243
|
|
|
238
|
-
cliprobe runs the target in your current directory without a shell, with stdin closed (`/dev/null`; the stdin check also uses a pipe that it never writes to), a temporary `HOME`, and a minimal environment (no tokens from your shell). It still executes the program, so only probe programs you trust. By default cliprobe passes only the arguments you give, or `--version` and `--help`; only the baseline check, when you name it, adds an unknown flag. The only input it ever sends is Ctrl-C, from the ctrl-c and restore checks, to probes you write. It kills each run's whole process group on timeout, including under a pseudo-terminal. It runs on macOS and Linux, including Alpine; the terminal checks need the `script` command, which Alpine ships in `util-linux-misc`. Windows isn't supported yet.
|
|
244
|
+
cliprobe runs the target in your current directory without a shell, with stdin closed (`/dev/null`; the stdin check also uses a pipe that it never writes to), a temporary `HOME`, and a minimal environment (no tokens from your shell). It still executes the program, so only probe programs you trust. By default cliprobe passes only the arguments you give, or `--version` and `--help`, or none with `--bare`; only the baseline check, when you name it, adds an unknown flag. The only input it ever sends is Ctrl-C, from the ctrl-c and restore checks, to probes you write. It kills each run's whole process group on timeout, including under a pseudo-terminal. It runs on macOS and Linux, including Alpine; the terminal checks need the `script` command, which Alpine ships in `util-linux-misc`. Windows isn't supported yet.
|
|
239
245
|
|
|
240
246
|
## License
|
|
241
247
|
|
package/dist/cli.js
CHANGED
|
@@ -147,7 +147,13 @@ const UNKNOWN_FLAG = "--cliprobe-unknown-flag";
|
|
|
147
147
|
/** A program that ignores unknown flags may start its default action; don't wait long. */
|
|
148
148
|
const UNKNOWN_FLAG_TIMEOUT_MS = 5e3;
|
|
149
149
|
const lines = (text) => text.split("\n").filter((l) => l.trim() !== "");
|
|
150
|
-
|
|
150
|
+
/** The first line printed, labelled with its stream, as evidence. */
|
|
151
|
+
function firstLine(r) {
|
|
152
|
+
const out = lines(r.stdout.toString("utf8"))[0];
|
|
153
|
+
if (out !== void 0) return `stdout: ${out}`;
|
|
154
|
+
const err = lines(r.stderr)[0];
|
|
155
|
+
return err === void 0 ? "" : `stderr: ${err}`;
|
|
156
|
+
}
|
|
151
157
|
const exitText = (r) => r.signal ? `was stopped by ${r.signal}` : `exited ${r.exitCode}`;
|
|
152
158
|
/** Each describes one convention scripts and agents rely on; observations, never verdicts. */
|
|
153
159
|
function describeVersion(r) {
|
|
@@ -162,7 +168,7 @@ function describeVersion(r) {
|
|
|
162
168
|
};
|
|
163
169
|
if (out.length > 1) return {
|
|
164
170
|
reason: `printed ${out.length} lines to stdout; one line is easier for scripts to parse`,
|
|
165
|
-
evidence: out[0] ?? ""
|
|
171
|
+
evidence: `first line: ${out[0] ?? ""}`
|
|
166
172
|
};
|
|
167
173
|
if (lines(r.stderr).length) return {
|
|
168
174
|
reason: "printed the version to stderr, not stdout",
|
|
@@ -256,17 +262,68 @@ function crashEvidence(stderr, messages = CRASH_MESSAGES) {
|
|
|
256
262
|
const cwd = process.cwd() + "/";
|
|
257
263
|
return `${message} (at ${frame.startsWith(cwd) ? frame.slice(cwd.length) : frame})`;
|
|
258
264
|
}
|
|
265
|
+
// src/core/long-running.ts
|
|
266
|
+
/**
|
|
267
|
+
* Once one check has seen a probe still running at the timeout (a server, a
|
|
268
|
+
* watcher, a full-screen program), later checks watch it this long instead, so
|
|
269
|
+
* the timeout is paid once rather than once per check.
|
|
270
|
+
*/
|
|
271
|
+
const LONG_RUN_WINDOW_MS = 3e3;
|
|
272
|
+
const key = (command, args) => JSON.stringify([command, ...args]);
|
|
273
|
+
function isLongRunning(ctx, command, args) {
|
|
274
|
+
return ctx.longRunning?.has(key(command, args)) === true;
|
|
275
|
+
}
|
|
276
|
+
/** How long to let a normal run of this probe go: the timeout, or the short window once it is known to keep running. */
|
|
277
|
+
function probeTimeout(ctx, command, args) {
|
|
278
|
+
return isLongRunning(ctx, command, args) ? Math.min(ctx.timeout, LONG_RUN_WINDOW_MS) : ctx.timeout;
|
|
279
|
+
}
|
|
280
|
+
function markLongRunning(ctx, command, args) {
|
|
281
|
+
ctx.longRunning?.add(key(command, args));
|
|
282
|
+
}
|
|
283
|
+
/** "still running after 15 s", from a run that was stopped at its timeout. */
|
|
284
|
+
const stillRunning = (durationMs) => `still running after ${Math.round(durationMs / 1e3)} s`;
|
|
259
285
|
// src/checks/closed-pipe.ts
|
|
286
|
+
/** A program that writes an error to stderr only once its stdout is closed. */
|
|
287
|
+
const newWriteError = (base, closed) => ERROR_RE.test(closed.stderr) && !ERROR_RE.test(base.stderr);
|
|
288
|
+
/**
|
|
289
|
+
* For a program that keeps running (a server, a watcher): there is no normal exit
|
|
290
|
+
* to compare with, but a crash once stdout is closed is still a crash.
|
|
291
|
+
*/
|
|
292
|
+
function judgeLongRunning(base, closed) {
|
|
293
|
+
if (!closed.timedOut && newWriteError(base, closed)) return {
|
|
294
|
+
verdict: "fail",
|
|
295
|
+
reason: `crashed when stdout was closed, while a normal run kept running (exit ${closed.exitCode})`,
|
|
296
|
+
evidence: crashEvidence(closed.stderr)
|
|
297
|
+
};
|
|
298
|
+
if (closed.signal === "SIGPIPE") return {
|
|
299
|
+
verdict: "pass",
|
|
300
|
+
reason: "stopped by SIGPIPE, the conventional exit"
|
|
301
|
+
};
|
|
302
|
+
if (base.stdoutBytes === 0) return {
|
|
303
|
+
verdict: "skip",
|
|
304
|
+
reason: `${stillRunning(base.durationMs)} without writing to stdout, so a closed stdout was never touched`
|
|
305
|
+
};
|
|
306
|
+
if (!closed.timedOut) return {
|
|
307
|
+
verdict: "pass",
|
|
308
|
+
reason: "exited quietly when stdout was closed"
|
|
309
|
+
};
|
|
310
|
+
if (newWriteError(base, closed)) return {
|
|
311
|
+
verdict: "warn",
|
|
312
|
+
reason: "printed a write error when stdout was closed, and kept running",
|
|
313
|
+
evidence: crashEvidence(closed.stderr)
|
|
314
|
+
};
|
|
315
|
+
return {
|
|
316
|
+
verdict: "pass",
|
|
317
|
+
reason: `${stillRunning(base.durationMs)}; with stdout closed it kept running without a write error`
|
|
318
|
+
};
|
|
319
|
+
}
|
|
260
320
|
/** Compares a normal run with a closed-stdout run of the same invocation. */
|
|
261
321
|
function judge(base, closed) {
|
|
262
322
|
if (base.spawnError) return {
|
|
263
323
|
verdict: "error",
|
|
264
324
|
reason: `could not start: ${base.spawnError}`
|
|
265
325
|
};
|
|
266
|
-
if (base.timedOut) return
|
|
267
|
-
verdict: "error",
|
|
268
|
-
reason: "timed out on a normal run"
|
|
269
|
-
};
|
|
326
|
+
if (base.timedOut) return judgeLongRunning(base, closed);
|
|
270
327
|
if (base.stdoutBytes === 0) return {
|
|
271
328
|
verdict: "skip",
|
|
272
329
|
reason: "wrote nothing to stdout, so a closed stdout is never touched"
|
|
@@ -279,7 +336,7 @@ function judge(base, closed) {
|
|
|
279
336
|
verdict: "pass",
|
|
280
337
|
reason: "stopped by SIGPIPE, the conventional exit"
|
|
281
338
|
};
|
|
282
|
-
const newError =
|
|
339
|
+
const newError = newWriteError(base, closed);
|
|
283
340
|
if (newError && closed.exitCode !== base.exitCode) return {
|
|
284
341
|
verdict: "fail",
|
|
285
342
|
reason: `crashed when stdout was closed (exit ${base.exitCode} -> ${closed.exitCode})`,
|
|
@@ -299,14 +356,15 @@ function judge(base, closed) {
|
|
|
299
356
|
reason: "exited quietly"
|
|
300
357
|
};
|
|
301
358
|
}
|
|
302
|
-
async function closedPipe(command, args,
|
|
359
|
+
async function closedPipe(command, args, ctx) {
|
|
303
360
|
const base = await run$1(command, args, {
|
|
304
361
|
closedStdout: false,
|
|
305
|
-
timeout
|
|
362
|
+
timeout: probeTimeout(ctx, command, args)
|
|
306
363
|
});
|
|
364
|
+
if (base.timedOut) markLongRunning(ctx, command, args);
|
|
307
365
|
const closed = await run$1(command, args, {
|
|
308
366
|
closedStdout: true,
|
|
309
|
-
timeout
|
|
367
|
+
timeout: base.timedOut ? Math.min(ctx.timeout, LONG_RUN_WINDOW_MS) : ctx.timeout
|
|
310
368
|
});
|
|
311
369
|
return {
|
|
312
370
|
check: "closed-pipe",
|
|
@@ -331,7 +389,7 @@ const closedPipeCheck = {
|
|
|
331
389
|
summary: "crashes or hangs when stdout is closed early (| head, grep -q, an agent)",
|
|
332
390
|
async run(target, ctx) {
|
|
333
391
|
const results = [];
|
|
334
|
-
for (const args of target.invocations) results.push(await closedPipe(target.command, args, ctx
|
|
392
|
+
for (const args of target.invocations) results.push(await closedPipe(target.command, args, ctx));
|
|
335
393
|
return results;
|
|
336
394
|
}
|
|
337
395
|
};
|
|
@@ -742,10 +800,6 @@ function judgePipe(pipe) {
|
|
|
742
800
|
verdict: "error",
|
|
743
801
|
reason: `could not start: ${pipe.spawnError}`
|
|
744
802
|
};
|
|
745
|
-
if (pipe.timedOut) return {
|
|
746
|
-
verdict: "error",
|
|
747
|
-
reason: "timed out on a normal run"
|
|
748
|
-
};
|
|
749
803
|
const stdoutHit = findStyle(pipe.stdout.toString("utf8"));
|
|
750
804
|
if (stdoutHit) return {
|
|
751
805
|
verdict: "fail",
|
|
@@ -758,6 +812,10 @@ function judgePipe(pipe) {
|
|
|
758
812
|
reason: "printed color codes to stderr when it was a pipe",
|
|
759
813
|
evidence: describeHit("stderr", stderrHit)
|
|
760
814
|
};
|
|
815
|
+
if (pipe.timedOut) return {
|
|
816
|
+
verdict: "skip",
|
|
817
|
+
reason: `${stillRunning(pipe.durationMs)} with no color in a pipe so far; a terminal is compared only for a command that finishes`
|
|
818
|
+
};
|
|
761
819
|
}
|
|
762
820
|
function judgeColor(runs) {
|
|
763
821
|
const fromPipe = judgePipe(runs.pipe);
|
|
@@ -797,11 +855,13 @@ function judgeColor(runs) {
|
|
|
797
855
|
};
|
|
798
856
|
}
|
|
799
857
|
/** Runs only as many probes as the verdict needs: a pipe, then a terminal, then NO_COLOR. */
|
|
800
|
-
async function colorRuns(command, args,
|
|
858
|
+
async function colorRuns(command, args, ctx) {
|
|
859
|
+
const { timeout } = ctx;
|
|
801
860
|
const pipe = await run$1(command, args, {
|
|
802
|
-
timeout,
|
|
861
|
+
timeout: probeTimeout(ctx, command, args),
|
|
803
862
|
env: COLOR_ENV
|
|
804
863
|
});
|
|
864
|
+
if (pipe.timedOut) markLongRunning(ctx, command, args);
|
|
805
865
|
if (judgePipe(pipe)) return { pipe };
|
|
806
866
|
const support = ptySupport();
|
|
807
867
|
if (!support.ok) return {
|
|
@@ -833,8 +893,8 @@ const summarize = (r) => r ? {
|
|
|
833
893
|
timedOut: r.timedOut,
|
|
834
894
|
styled: findStyle(r.output) !== void 0
|
|
835
895
|
} : null;
|
|
836
|
-
async function color(command, args,
|
|
837
|
-
const runs = await colorRuns(command, args,
|
|
896
|
+
async function color(command, args, ctx) {
|
|
897
|
+
const runs = await colorRuns(command, args, ctx);
|
|
838
898
|
return {
|
|
839
899
|
check: "color",
|
|
840
900
|
invocation: [command, ...args],
|
|
@@ -854,7 +914,7 @@ const colorCheck = {
|
|
|
854
914
|
summary: "prints color codes into pipes, or ignores NO_COLOR in a terminal",
|
|
855
915
|
async run(target, ctx) {
|
|
856
916
|
const results = [];
|
|
857
|
-
for (const args of target.invocations) results.push(await color(target.command, args, ctx
|
|
917
|
+
for (const args of target.invocations) results.push(await color(target.command, args, ctx));
|
|
858
918
|
return results;
|
|
859
919
|
}
|
|
860
920
|
};
|
|
@@ -945,6 +1005,37 @@ function expandFixture(args, dir) {
|
|
|
945
1005
|
function collapseFixture(text, fixture) {
|
|
946
1006
|
return text.replaceAll(fixture.realDir, FIXTURE_PLACEHOLDER).replaceAll(fixture.dir, FIXTURE_PLACEHOLDER);
|
|
947
1007
|
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Removes the hostile names' dangerous parts from output, for checks other than
|
|
1010
|
+
* control-chars: a lister that prints them raw into a pipe is doing its job, and
|
|
1011
|
+
* control-chars judges how they reach a terminal.
|
|
1012
|
+
*/
|
|
1013
|
+
function withoutHostileNames(text) {
|
|
1014
|
+
let out = text;
|
|
1015
|
+
for (const { marker } of HOSTILE_NAMES) out = out.replaceAll(marker, "");
|
|
1016
|
+
return out;
|
|
1017
|
+
}
|
|
1018
|
+
function collapseValue(value, fixture) {
|
|
1019
|
+
if (typeof value === "string") return collapseFixture(value, fixture);
|
|
1020
|
+
if (Array.isArray(value)) return value.map((v) => collapseValue(v, fixture));
|
|
1021
|
+
if (value && typeof value === "object" && !Buffer.isBuffer(value)) return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, collapseValue(v, fixture)]));
|
|
1022
|
+
return value;
|
|
1023
|
+
}
|
|
1024
|
+
/** collapseFixture applied to every string in the results: invocation, reason, evidence and data. */
|
|
1025
|
+
function collapseResults(results, fixture) {
|
|
1026
|
+
return results.map((r) => {
|
|
1027
|
+
const data = Object.fromEntries(Object.entries(r).map(([k, v]) => [k, collapseValue(v, fixture)]));
|
|
1028
|
+
const c = (text) => collapseFixture(text, fixture);
|
|
1029
|
+
return {
|
|
1030
|
+
...data,
|
|
1031
|
+
check: r.check,
|
|
1032
|
+
invocation: r.invocation.map(c),
|
|
1033
|
+
verdict: r.verdict,
|
|
1034
|
+
reason: c(r.reason),
|
|
1035
|
+
...r.evidence === void 0 ? {} : { evidence: c(r.evidence) }
|
|
1036
|
+
};
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
948
1039
|
// src/checks/control-chars.ts
|
|
949
1040
|
const ENV$1 = {
|
|
950
1041
|
TERM: "xterm-256color",
|
|
@@ -969,17 +1060,13 @@ function judgeControlChars(runs) {
|
|
|
969
1060
|
verdict: "error",
|
|
970
1061
|
reason: `could not start: ${pipe.spawnError}`
|
|
971
1062
|
};
|
|
972
|
-
if (pipe?.timedOut) return {
|
|
973
|
-
verdict: "error",
|
|
974
|
-
reason: "timed out on a normal run"
|
|
975
|
-
};
|
|
976
1063
|
if (!tty) return {
|
|
977
1064
|
verdict: "skip",
|
|
978
1065
|
reason: `no terminal to check with (${runs.noPty ?? "no PTY"})`
|
|
979
1066
|
};
|
|
980
|
-
if (tty.timedOut) return {
|
|
1067
|
+
if (tty.timedOut && !tty.output.includes("plain.txt")) return {
|
|
981
1068
|
verdict: "skip",
|
|
982
|
-
reason: "
|
|
1069
|
+
reason: "still running in a terminal at the timeout, and had not printed the file names in {fixture}"
|
|
983
1070
|
};
|
|
984
1071
|
if (!tty.output.includes("plain.txt")) return {
|
|
985
1072
|
verdict: "skip",
|
|
@@ -1004,17 +1091,18 @@ function judgeControlChars(runs) {
|
|
|
1004
1091
|
reason: `escaped control characters in file names${noted.length ? `; printed ${listLabels$2(noted)} as is` : ""}`
|
|
1005
1092
|
};
|
|
1006
1093
|
}
|
|
1007
|
-
async function controlCharsRuns(command, args, fixtureDir,
|
|
1094
|
+
async function controlCharsRuns(command, args, fixtureDir, ctx) {
|
|
1008
1095
|
const usesFixture = fixtureDir !== void 0 && args.some((a) => a.includes(fixtureDir));
|
|
1009
1096
|
if (!usesFixture) return { usesFixture };
|
|
1010
1097
|
const pipe = await run$1(command, args, {
|
|
1011
|
-
timeout,
|
|
1098
|
+
timeout: probeTimeout(ctx, command, args),
|
|
1012
1099
|
env: ENV$1
|
|
1013
1100
|
});
|
|
1014
|
-
if (pipe.spawnError
|
|
1101
|
+
if (pipe.spawnError) return {
|
|
1015
1102
|
usesFixture,
|
|
1016
1103
|
pipe
|
|
1017
1104
|
};
|
|
1105
|
+
if (pipe.timedOut) markLongRunning(ctx, command, args);
|
|
1018
1106
|
const support = ptySupport();
|
|
1019
1107
|
if (!support.ok) return {
|
|
1020
1108
|
usesFixture,
|
|
@@ -1025,14 +1113,14 @@ async function controlCharsRuns(command, args, fixtureDir, timeout) {
|
|
|
1025
1113
|
usesFixture,
|
|
1026
1114
|
pipe,
|
|
1027
1115
|
tty: await runPty(command, args, {
|
|
1028
|
-
timeout,
|
|
1116
|
+
timeout: probeTimeout(ctx, command, args),
|
|
1029
1117
|
env: ENV$1
|
|
1030
1118
|
})
|
|
1031
1119
|
};
|
|
1032
1120
|
}
|
|
1033
1121
|
const kinds = (output) => output === void 0 ? [] : rawNames(output).map((h) => h.kind);
|
|
1034
|
-
async function controlChars(command, args, fixtureDir,
|
|
1035
|
-
const runs = await controlCharsRuns(command, args, fixtureDir,
|
|
1122
|
+
async function controlChars(command, args, fixtureDir, ctx) {
|
|
1123
|
+
const runs = await controlCharsRuns(command, args, fixtureDir, ctx);
|
|
1036
1124
|
const pipeOutput = runs.pipe && runs.pipe.stdout.toString("utf8") + runs.pipe.stderr;
|
|
1037
1125
|
return {
|
|
1038
1126
|
check: "control-chars",
|
|
@@ -1055,7 +1143,7 @@ const controlCharsCheck = {
|
|
|
1055
1143
|
pipeRaw: []
|
|
1056
1144
|
}];
|
|
1057
1145
|
const results = [];
|
|
1058
|
-
for (const args of target.invocations) results.push(await controlChars(target.command, args, target.fixtureDir, ctx
|
|
1146
|
+
for (const args of target.invocations) results.push(await controlChars(target.command, args, target.fixtureDir, ctx));
|
|
1059
1147
|
return results;
|
|
1060
1148
|
}
|
|
1061
1149
|
};
|
|
@@ -1132,7 +1220,7 @@ const ctrlCCheck = {
|
|
|
1132
1220
|
check: "ctrl-c",
|
|
1133
1221
|
invocation: [target.command],
|
|
1134
1222
|
verdict: "skip",
|
|
1135
|
-
reason: "needs probe args that keep it running, such as a watch or serve command",
|
|
1223
|
+
reason: "needs probe args that keep it running, such as a watch or serve command, or --bare",
|
|
1136
1224
|
sentAfterMs: null,
|
|
1137
1225
|
exitedAfterMs: null,
|
|
1138
1226
|
exitCode: null,
|
|
@@ -1160,10 +1248,6 @@ function judgePipeEscapes(r) {
|
|
|
1160
1248
|
verdict: "error",
|
|
1161
1249
|
reason: `could not start: ${r.spawnError}`
|
|
1162
1250
|
};
|
|
1163
|
-
if (r.timedOut) return {
|
|
1164
|
-
verdict: "error",
|
|
1165
|
-
reason: "timed out on a normal run"
|
|
1166
|
-
};
|
|
1167
1251
|
const stdout = r.stdout.toString("utf8");
|
|
1168
1252
|
const outHits = findControls(stdout);
|
|
1169
1253
|
const errHits = findControls(r.stderr);
|
|
@@ -1179,20 +1263,33 @@ function judgePipeEscapes(r) {
|
|
|
1179
1263
|
reason: `printed terminal control codes into a pipe: ${listLabels$1([.../* @__PURE__ */ new Set([...kindsOf(outHits), ...kindsOf(errHits)])])}`,
|
|
1180
1264
|
evidence: `${first.stream} line ${first.hit.line}: ${first.hit.text}`
|
|
1181
1265
|
};
|
|
1182
|
-
if (!stdout && !r.stderr) return {
|
|
1266
|
+
if (!stdout && !r.stderr) return r.timedOut ? {
|
|
1267
|
+
verdict: "skip",
|
|
1268
|
+
reason: `${stillRunning(r.durationMs)} and printed nothing so far`
|
|
1269
|
+
} : {
|
|
1183
1270
|
verdict: "skip",
|
|
1184
1271
|
reason: "printed nothing, so there is nothing to check"
|
|
1185
1272
|
};
|
|
1273
|
+
if (r.timedOut) return {
|
|
1274
|
+
verdict: "pass",
|
|
1275
|
+
reason: `no cursor, erase, hyperlink, title or redraw codes in a pipe (${stillRunning(r.durationMs)})`
|
|
1276
|
+
};
|
|
1186
1277
|
return {
|
|
1187
1278
|
verdict: "pass",
|
|
1188
1279
|
reason: "no cursor, erase, hyperlink, title or redraw codes in a pipe"
|
|
1189
1280
|
};
|
|
1190
1281
|
}
|
|
1191
|
-
async function pipeEscapes(command, args,
|
|
1192
|
-
const
|
|
1193
|
-
timeout,
|
|
1282
|
+
async function pipeEscapes(command, args, ctx, fixture = false) {
|
|
1283
|
+
const raw = await run$1(command, args, {
|
|
1284
|
+
timeout: probeTimeout(ctx, command, args),
|
|
1194
1285
|
env: ENV
|
|
1195
1286
|
});
|
|
1287
|
+
if (raw.timedOut) markLongRunning(ctx, command, args);
|
|
1288
|
+
const r = fixture ? {
|
|
1289
|
+
...raw,
|
|
1290
|
+
stdout: Buffer.from(withoutHostileNames(raw.stdout.toString("utf8"))),
|
|
1291
|
+
stderr: withoutHostileNames(raw.stderr)
|
|
1292
|
+
} : raw;
|
|
1196
1293
|
return {
|
|
1197
1294
|
check: "pipe-escapes",
|
|
1198
1295
|
invocation: [command, ...args],
|
|
@@ -1207,7 +1304,7 @@ const pipeEscapesCheck = {
|
|
|
1207
1304
|
summary: "prints spinners, cursor codes, hyperlinks or titles into a pipe",
|
|
1208
1305
|
async run(target, ctx) {
|
|
1209
1306
|
const results = [];
|
|
1210
|
-
for (const args of target.invocations) results.push(await pipeEscapes(target.command, args, ctx.
|
|
1307
|
+
for (const args of target.invocations) results.push(await pipeEscapes(target.command, args, ctx, target.fixtureDir !== void 0));
|
|
1211
1308
|
return results;
|
|
1212
1309
|
}
|
|
1213
1310
|
};
|
|
@@ -1439,7 +1536,8 @@ function judgeStdin(runs, defaultProbe) {
|
|
|
1439
1536
|
}
|
|
1440
1537
|
async function stdinRuns(command, args, timeout) {
|
|
1441
1538
|
const closed = await run$1(command, args, { timeout });
|
|
1442
|
-
if (closed.
|
|
1539
|
+
if (closed.timedOut) return { closed };
|
|
1540
|
+
if (closed.spawnError) return { closed };
|
|
1443
1541
|
const open = await run$1(command, args, {
|
|
1444
1542
|
timeout: STDIN_WAIT_MS,
|
|
1445
1543
|
stdin: "open"
|
|
@@ -1457,8 +1555,18 @@ async function stdinRuns(command, args, timeout) {
|
|
|
1457
1555
|
})
|
|
1458
1556
|
};
|
|
1459
1557
|
}
|
|
1460
|
-
async function stdinCheck(command, args, defaultProbe,
|
|
1461
|
-
|
|
1558
|
+
async function stdinCheck(command, args, defaultProbe, ctx) {
|
|
1559
|
+
if (isLongRunning(ctx, command, args)) return {
|
|
1560
|
+
check: "stdin",
|
|
1561
|
+
invocation: [command, ...args],
|
|
1562
|
+
verdict: "skip",
|
|
1563
|
+
reason: "keeps running even with stdin closed, so stdin isn't what it waits for",
|
|
1564
|
+
closedMs: null,
|
|
1565
|
+
waitedForStdin: false,
|
|
1566
|
+
finishedAfterCloseMs: null
|
|
1567
|
+
};
|
|
1568
|
+
const runs = await stdinRuns(command, args, ctx.timeout);
|
|
1569
|
+
if (runs.closed.timedOut) markLongRunning(ctx, command, args);
|
|
1462
1570
|
const proven = runs.open?.timedOut === true && runs.closing !== void 0 && !runs.closing.timedOut;
|
|
1463
1571
|
return {
|
|
1464
1572
|
check: "stdin",
|
|
@@ -1481,7 +1589,7 @@ const CHECKS = [
|
|
|
1481
1589
|
summary: "waits for stdin when it is an open pipe, as agents and CI runners leave it",
|
|
1482
1590
|
async run(target, ctx) {
|
|
1483
1591
|
const results = [];
|
|
1484
|
-
for (const args of target.invocations) results.push(await stdinCheck(target.command, args, !target.explicit, ctx
|
|
1592
|
+
for (const args of target.invocations) results.push(await stdinCheck(target.command, args, !target.explicit, ctx));
|
|
1485
1593
|
return results;
|
|
1486
1594
|
}
|
|
1487
1595
|
},
|
|
@@ -1528,6 +1636,18 @@ function safe(text) {
|
|
|
1528
1636
|
function safeJson(value) {
|
|
1529
1637
|
return JSON.stringify(value, null, 2).replace(JSON_UNSAFE, (c) => `\\u${hex(c, 4)}`);
|
|
1530
1638
|
}
|
|
1639
|
+
// src/core/quote.ts
|
|
1640
|
+
/** Characters a POSIX shell takes literally in a word; `{fixture}` stays readable. */
|
|
1641
|
+
const PLAIN = /^[\w@%+=:,./{}-]+$/;
|
|
1642
|
+
/**
|
|
1643
|
+
* Joins a command and its arguments the way you would type them in a shell,
|
|
1644
|
+
* single-quoting any argument with spaces, quotes or other special characters,
|
|
1645
|
+
* so `python3 -c 'import time; time.sleep(30)'` doesn't read as five words.
|
|
1646
|
+
* Only for display: cliprobe never runs a shell.
|
|
1647
|
+
*/
|
|
1648
|
+
function shellJoin(args) {
|
|
1649
|
+
return args.map((a) => PLAIN.test(a) ? a : `'${a.replaceAll("'", `'\\''`)}'`).join(" ");
|
|
1650
|
+
}
|
|
1531
1651
|
// src/report/summary.ts
|
|
1532
1652
|
function countVerdicts(results) {
|
|
1533
1653
|
const counts = {
|
|
@@ -1561,14 +1681,14 @@ function formatHuman({ version, command, checks, results }, { color }) {
|
|
|
1561
1681
|
const label = verdict.toUpperCase().padEnd(5);
|
|
1562
1682
|
return color ? `\x1b[${COLORS[verdict]}m${label}\x1b[0m` : label;
|
|
1563
1683
|
};
|
|
1564
|
-
const width = Math.max(0, ...results.map((r) => safe(r.invocation
|
|
1684
|
+
const width = Math.max(0, ...results.map((r) => safe(shellJoin(r.invocation)).length));
|
|
1565
1685
|
const noun = checks.length === 1 ? "check" : "checks";
|
|
1566
1686
|
const lines = [`cliprobe ${version}: ${checks.join(", ")} ${noun} for ${safe(command)}`];
|
|
1567
1687
|
for (const check of checks) {
|
|
1568
1688
|
lines.push("");
|
|
1569
1689
|
if (checks.length > 1) lines.push(check);
|
|
1570
1690
|
for (const r of results.filter((result) => result.check === check)) {
|
|
1571
|
-
lines.push(` ${paint(r.verdict)} ${safe(r.invocation
|
|
1691
|
+
lines.push(` ${paint(r.verdict)} ${safe(shellJoin(r.invocation)).padEnd(width)} ${r.reason}`);
|
|
1572
1692
|
if (r.evidence) lines.push(` ${" ".repeat(5)} ${" ".repeat(width)} ${safe(r.evidence).slice(0, 200)}`);
|
|
1573
1693
|
}
|
|
1574
1694
|
}
|
|
@@ -1607,7 +1727,7 @@ function totals(results) {
|
|
|
1607
1727
|
return `tests="${results.length}" failures="${c.fail}" errors="${c.error}" skipped="${c.skip}"`;
|
|
1608
1728
|
}
|
|
1609
1729
|
function testcase(r) {
|
|
1610
|
-
const open = ` <testcase classname="cliprobe.${xml(r.check)}" name="${xml(r.invocation
|
|
1730
|
+
const open = ` <testcase classname="cliprobe.${xml(r.check)}" name="${xml(shellJoin(r.invocation))}"`;
|
|
1611
1731
|
const message = `message="${xml(r.reason)}"`;
|
|
1612
1732
|
const body = r.evidence ? xml(r.evidence) : "";
|
|
1613
1733
|
switch (r.verdict) {
|
|
@@ -1664,7 +1784,7 @@ function row(r) {
|
|
|
1664
1784
|
return `| ${[
|
|
1665
1785
|
prose(r.check),
|
|
1666
1786
|
verdict,
|
|
1667
|
-
code(r.invocation
|
|
1787
|
+
code(shellJoin(r.invocation), { inTable: true }),
|
|
1668
1788
|
prose(r.reason) + evidence
|
|
1669
1789
|
].join(" | ")} |`;
|
|
1670
1790
|
}
|
|
@@ -1734,6 +1854,7 @@ function parseArgs(argv) {
|
|
|
1734
1854
|
format: "human",
|
|
1735
1855
|
outputFile: void 0,
|
|
1736
1856
|
timeout: 15e3,
|
|
1857
|
+
bare: false,
|
|
1737
1858
|
help: false,
|
|
1738
1859
|
version: false,
|
|
1739
1860
|
checks: [],
|
|
@@ -1747,6 +1868,7 @@ function parseArgs(argv) {
|
|
|
1747
1868
|
break;
|
|
1748
1869
|
}
|
|
1749
1870
|
if (a === "--json") opts.format = "json";
|
|
1871
|
+
else if (a === "--bare") opts.bare = true;
|
|
1750
1872
|
else if (a === "-o" || a === "--output-file" || a.startsWith("--output-file=")) {
|
|
1751
1873
|
const value = a.includes("=") ? a.slice(a.indexOf("=") + 1) : argv[++i];
|
|
1752
1874
|
if (!value) throw new UsageError(`${a.split("=")[0] ?? a} needs a file path`);
|
|
@@ -1771,6 +1893,7 @@ function parseArgs(argv) {
|
|
|
1771
1893
|
break;
|
|
1772
1894
|
}
|
|
1773
1895
|
}
|
|
1896
|
+
if (opts.bare && opts.args.length) throw new UsageError("--bare probes the command with no arguments, so give none after it");
|
|
1774
1897
|
return opts;
|
|
1775
1898
|
}
|
|
1776
1899
|
// src/cli/help.ts
|
|
@@ -1780,9 +1903,10 @@ Usage:
|
|
|
1780
1903
|
cliprobe [options] -- <command> [args...]
|
|
1781
1904
|
|
|
1782
1905
|
With no args after <command>, cliprobe probes "<command> --version" and
|
|
1783
|
-
"<command> --help". With args, it probes exactly that invocation
|
|
1784
|
-
containing {fixture} gets the path of a
|
|
1785
|
-
control characters in them, for the
|
|
1906
|
+
"<command> --help". With args, it probes exactly that invocation; with --bare,
|
|
1907
|
+
the command alone. An argument containing {fixture} gets the path of a
|
|
1908
|
+
temporary directory of file names with control characters in them, for the
|
|
1909
|
+
control-chars check.
|
|
1786
1910
|
|
|
1787
1911
|
Checks:
|
|
1788
1912
|
closed-pipe Runs the command with stdout already closed, as when output is
|
|
@@ -1823,6 +1947,8 @@ Info checks (never fail; run only when named with --check):
|
|
|
1823
1947
|
flags runs its default action, cut off after 5 s.
|
|
1824
1948
|
|
|
1825
1949
|
Options:
|
|
1950
|
+
--bare Probe the command with no arguments (a REPL, a full-screen
|
|
1951
|
+
program, a server) instead of --version and --help
|
|
1826
1952
|
--check <name> Run only this check; repeat it or use commas for several
|
|
1827
1953
|
--format <name> Output format: human (default), json, markdown (a CI job
|
|
1828
1954
|
summary or PR comment) or junit (XML for CI test reports)
|
|
@@ -1830,13 +1956,16 @@ Options:
|
|
|
1830
1956
|
-o, --output-file <path>
|
|
1831
1957
|
Write the --format report to a file (created atomically,
|
|
1832
1958
|
with parent folders); the human report still prints
|
|
1833
|
-
--timeout <ms> Kill a probe after this long (default 15000)
|
|
1959
|
+
--timeout <ms> Kill a probe after this long (default 15000). A command
|
|
1960
|
+
still running then (a server, a watcher) is judged on
|
|
1961
|
+
what it did so far, and later checks watch it for 3 s
|
|
1834
1962
|
-h, --help Show this help
|
|
1835
1963
|
-v, --version Show the version
|
|
1836
1964
|
|
|
1837
1965
|
Exit codes: 0 no failures, 1 a check failed, 2 usage error or could not run.
|
|
1838
|
-
Runs the target in the current directory without a shell, with stdin closed
|
|
1839
|
-
|
|
1966
|
+
Runs the target in the current directory without a shell, with stdin closed
|
|
1967
|
+
(the stdin check uses a pipe it never writes to), a temporary HOME and a
|
|
1968
|
+
minimal environment. Only run programs you trust.`;
|
|
1840
1969
|
// src/cli/program.ts
|
|
1841
1970
|
/** 0 no failures, 1 a check failed, 2 nothing could be judged because something could not run. */
|
|
1842
1971
|
function exitCodeFor(results) {
|
|
@@ -1878,38 +2007,45 @@ async function run(argv, io) {
|
|
|
1878
2007
|
err("cliprobe: Windows is not supported yet (the closed-pipe check needs mkfifo).\n");
|
|
1879
2008
|
return 2;
|
|
1880
2009
|
}
|
|
1881
|
-
|
|
2010
|
+
if (findCommand(opts.command) === void 0) {
|
|
2011
|
+
err(`cliprobe: command not found: ${safe(opts.command)}\n`);
|
|
2012
|
+
return 2;
|
|
2013
|
+
}
|
|
2014
|
+
const invocations = opts.bare ? [[]] : opts.args.length ? [opts.args] : [["--version"], ["--help"]];
|
|
1882
2015
|
const fixture = usesFixture(opts.args) ? createFixture() : void 0;
|
|
1883
2016
|
const results = [];
|
|
1884
2017
|
try {
|
|
1885
2018
|
const target = {
|
|
1886
2019
|
command: opts.command,
|
|
1887
|
-
explicit: opts.args.length > 0,
|
|
2020
|
+
explicit: opts.bare || opts.args.length > 0,
|
|
1888
2021
|
invocations: fixture ? invocations.map((a) => expandFixture(a, fixture.dir)) : invocations,
|
|
1889
2022
|
...fixture ? { fixtureDir: fixture.dir } : {}
|
|
1890
2023
|
};
|
|
1891
|
-
|
|
2024
|
+
const ctx = {
|
|
2025
|
+
timeout: opts.timeout,
|
|
2026
|
+
longRunning: /* @__PURE__ */ new Set()
|
|
2027
|
+
};
|
|
2028
|
+
for (const check of checks) results.push(...await check.run(target, ctx));
|
|
1892
2029
|
} finally {
|
|
1893
2030
|
fixture?.cleanup();
|
|
1894
2031
|
}
|
|
1895
|
-
const collapse = (text) => fixture ? collapseFixture(text, fixture) : text;
|
|
1896
2032
|
const report = {
|
|
1897
2033
|
version: VERSION,
|
|
1898
2034
|
command: opts.command,
|
|
1899
2035
|
checks: checks.map((c) => c.name),
|
|
1900
|
-
results
|
|
2036
|
+
results: fixture ? collapseResults(results, fixture) : results
|
|
1901
2037
|
};
|
|
1902
2038
|
const { color } = io;
|
|
1903
2039
|
if (opts.outputFile) {
|
|
1904
2040
|
try {
|
|
1905
|
-
writeReportFile(opts.outputFile,
|
|
2041
|
+
writeReportFile(opts.outputFile, FORMATS[opts.format](report, { color: false }));
|
|
1906
2042
|
} catch (error) {
|
|
1907
2043
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1908
2044
|
err(`cliprobe: could not write ${safe(opts.outputFile)}: ${safe(reason)}\n`);
|
|
1909
2045
|
return 2;
|
|
1910
2046
|
}
|
|
1911
|
-
out(
|
|
1912
|
-
} else out(
|
|
2047
|
+
out(FORMATS.human(report, { color }));
|
|
2048
|
+
} else out(FORMATS[opts.format](report, { color }));
|
|
1913
2049
|
return exitCodeFor(results);
|
|
1914
2050
|
}
|
|
1915
2051
|
// src/cli/main.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cliprobe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Black-box test any command-line program for terminal-edge bugs: crashes on a closed pipe (| head), color and control codes leaking into pipes, hangs waiting on stdin, broken Ctrl-C handling, a terminal left broken after Ctrl-C, and control characters from file names reaching your terminal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|