@ubercode/dcmtk 0.8.2 → 0.9.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/servers.cjs CHANGED
@@ -2308,13 +2308,26 @@ async function tryDirectPath(inputPath, timeoutMs, signal, verbosity) {
2308
2308
  if (!jsonBinary.ok) {
2309
2309
  return err(jsonBinary.error);
2310
2310
  }
2311
- const directArgs = [...buildVerbosityArgs(verbosity), "+b", inputPath];
2312
- const result = await execCommand(jsonBinary.value, directArgs, { timeoutMs, signal });
2311
+ const bulkDir = await createBulkTempDir();
2312
+ const directArgs = [...buildVerbosityArgs(verbosity), "+b", "+bd", bulkDir, inputPath];
2313
+ try {
2314
+ const execOpts = signal !== void 0 ? { timeoutMs, signal } : { timeoutMs };
2315
+ return await execAndParse(jsonBinary.value, directArgs, inputPath, execOpts);
2316
+ } finally {
2317
+ fs.rm(bulkDir, { recursive: true, force: true }).catch(() => {
2318
+ });
2319
+ }
2320
+ }
2321
+ async function createBulkTempDir() {
2322
+ return fs.mkdtemp(path.join(os.tmpdir(), "dcm2json-bulk-"));
2323
+ }
2324
+ async function execAndParse(binary, args, inputPath, execOpts) {
2325
+ const result = await execCommand(binary, args, execOpts);
2313
2326
  if (!result.ok) {
2314
2327
  return err(result.error);
2315
2328
  }
2316
2329
  if (result.value.exitCode !== 0) {
2317
- return err(createToolError("dcm2json", directArgs, result.value.exitCode, result.value.stderr));
2330
+ return err(createToolError("dcm2json", args, result.value.exitCode, result.value.stderr));
2318
2331
  }
2319
2332
  try {
2320
2333
  const repaired = repairJson(result.value.stdout);