@ubercode/dcmtk 0.8.2 → 0.9.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/dicom.cjs CHANGED
@@ -5,9 +5,10 @@ var stderrLib = require('stderr-lib');
5
5
  var child_process = require('child_process');
6
6
  var kill = require('tree-kill');
7
7
  var fs = require('fs');
8
+ var promises = require('fs/promises');
9
+ var os = require('os');
8
10
  var zod = require('zod');
9
11
  var fastXmlParser = require('fast-xml-parser');
10
- var promises = require('fs/promises');
11
12
 
12
13
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
14
 
@@ -30825,13 +30826,26 @@ async function tryDirectPath(inputPath, timeoutMs, signal, verbosity) {
30825
30826
  if (!jsonBinary.ok) {
30826
30827
  return err(jsonBinary.error);
30827
30828
  }
30828
- const directArgs = [...buildVerbosityArgs(verbosity), "+b", inputPath];
30829
- const result = await execCommand(jsonBinary.value, directArgs, { timeoutMs, signal });
30829
+ const bulkDir = await createBulkTempDir();
30830
+ const directArgs = [...buildVerbosityArgs(verbosity), "+b", "+bd", bulkDir, inputPath];
30831
+ try {
30832
+ const execOpts = signal !== void 0 ? { timeoutMs, signal } : { timeoutMs };
30833
+ return await execAndParse(jsonBinary.value, directArgs, inputPath, execOpts);
30834
+ } finally {
30835
+ promises.rm(bulkDir, { recursive: true, force: true }).catch(() => {
30836
+ });
30837
+ }
30838
+ }
30839
+ async function createBulkTempDir() {
30840
+ return promises.mkdtemp(path.join(os.tmpdir(), "dcm2json-bulk-"));
30841
+ }
30842
+ async function execAndParse(binary, args, inputPath, execOpts) {
30843
+ const result = await execCommand(binary, args, execOpts);
30830
30844
  if (!result.ok) {
30831
30845
  return err(result.error);
30832
30846
  }
30833
30847
  if (result.value.exitCode !== 0) {
30834
- return err(createToolError("dcm2json", directArgs, result.value.exitCode, result.value.stderr));
30848
+ return err(createToolError("dcm2json", args, result.value.exitCode, result.value.stderr));
30835
30849
  }
30836
30850
  try {
30837
30851
  const repaired = repairJson(result.value.stdout);