import { sh } from "https://deno.land/x/drake@v1.7.0/lib/utils.ts";
Execute commands asynchronously in the command shell.
- If
commands
is a string execute it. - If
commands
is an array of commands execute them asynchronously. - If any command fails throw an error.
- If
opts.stdout
oropts.stderr
is set to"null"
then the respective outputs are ignored. opts.cwd
sets the shell current working directory (defaults to the parent process working directory).- The
opts.env
mapping passes additional environment variables to the shell.
On MS Windows run PowerShell.exe -Command <cmd>
. On other platforms run $SHELL -c <cmd>
(if SHELL
is not defined use /bin/bash
).
Examples:
await sh("echo Hello World");
await sh(["echo Hello 1", "echo Hello 2", "echo Hello 3"]);
await sh("echo Hello World", { stdout: "null" });
Parameters
optional
opts: ShOpts = [UNSUPPORTED]