deno-proc

Abstractions for running processes in Deno.

This is still very early. Things are going to change. A lot. Functionality is limited. The API is unstable.

Deno has all the right parts for working with processes, but I really want something that is a better version of what I get in bash scripts. I want stdin and stdout pipes, decent default error handling, and minimal need to manually close things. I want all this to work with a fluent API.

documentation

deno doc -q https://deno.land/x/proc/mod.ts

stdout from a process as lines

for await (const line of new Proc({ cmd: ["ls", "-la"] }).stdoutLines()) {
  console.log(line);
}

pipe stdout to stdin

const fileCount = await first(
  run({ cmd: ["ls", "-1"] })
    .pipe(run({ cmd: ["wc", "-l"] }))
    .stdoutLines(),
);

console.info(
  `Total number of files and folders in <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mrow><mi>r</mi><mi>e</mi><mi>s</mi><mi>o</mi><mi>l</mi><mi>v</mi><mi>e</mi><mo stretchy="false">(</mo><mi mathvariant="normal">&quot;</mi><mi mathvariant="normal">.</mi><mi mathvariant="normal">&quot;</mi><mo stretchy="false">)</mo></mrow><mi>i</mi><mi>s</mi></mrow><annotation encoding="application/x-tex">{resolve(&quot;.&quot;)} is </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">reso</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord mathnormal">e</span><span class="mopen">(</span><span class="mord">&quot;.&quot;</span><span class="mclose">)</span></span><span class="mord mathnormal">i</span><span class="mord mathnormal">s</span></span></span></span>{parseInt(fileCount!, 10)}.`,
);