Skip to main content Link Search Menu Expand Document (external link)

Command overview

Added in v1.0.0


Table of contents


combinators

env

Specify the environment variables that will be used when running this command.

Signature

export declare const env: {
  (environment: Record<string, string | undefined>): (self: Command) => Command
  (self: Command, environment: Record<string, string | undefined>): Command
}

Added in v1.0.0

feed

Feed a string to standard input (default encoding of UTF-8).

Signature

export declare const feed: { (input: string): (self: Command) => Command; (self: Command, input: string): Command }

Added in v1.0.0

flatten

Flatten this command to a non-empty array of standard commands.

  • For a StandardCommand, this simply returns a 1 element array
  • For a PipedCommand, all commands in the pipe will be extracted out into a array from left to right

Signature

export declare const flatten: (self: Command) => NonEmptyReadonlyArray<StandardCommand>

Added in v1.0.0

pipeTo

Pipe one command to another command from left to right.

Conceptually, the equivalent of piping one shell command to another:

command1 | command2

Signature

export declare const pipeTo: { (into: Command): (self: Command) => Command; (self: Command, into: Command): Command }

Added in v1.0.0

runInShell

Allows for specifying whether or not a Command should be run inside a shell.

Signature

export declare const runInShell: {
  (shell: string | boolean): (self: Command) => Command
  (self: Command, shell: string | boolean): Command
}

Added in v1.0.0

stderr

Specify the standard error stream for a command.

Signature

export declare const stderr: {
  (stderr: Command.Output): (self: Command) => Command
  (self: Command, stderr: Command.Output): Command
}

Added in v1.0.0

stdin

Specify the standard input stream for a command.

Signature

export declare const stdin: {
  (stdin: Command.Input): (self: Command) => Command
  (self: Command, stdin: Command.Input): Command
}

Added in v1.0.0

stdout

Specify the standard output stream for a command.

Signature

export declare const stdout: {
  (stdout: Command.Output): (self: Command) => Command
  (self: Command, stdout: Command.Output): Command
}

Added in v1.0.0

workingDirectory

Set the working directory that will be used when this command will be run.

For piped commands, the working directory of each command will be set to the specified working directory.

Signature

export declare const workingDirectory: {
  (cwd: string): (self: Command) => Command
  (self: Command, cwd: string): Command
}

Added in v1.0.0

constructors

make

Create a command with the specified process name and an optional list of arguments.

Signature

export declare const make: (command: string, ...args: Array<string>) => Command

Added in v1.0.0

execution

exitCode

Returns the exit code of the command after the process has completed execution.

Signature

export declare const exitCode: (
  self: Command
) => Effect<Brand.Branded<number, "ExitCode">, PlatformError, CommandExecutor>

Added in v1.0.0

lines

Runs the command returning the output as an array of lines with the specified encoding.

Signature

export declare const lines: (
  command: Command,
  encoding?: string
) => Effect<readonly string[], PlatformError, CommandExecutor>

Added in v1.0.0

start

Start running the command and return a handle to the running process.

Signature

export declare const start: (command: Command) => Effect<Process, PlatformError, any>

Added in v1.0.0

stream

Start running the command and return the output as a Stream.

Signature

export declare const stream: (command: Command) => Stream<Uint8Array, PlatformError, CommandExecutor>

Added in v1.0.0

streamLines

Runs the command returning the output as an stream of lines with the specified encoding.

Signature

export declare const streamLines: (command: Command) => Stream<string, PlatformError, CommandExecutor>

Added in v1.0.0

string

Runs the command returning the entire output as a string with the specified encoding.

If an encoding is not specified, the encoding will default to utf-8.

Signature

export declare const string: {
  (encoding?: string): (command: Command) => Effect<string, PlatformError, CommandExecutor>
  (command: Command, encoding?: string): Effect<string, PlatformError, CommandExecutor>
}

Added in v1.0.0

models

Command (type alias)

Signature

export type Command = StandardCommand | PipedCommand

Added in v1.0.0

CommandInput (type alias)

Configures the pipe that is established between the parent and child processes’ stdin stream.

Defaults to “pipe”

Signature

export type CommandInput = "inherit" | "pipe" | Stream<Uint8Array, PlatformError>

Added in v1.0.0

CommandOutput (type alias)

Configures the pipes that are established between the parent and child processes stderr and stdout streams.

Defaults to “pipe”

Signature

export type CommandOutput = "inherit" | "pipe" | Sink<Uint8Array, Uint8Array>

Added in v1.0.0

PipedCommand (interface)

Signature

export interface PipedCommand extends Command.Proto {
  readonly _tag: "PipedCommand"
  readonly left: Command
  readonly right: Command
}

Added in v1.0.0

StandardCommand (interface)

Signature

export interface StandardCommand extends Command.Proto {
  readonly _tag: "StandardCommand"
  readonly command: string
  readonly args: ReadonlyArray<string>
  readonly env: HashMap<string, string>
  readonly cwd: Option<string>
  readonly shell: boolean | string
  readonly stdin: Command.Input
  readonly stdout: Command.Output
  readonly stderr: Command.Output
  readonly gid: Option<number>
  readonly uid: Option<number>
}

Added in v1.0.0

refinements

isCommand

Returns true if the specified value is a Command, otherwise returns false.

Signature

export declare const isCommand: (u: unknown) => u is Command

Added in v1.0.0

utils

Command (namespace)

Added in v1.0.0

Proto (interface)

Signature

export interface Proto extends Pipeable, Inspectable {
  readonly [CommandTypeId]: CommandTypeId
  readonly _tag: string
}

Added in v1.0.0

Input (type alias)

Configures the pipe that is established between the parent and child processes’ stdin stream.

Signature

export type Input = CommandInput

Added in v1.0.0

Output (type alias)

Configures the pipes that are established between the parent and child processes stderr and stdout streams.

Signature

export type Output = CommandOutput

Added in v1.0.0

CommandTypeId

Signature

export declare const CommandTypeId: typeof CommandTypeId

Added in v1.0.0

CommandTypeId (type alias)

Signature

export type CommandTypeId = typeof CommandTypeId

Added in v1.0.0