Options
All
  • Public
  • Public/Protected
  • All
Menu

kpo v0.23.2

Index

Type aliases

ExecOptions: ExecaOptions
LogLevel: None | Core
PrefixPolicy: "none" | "print" | "exec" | "all"
Stdio: [Readable | null, Writable | null, Writable | null]
StyleColor: ForegroundColor
Task: (context: Context) => Promise<void> | void

Type declaration

    • (context: Context): Promise<void> | void
    • A task, that being a Context receiving function, optionally async.

      Parameters

      Returns Promise<void> | void

Functions

  • Catches errors in a task, preventing it from stopping execution of other tasks when run in series or parallel. When a task raises an exception, it will log the error message with a given options.level, and optionally run an alternate task.

    Parameters

    Returns Async

    Task

  • Modifies a task's context with a given context. Takes a context as a first argument, which can be a partial Context object, or a callback receiving a Context and returning a partial Context object.

    Parameters

    Returns Async

    Task

  • copy(paths: string | string[], destination: string, options?: CopyOptions): Async
  • Copies files or directories from paths to destination. Treats destination as a folder unless options.single is true.

    Parameters

    • paths: string | string[]
    • destination: string
    • Optional options: CopyOptions

    Returns Async

    Task

  • Takes an optionally Task returning function and turns the function itself and the returned Task into a single sequential Task.

    Parameters

    Returns Async

    Task

  • edit(paths: string | string[], cb: (buffer: Buffer, path: string) => Buffer | Type | Promise<Buffer | Type>, options?: EditOptions): Async
  • Reads files as specified in paths, calling the cb callback with a Buffer for each file read. The callback's responses will be written into the original file path. If the callback returns an object, it will be stringified as JSON.

    Parameters

    • paths: string | string[]
    • cb: (buffer: Buffer, path: string) => Buffer | Type | Promise<Buffer | Type>
        • (buffer: Buffer, path: string): Buffer | Type | Promise<Buffer | Type>
        • Parameters

          • buffer: Buffer
          • path: string

          Returns Buffer | Type | Promise<Buffer | Type>

    • Optional options: EditOptions

    Returns Async

    Task

  • exec(file: null | string, args?: string[] | Empty, options?: Empty | ExecOptions, cb?: (ps: ExecaChildProcess<string>) => void): Async
  • Spawns a process. When no file is passed, it will execute node.

    Parameters

    • file: null | string
    • Optional args: string[] | Empty
    • Optional options: Empty | ExecOptions
    • Optional cb: (ps: ExecaChildProcess<string>) => void
        • (ps: ExecaChildProcess<string>): void
        • Parameters

          • ps: ExecaChildProcess<string>

          Returns void

    Returns Async

    Task

  • finalize(task?: Task | Empty | (Task | Empty)[] | Dictionary<Task | Empty>, ...tasks: (Task | Empty)[]): Async
  • Executes all tasks in series. If any of the tasks throws an exception, it will throw after all tasks have finalized with the latest thrown exception.

    Parameters

    • Optional task: Task | Empty | (Task | Empty)[] | Dictionary<Task | Empty>
    • Rest ...tasks: (Task | Empty)[]

    Returns Async

    Task

  • Marks a task as interactive. Will error on non-interactive environments unless an alternate task is provided.

    Parameters

    Returns Async

    Task

  • Returns true when a context's environment variables indicate it's running in a CI.

    Parameters

    Returns boolean

  • isCancelled(context: Context): Promise<boolean>
  • A promise returning function that will resolve with true if context.cancellation has finalized, and false otherwise.

    Parameters

    Returns Promise<boolean>

  • Returns true when a context is that of an interactive environment. Ensures that there's a TTY stdin and stdout, it's a non-dumb terminal, and not running in a CI.

    Parameters

    Returns context is Interactive

  • Lifts all tasks on a tasks record to a package.json file, which is expected to be available at the context's working directory. The tasks argument can be a record itself, a string with the path of the tasks record, or empty to fetch it at the default path.

    Parameters

    Returns Async

    Task

  • Writes a message or other data into a context's stdout if a given context.level allows for the particular logging level of the call.

    Parameters

    • level: LogLevel
    • item: any
    • Rest ...data: any[]

    Returns Sync

    Task

  • move(paths: string | string[], destination: string, options?: MoveOptions): Async
  • Moves files or directories from paths to destination. Treats destination as a folder unless options.single is true.

    Parameters

    • paths: string | string[]
    • destination: string
    • Optional options: MoveOptions

    Returns Async

    Task

  • parallel(task?: Task | Empty | (Task | Empty)[] | Dictionary<Task | Empty>, ...tasks: (Task | Empty)[]): Async
  • Returns a Task that will run in parallel a set of given tasks. Suppresses the context's stdin. For tasks passed as arguments, the route will be left unmodified, while task lists and records will inherit their index or key name for their route.

    Parameters

    • Optional task: Task | Empty | (Task | Empty)[] | Dictionary<Task | Empty>
    • Rest ...tasks: (Task | Empty)[]

    Returns Async

    Task

  • print(...data: any[]): Sync
  • Writes a message or other data into a context's stdout.

    Parameters

    • Rest ...data: any[]

    Returns Sync

    Task

  • Shows a spinner upon task initialization, and a success message on successful finalization. Will suppress the context's stdio. Non-interactive environments will fallback to announce. Logging levels equal or above debug will fallback to logging the start and successful finalization of a task, while maintaining the context's stdout and stderr.

    Parameters

    Returns Async

    Task

  • Uses a context's stdio to prompt for a user response. The response will be prepended to the context arg array for task, when valid.

    Parameters

    Returns Async

    Task

  • raises(error: string | Error | UnaryFn<Context, string | Error>): Sync
  • repeat(times: null | number, task: Task): Async
  • run(context: Empty | Partial<Context>, task: Task): Promise<void>
  • Safely runs a task with an optional given context.

    Parameters

    Returns Promise<void>

  • Uses a context's stdio to prompt for input. Executes a task in response to user selection. Takes in a record of tasks.

    Parameters

    Returns Async

    Task

  • series(task?: Task | Empty | (Task | Empty)[] | Dictionary<Task | Empty>, ...tasks: (Task | Empty)[]): Async
  • Returns a Task that will run in series a set of given tasks. For tasks passed as arguments, the route will be left unmodified, while task lists and records will inherit their index or key name for their route.

    Parameters

    • Optional task: Task | Empty | (Task | Empty)[] | Dictionary<Task | Empty>
    • Rest ...tasks: (Task | Empty)[]

    Returns Async

    Task

  • Will suppress the context's stdio. Logging levels equal or above debug will maintain the context's stdout and stderr.

    Parameters

    Returns Async

    Task

  • Timeout for a task, in milliseconds. Will error on timeout unless an alternate task is provided.

    Parameters

    • ms: number
    • task: Task
    • alternate: Task | Empty

    Returns Async

    Task

  • Writes a file with a content at path. When content is an object, it will be stringified as JSON.

    Parameters

    • path: string
    • content: Buffer | Type
    • Optional options: WriteOptions

    Returns Async

    Task

Generated using TypeDoc