@kud/cli-shot 0.1.1 → 0.1.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.
@@ -10,6 +10,7 @@ import { execFileSync } from 'child_process';
10
10
  // src/index.ts
11
11
  var { Terminal } = headless;
12
12
  var TICK_MS = 60;
13
+ var HELPER_FAILURE = /execvp\(\d\) failed|posix_spawnp failed/;
13
14
  var explainSpawnFailure = (error, command) => {
14
15
  const message = error instanceof Error ? error.message : String(error);
15
16
  const helper = helperPath();
@@ -62,6 +63,7 @@ var capture = (command, args = [], {
62
63
  return;
63
64
  }
64
65
  let raw = 0;
66
+ let rawText = "";
65
67
  let sentKeys = false;
66
68
  let finished = false;
67
69
  let previous = "";
@@ -106,16 +108,17 @@ var capture = (command, args = [], {
106
108
  const hard = setTimeout(finish, timeout);
107
109
  pty.onData((data) => {
108
110
  raw += data.length;
111
+ if (rawText.length < 2048) rawText += data;
109
112
  term.write(data);
110
113
  });
111
114
  pty.onExit(({ exitCode }) => {
112
- if (exitCode !== 0 && raw === 0) {
115
+ if (exitCode !== 0 && (raw === 0 || HELPER_FAILURE.test(rawText))) {
113
116
  finished = true;
114
117
  clearInterval(poll);
115
118
  clearTimeout(hard);
116
119
  reject(
117
120
  explainSpawnFailure(
118
- new Error(`exited ${exitCode} without drawing anything`),
121
+ new Error(`the command exited ${exitCode} without drawing a screen`),
119
122
  command
120
123
  )
121
124
  );
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { DEFAULT_FONT, listScreens, shootScreen, shootAll } from './chunk-ZWMKVITE.js';
2
+ import { DEFAULT_FONT, listScreens, shootScreen, shootAll } from './chunk-RT6Y4NTY.js';
3
3
  import { Command } from 'commander';
4
4
 
5
5
  var separator = process.argv.indexOf("--");
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { DEFAULT_FONT, capture, listScreens, shootAll, shootScreen, toImage } from './chunk-ZWMKVITE.js';
1
+ export { DEFAULT_FONT, capture, listScreens, shootAll, shootScreen, toImage } from './chunk-RT6Y4NTY.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kud/cli-shot",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "description": "Automatic screenshots of interactive CLIs — pty capture, terminal emulation, PNG out",
6
6
  "license": "MIT",