@ubercode/dcmtk 0.10.0 → 0.11.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/dist/tools.cjs CHANGED
@@ -46,13 +46,14 @@ async function execCommand(binary, args, options) {
46
46
  windowsHide: true,
47
47
  signal: options?.signal
48
48
  });
49
- wireSpawnListeners(child, timeoutMs, resolve);
49
+ wireSpawnListeners(binary, child, timeoutMs, resolve);
50
50
  });
51
51
  }
52
- function wireSpawnListeners(child, timeoutMs, resolve) {
52
+ function wireSpawnListeners(binary, child, timeoutMs, resolve) {
53
53
  let stdout = "";
54
54
  let stderr3 = "";
55
55
  let settled = false;
56
+ const name = binary.split("/").pop() ?? binary;
56
57
  const settle = (result) => {
57
58
  if (settled) return;
58
59
  settled = true;
@@ -61,25 +62,25 @@ function wireSpawnListeners(child, timeoutMs, resolve) {
61
62
  };
62
63
  const timer = setTimeout(() => {
63
64
  if (child.pid !== void 0 && child.pid !== null) killTree(child.pid);
64
- settle(err(new Error(`Process timed out after ${timeoutMs}ms`)));
65
+ settle(err(new Error(`${name} timed out after ${timeoutMs}ms (pid: ${String(child.pid ?? "unknown")})`)));
65
66
  }, timeoutMs);
66
67
  child.stdout?.on("data", (chunk) => {
67
68
  stdout += String(chunk);
68
69
  if (stdout.length + stderr3.length > MAX_OUTPUT_BYTES) {
69
70
  if (child.pid !== void 0 && child.pid !== null) killTree(child.pid);
70
- settle(err(new Error(`Process output exceeded ${MAX_OUTPUT_BYTES} bytes`)));
71
+ settle(err(new Error(`${name} output exceeded ${MAX_OUTPUT_BYTES} bytes`)));
71
72
  }
72
73
  });
73
74
  child.stderr?.on("data", (chunk) => {
74
75
  stderr3 += String(chunk);
75
76
  if (stdout.length + stderr3.length > MAX_OUTPUT_BYTES) {
76
77
  if (child.pid !== void 0 && child.pid !== null) killTree(child.pid);
77
- settle(err(new Error(`Process output exceeded ${MAX_OUTPUT_BYTES} bytes`)));
78
+ settle(err(new Error(`${name} output exceeded ${MAX_OUTPUT_BYTES} bytes`)));
78
79
  }
79
80
  });
80
81
  child.on("error", (error) => {
81
82
  if (child.pid !== void 0 && child.pid !== null) killTree(child.pid);
82
- settle(err(new Error(`Process error: ${error.message}`)));
83
+ settle(err(new Error(`${name} error: ${error.message}`)));
83
84
  });
84
85
  child.on("close", (code) => {
85
86
  settle(ok({ stdout, stderr: stderr3, exitCode: code ?? 1 }));
@@ -94,7 +95,7 @@ async function spawnCommand(binary, args, options) {
94
95
  windowsHide: true,
95
96
  signal: options?.signal
96
97
  });
97
- wireSpawnListeners(child, timeoutMs, resolve);
98
+ wireSpawnListeners(binary, child, timeoutMs, resolve);
98
99
  });
99
100
  }
100
101