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

CommandExecutor overview

Added in v1.0.0


Table of contents


constructors

ExitCode

Signature

export declare const ExitCode: Brand.Brand.Constructor<Brand.Branded<number, "ExitCode">>

Added in v1.0.0

ProcessId

Signature

export declare const ProcessId: Brand.Brand.Constructor<Brand.Branded<number, "ProcessId">>

Added in v1.0.0

makeExecutor

Signature

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

Added in v1.0.0

models

CommandExecutor (interface)

Signature

export interface CommandExecutor {
  readonly [TypeId]: TypeId

  /**
   * Returns the exit code of the command after the process has completed
   * execution.
   */
  readonly exitCode: (command: Command) => Effect<ExitCode, PlatformError>
  /**
   * Start running the command and return a handle to the running process.
   */
  readonly start: (command: Command) => Effect<Process, PlatformError, Scope>
  /**
   * 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`.
   */
  readonly string: (command: Command, encoding?: string) => Effect<string, PlatformError>
  /**
   * Runs the command returning the entire output as an array of lines.
   *
   * If an encoding is not specified, the encoding will default to `utf-8`.
   */
  readonly lines: (command: Command, encoding?: string) => Effect<ReadonlyArray<string>, PlatformError>
  /**
   * Runs the command returning the output as a `Stream`.
   */
  readonly stream: (command: Command) => Stream<Uint8Array, PlatformError>
  /**
   * Runs the command returning the output as a `Stream` of lines.
   */
  readonly streamLines: (command: Command, encoding?: string) => Stream<string, PlatformError>
}

Added in v1.0.0

ExitCode (type alias)

Signature

export type ExitCode = Brand.Branded<number, "ExitCode">

Added in v1.0.0

Process (interface)

Signature

export interface Process extends Inspectable {
  readonly [ProcessTypeId]: ProcessTypeId
  /**
   * The process identifier.
   */
  readonly pid: ProcessId
  /**
   * Waits for the process to exit and returns the `ExitCode` of the command
   * that was run.
   */
  readonly exitCode: Effect<ExitCode, PlatformError>
  /**
   * Returns `true` if the process is still running, otherwise returns `false`.
   */
  readonly isRunning: Effect<boolean, PlatformError>
  /**
   * Kills the running process with the provided signal.
   *
   * If no signal is provided, the signal will defaults to `SIGTERM`.
   */
  readonly kill: (signal?: Signal) => Effect<void, PlatformError>
  /**
   * The standard error stream of the process.
   */
  readonly stderr: Stream<Uint8Array, PlatformError>
  /**
   * The standard input sink of the process.
   */
  readonly stdin: Sink<void, Uint8Array, never, PlatformError>
  /**
   * The standard output stream of the process.
   */
  readonly stdout: Stream<Uint8Array, PlatformError>
}

Added in v1.0.0

ProcessId (type alias)

Signature

export type ProcessId = Brand.Branded<number, "ProcessId">

Added in v1.0.0

Signal (type alias)

Signature

export type Signal =
  | "SIGABRT"
  | "SIGALRM"
  | "SIGBUS"
  | "SIGCHLD"
  | "SIGCONT"
  | "SIGFPE"
  | "SIGHUP"
  | "SIGILL"
  | "SIGINT"
  | "SIGIO"
  | "SIGIOT"
  | "SIGKILL"
  | "SIGPIPE"
  | "SIGPOLL"
  | "SIGPROF"
  | "SIGPWR"
  | "SIGQUIT"
  | "SIGSEGV"
  | "SIGSTKFLT"
  | "SIGSTOP"
  | "SIGSYS"
  | "SIGTERM"
  | "SIGTRAP"
  | "SIGTSTP"
  | "SIGTTIN"
  | "SIGTTOU"
  | "SIGUNUSED"
  | "SIGURG"
  | "SIGUSR1"
  | "SIGUSR2"
  | "SIGVTALRM"
  | "SIGWINCH"
  | "SIGXCPU"
  | "SIGXFSZ"
  | "SIGBREAK"
  | "SIGLOST"
  | "SIGINFO"

Added in v1.0.0

symbols

ProcessTypeId

Signature

export declare const ProcessTypeId: typeof ProcessTypeId

Added in v1.0.0

ProcessTypeId (type alias)

Signature

export type ProcessTypeId = typeof ProcessTypeId

Added in v1.0.0

tags

CommandExecutor

Signature

export declare const CommandExecutor: Tag<CommandExecutor, CommandExecutor>

Added in v1.0.0

type ids

TypeId

Signature

export declare const TypeId: typeof TypeId

Added in v1.0.0

TypeId (type alias)

Signature

export type TypeId = typeof TypeId

Added in v1.0.0

utils

Process (namespace)

Added in v1.0.0

Id (type alias)

Signature

export type Id = ProcessId

Added in v1.0.0