// Generated by ReScript, PLEASE EDIT WITH CARE

import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs";
import * as Nodechild_process from "node:child_process";

async function run(command, args, options) {
  let spawn = Nodechild_process.spawn(command, args, options !== undefined ? Primitive_option.valFromOption(options) : undefined);
  let stdout = [];
  let stderr = [];
  spawn.stdout.on("data", data => {
    stdout.push(data);
  });
  spawn.stderr.on("data", data => {
    stderr.push(data);
  });
  return await new Promise((resolve, reject) => {
    spawn.once("error", (param, param$1) => reject({
      stdout: stdout,
      stderr: stderr,
      code: 1.0
    }));
    spawn.once("close", (code, _signal) => resolve({
      stdout: stdout,
      stderr: stderr,
      code: code
    }));
  });
}

export {
  run,
}
/* node:child_process Not a pure module */
