Skip to main content
Module

x/drake/mod.ts>shCapture

Drake is a make-like task runner for Deno.
Go to Latest
function shCapture
import { shCapture } from "https://deno.land/x/drake@v1.6.0/mod.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 shell stdin.
  • 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 and opts.stderr have Deno.RunOptions semantics. opts.stdout defaults to "piped". opts.stderr defaults to "inherit" (to capture stderr set opts.stderr to "piped").

Examples:

const { code, stdout } = await shCapture("echo Hello");
const { code, output, error } = await shCapture( "mkdir tmpdir", { stderr: "piped" });

Parameters

command: string
optional
opts: ShCaptureOpts = [UNSUPPORTED]