Resolved: Use Deno.run to extract a file with 7z

Question:

Trying to do a little script to automate some tasks. Chose deno as a nice self-contained way to do random automation tasks I need – and a learning opportunity.
One of the things I’m trying to do is extract an archive using 7z and I can’t figure out why it’s not working.
let cmdProcess = Deno.run({
    cmd: ["7z", "e ProcessExplorer.zip"],
    stdout: "piped",
    stderr: "piped"
})
const output = await cmdProcess.output()
const outStr = new TextDecoder().decode(output);
console.log(outStr)

const errout = await cmdProcess.stderrOutput()
const errStr = new TextDecoder().decode(errout);
console.log(errStr)
7z does run, according to the normal output. But I receive the following error no matter what parameters I try to pass to 7z:
Command Line Error:
Unsupported command:
x ProcessExplorer.zip
It doesn’t matter if I supply the full path or relative, or what command I give.
It’s possible that I’m supplying the wrong arguments to Deno.run, but I’ve been unable to google Deno.run() because most search result end up being for the deno run CLI command.
I am on Win 10 21H2.
deno v1.19.3

Answer:

It should work if you split the e subcommand from the argument ProcessExplorer.zip:
const cmdProcess = Deno.run({
  cmd: ["7z", "e", "ProcessExplorer.zip"],
  stdout: "piped",
  stderr: "piped",
});
With Deno.run you need to split all the different subcommands/options/flags of a command into separate strings in the cmd array, as is mentioned in this thread
For documentation on the Deno namespace API you can find it at https://doc.deno.land. For Deno.run specifically you can find it here.

If you have better answer, please add a comment about this, thank you!