import { shCapture } from "https://deno.land/x/drake@v1.7.0/lib/utils.ts";
Execute command
in the command shell and return a promise for
{code, output, error}
(the exit code, the stdout output and the
stderr output).
- If the
opts.input
string has been assigned then it is piped to the shellstdin
. 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. opts.stdout
andopts.stderr
haveDeno.CommandOptions.stdout
andDeno.CommandOptions.stdout
semantics respectively.opts.stdout
defaults to"piped"
.opts.stderr
defaults to"inherit"
(to capture stderr setopts.stderr
to"piped"
).
Examples:
const { code, output } = await shCapture("echo Hello");
const { code, output, error } = await shCapture( "mkdir tmpdir", { stderr: "piped" });
const vers = (await shCapture("make version")).output.trim();
Parameters
optional
opts: ShCaptureOpts = [UNSUPPORTED]