UNPKG

dax

Version:

Cross platform shell tools inspired by zx.

92 lines 3.05 kB
/** Result of executing a custom command. */ export type ExecuteResult = ExitExecuteResult | ContinueExecuteResult; export declare function getAbortedResult(): ExecuteResult; /** Tells the shell it should exit immediately with the provided exit code. */ export interface ExitExecuteResult { /** Discriminator. */ kind: "exit"; /** Exit code to use and completely exit the shell with. */ code: number; } /** Tells the shell to continue executing. */ export interface ContinueExecuteResult { /** Discriminator. */ kind?: undefined; /** Exit code to use. */ code: number; /** Changes to the shell that should occur (ex. unsetting env vars). */ changes?: EnvChange[]; } /** Change that alters the environment. * * Used for registering custom commands. */ export type EnvChange = SetEnvVarChange | SetShellVarChange | UnsetVarChange | CdChange | SetOptionChange; /** Change that sets an environment variable (ex. `export ENV_VAR=VALUE`) * * Used for registering custom commands. */ export interface SetEnvVarChange { /** Discriminator. */ kind: "envvar"; /** Name of the env var to set. */ name: string; /** Value to set the env var to. */ value: string; } /** Change that sets a shell variable (ex. `ENV_VAR=VALUE`) * * Used for registering custom commands. */ export interface SetShellVarChange { /** Discriminator. */ kind: "shellvar"; /** Name of the shell var to set. */ name: string; /** Value to set the shell var to. */ value: string; } /** Change that deletes the environment variable (ex. `unset ENV_VAR`). * * Used for registering custom commands. */ export interface UnsetVarChange { /** Discriminator. */ kind: "unsetvar"; /** Nave of the env var to unset. */ name: string; } /** Change that alters the current working directory. * * Used for registering custom commands. */ export interface CdChange { /** Discriminator. */ kind: "cd"; /** Relative or absolute directory to change to. */ dir: string; } /** * Shell options that can be set via `shopt` or `set -o`. * * - `nullglob`: a glob pattern that matches no files expands to nothing * - `failglob`: a glob pattern that matches no files causes an error * - `pipefail`: pipeline exit code is the rightmost non-zero exit code * - `globstar`: `**` matches recursively across directories (default) * - `questionGlob`: `?` matches any single character in glob patterns * - `errexit`: abort a sequential list at the first non-zero command (`set -e`) */ export type ShellOption = "nullglob" | "failglob" | "pipefail" | "globstar" | "questionGlob" | "errexit"; /** Change that sets a shell option (ex. `shopt -s nullglob` or `set -o pipefail`). * * Used for registering custom commands. */ export interface SetOptionChange { /** Discriminator. */ kind: "setoption"; /** The shell option to set. */ option: ShellOption; /** Whether to enable or disable the option. */ value: boolean; } //# sourceMappingURL=result.d.ts.map