Command
Combinators
Signature
declare const env: {
(
environment: Record<string, string | undefined>,
options?: {
readonly extendEnv?: boolean;
},
): (self: Command) => Command;
(
self: Command,
environment: Record<string, string | undefined>,
options?: {
readonly extendEnv?: boolean;
},
): Command;
};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;
};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>;Pipe one command to another command from left to right.
Conceptually, the equivalent of piping one shell command to another:
``sh command1 | command2 ``
Signature
declare const pipeTo: {
(into: Command): (self: Command) => Command;
(self: Command, into: Command): Command;
};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;
};Specify the standard error stream for a command.
Signature
declare const stderr: {
(stderr: CommandOutput): (self: Command) => Command;
(self: Command, stderr: CommandOutput): Command;
};Specify the standard input stream for a command.
Signature
declare const stdin: {
(stdin: CommandInput): (self: Command) => Command;
(self: Command, stdin: CommandInput): Command;
};Specify the standard output stream for a command.
Signature
declare const stdout: {
(stdout: CommandOutput): (self: Command) => Command;
(self: Command, stdout: CommandOutput): Command;
};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;
};Constructors
Execution
Returns the exit code of the command after the process has completed execution.
Signature
declare const exitCode: (self: Command) => Effect<ExitCode, PlatformError, CommandExecutor>;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>;Start running the command and return a handle to the running process.
Signature
declare const start: (command: Command) => Effect<Process, PlatformError, CommandExecutor | Scope>;Start running the command and return the output as a Stream.
Signature
declare const stream: (command: Command) => Stream<Uint8Array, PlatformError, CommandExecutor>;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>;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>;
};Models
Signature
type Command = StandardCommand | PipedCommand;CommandInput type
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>;CommandOutput type
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>;PipedCommand interface
Signature
interface PipedCommand extends Proto {
readonly _tag: "PipedCommand";
readonly left: Command;
readonly right: Command;
}StandardCommand interface
Signature
interface StandardCommand extends Proto {
readonly _tag: "StandardCommand";
readonly args: readonly Array<string>;
readonly command: string;
readonly cwd: Option<string>;
readonly env: HashMap<string, string>;
readonly extendEnv: boolean;
readonly gid: Option<number>;
readonly shell: string | boolean;
readonly stderr: CommandOutput;
readonly stdin: CommandInput;
readonly stdout: CommandOutput;
readonly uid: Option<number>;
}Other
CommandTypeId
Signature
declare const CommandTypeId: unique symbol;CommandTypeId type
Signature
type CommandTypeId = typeof CommandTypeId;
Specify the environment variables that will be used when running this command.
By default, the configured variables extend the parent process environment. Set
extendEnvtofalseto use only the configured variables.