Command.ts overview
Since v1.0.0
Exports Grouped by Category
combinators
env
Specify the environment variables that will be used when running this command.
Signature
declare const env: {
(environment: Record<string, string | undefined>): (self: Command) => Command
(self: Command, environment: Record<string, string | undefined>): Command
}
Since v1.0.0
feed
Feed a string to standard input (default encoding of UTF-8).
Signature
declare const feed: { (input: string): (self: Command) => Command; (self: Command, input: string): Command }
Since 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
declare const flatten: (self: Command) => NonEmptyReadonlyArray<StandardCommand>
Since 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
declare const pipeTo: { (into: Command): (self: Command) => Command; (self: Command, into: Command): Command }
Since v1.0.0
runInShell
Allows for specifying whether or not a Command
should be run inside a shell.
Signature
declare const runInShell: {
(shell: string | boolean): (self: Command) => Command
(self: Command, shell: string | boolean): Command
}
Since v1.0.0
stderr
Specify the standard error stream for a command.
Signature
declare const stderr: {
(stderr: Command.Output): (self: Command) => Command
(self: Command, stderr: Command.Output): Command
}
Since v1.0.0
stdin
Specify the standard input stream for a command.
Signature
declare const stdin: {
(stdin: Command.Input): (self: Command) => Command
(self: Command, stdin: Command.Input): Command
}
Since v1.0.0
stdout
Specify the standard output stream for a command.
Signature
declare const stdout: {
(stdout: Command.Output): (self: Command) => Command
(self: Command, stdout: Command.Output): Command
}
Since 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
declare const workingDirectory: { (cwd: string): (self: Command) => Command; (self: Command, cwd: string): Command }
Since v1.0.0
constructors
make
Create a command with the specified process name and an optional list of arguments.
Signature
declare const make: (command: string, ...args: Array<string>) => Command
Since v1.0.0
execution
exitCode
Returns the exit code of the command after the process has completed execution.
Signature
declare const exitCode: (self: Command) => Effect<ExitCode, PlatformError, CommandExecutor>
Since v1.0.0
lines
Runs the command returning the output as an array of lines with the specified encoding.
Signature
declare const lines: (command: Command, encoding?: string) => Effect<Array<string>, PlatformError, CommandExecutor>
Since v1.0.0
start
Start running the command and return a handle to the running process.
Signature
declare const start: (command: Command) => Effect<Process, PlatformError, CommandExecutor | Scope>
Since v1.0.0
stream
Start running the command and return the output as a Stream
.
Signature
declare const stream: (command: Command) => Stream<Uint8Array, PlatformError, CommandExecutor>
Since v1.0.0
streamLines
Runs the command returning the output as an stream of lines with the specified encoding.
Signature
declare const streamLines: (command: Command, encoding?: string) => Stream<string, PlatformError, CommandExecutor>
Since 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
declare const string: {
(encoding?: string): (command: Command) => Effect<string, PlatformError, CommandExecutor>
(command: Command, encoding?: string): Effect<string, PlatformError, CommandExecutor>
}
Since v1.0.0
models
Command (type alias)
Signature
type Command = StandardCommand | PipedCommand
Since v1.0.0
CommandInput (type alias)
Configures the pipe that is established between the parent and child processes’ stdin
stream.
Defaults to “pipe”
Signature
type CommandInput = "inherit" | "pipe" | Stream<Uint8Array, PlatformError>
Since 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
type CommandOutput = "inherit" | "pipe" | Sink<Uint8Array, Uint8Array>
Since v1.0.0
PipedCommand (interface)
Signature
export interface PipedCommand extends Command.Proto {
readonly _tag: "PipedCommand"
readonly left: Command
readonly right: Command
}
Since 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>
}
Since v1.0.0
refinements
isCommand
Returns true
if the specified value is a Command
, otherwise returns false
.
Signature
declare const isCommand: (u: unknown) => u is Command
Since v1.0.0
utils
Command (namespace)
Since v1.0.0
Proto (interface)
Signature
export interface Proto extends Pipeable, Inspectable {
readonly [CommandTypeId]: CommandTypeId
readonly _tag: string
}
Since v1.0.0
Input (type alias)
Configures the pipe that is established between the parent and child processes’ stdin
stream.
Signature
type Input = CommandInput
Since v1.0.0
Output (type alias)
Configures the pipes that are established between the parent and child processes stderr
and stdout
streams.
Signature
type Output = CommandOutput
Since v1.0.0
CommandTypeId
Signature
declare const CommandTypeId: unique symbol
Since v1.0.0
CommandTypeId (type alias)
Signature
type CommandTypeId = typeof CommandTypeId
Since v1.0.0