@ubercode/dcmtk 0.10.0 → 0.10.1

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/index.cjs CHANGED
@@ -318,13 +318,14 @@ async function execCommand(binary, args, options) {
318
318
  windowsHide: true,
319
319
  signal: options?.signal
320
320
  });
321
- wireSpawnListeners(child, timeoutMs, resolve);
321
+ wireSpawnListeners(binary, child, timeoutMs, resolve);
322
322
  });
323
323
  }
324
- function wireSpawnListeners(child, timeoutMs, resolve) {
324
+ function wireSpawnListeners(binary, child, timeoutMs, resolve) {
325
325
  let stdout = "";
326
326
  let stderr8 = "";
327
327
  let settled = false;
328
+ const name = binary.split("/").pop() ?? binary;
328
329
  const settle = (result) => {
329
330
  if (settled) return;
330
331
  settled = true;
@@ -333,25 +334,25 @@ function wireSpawnListeners(child, timeoutMs, resolve) {
333
334
  };
334
335
  const timer = setTimeout(() => {
335
336
  if (child.pid !== void 0 && child.pid !== null) killTree(child.pid);
336
- settle(err(new Error(`Process timed out after ${timeoutMs}ms`)));
337
+ settle(err(new Error(`${name} timed out after ${timeoutMs}ms (pid: ${String(child.pid ?? "unknown")})`)));
337
338
  }, timeoutMs);
338
339
  child.stdout?.on("data", (chunk) => {
339
340
  stdout += String(chunk);
340
341
  if (stdout.length + stderr8.length > MAX_OUTPUT_BYTES) {
341
342
  if (child.pid !== void 0 && child.pid !== null) killTree(child.pid);
342
- settle(err(new Error(`Process output exceeded ${MAX_OUTPUT_BYTES} bytes`)));
343
+ settle(err(new Error(`${name} output exceeded ${MAX_OUTPUT_BYTES} bytes`)));
343
344
  }
344
345
  });
345
346
  child.stderr?.on("data", (chunk) => {
346
347
  stderr8 += String(chunk);
347
348
  if (stdout.length + stderr8.length > MAX_OUTPUT_BYTES) {
348
349
  if (child.pid !== void 0 && child.pid !== null) killTree(child.pid);
349
- settle(err(new Error(`Process output exceeded ${MAX_OUTPUT_BYTES} bytes`)));
350
+ settle(err(new Error(`${name} output exceeded ${MAX_OUTPUT_BYTES} bytes`)));
350
351
  }
351
352
  });
352
353
  child.on("error", (error) => {
353
354
  if (child.pid !== void 0 && child.pid !== null) killTree(child.pid);
354
- settle(err(new Error(`Process error: ${error.message}`)));
355
+ settle(err(new Error(`${name} error: ${error.message}`)));
355
356
  });
356
357
  child.on("close", (code) => {
357
358
  settle(ok({ stdout, stderr: stderr8, exitCode: code ?? 1 }));
@@ -366,7 +367,7 @@ async function spawnCommand(binary, args, options) {
366
367
  windowsHide: true,
367
368
  signal: options?.signal
368
369
  });
369
- wireSpawnListeners(child, timeoutMs, resolve);
370
+ wireSpawnListeners(binary, child, timeoutMs, resolve);
370
371
  });
371
372
  }
372
373
  var ProcessState = {