Skip to main content
Module

x/drake/mod.ts>shCapture

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

command: string
optional
opts: ShCaptureOpts = [UNSUPPORTED]