API Docs

Module for running external processes

Types

This module provides the following types:

Properties

hs.task.runAsync

JSValue
Run a task, returning a Promise. Swift-retained storage for the JS implementation.

hs.task.shell

JSValue
Run a shell command. Swift-retained storage for the JS implementation.

hs.task.parallel

JSValue
Run multiple tasks in parallel. Swift-retained storage for the JS implementation.

hs.task.sequence

JSValue
Run multiple tasks in sequence. Swift-retained storage for the JS implementation.

hs.task.builder

JSValue
Create a task builder. Swift-retained storage for the JS implementation.

hs.task.TaskBuilder

JSValue
TaskBuilder class. Swift-retained storage for the JS implementation.

Methods

hs.task.create(launchPath, arguments, completionCallback, environment, streamingCallback) -> HSTask

Create a new task
hs.task.create(launchPath, arguments, completionCallback, environment, streamingCallback) -> HSTask
Name Type Description
launchPath string The full path to the executable to run
arguments string[] An array of arguments to pass to the executable
completionCallback JSValue Optional callback function called when the task terminates
environment JSValue Optional dictionary of environment variables for the task
streamingCallback JSValue Optional callback function called when the task produces output
HSTask
A task object. Call start() to begin execution.
const task = hs.task.create("/usr/bin/env", ["printenv", "PATH"], (code, reason) => {
    console.log("exited", code)
})
task.start()

hs.task.runAsync(launchPath, args, options, options, options, options, legacyStreamCallback) -> any

Create and run a task asynchronously
hs.task.runAsync(launchPath, args, options, options, options, options, legacyStreamCallback) -> any
Name Type Description
launchPath string - Full path to the executable
args string[] - Array of arguments
options Object|Function - Options object or legacy callback
options Object .environment - Environment variables (optional)
options string .workingDirectory - Working directory (optional)
options Function .onOutput - Callback for streaming output: (stream, data) => {} (optional)
legacyStreamCallback Function - Legacy streaming callback (optional)
any
{Promise<{exitCode: number, stdout: string, stderr: string}>}

hs.task.shell(command, options) -> any

Run a shell command asynchronously
hs.task.shell(command, options) -> any
Name Type Description
command string - Shell command to execute
options Object - Options (same as run)
any
{Promise<{exitCode: number, stdout: string, stderr: string}>}

hs.task.parallel(tasks) -> Promise

Run multiple tasks in parallel
hs.task.parallel(tasks) -> Promise
Name Type Description
tasks Array - Array of task specifications: [{path, args, options}, ...]
Promise
Array of results

hs.task.builder(launchPath) -> any

Create a task builder for fluent API
hs.task.builder(launchPath) -> any
Name Type Description
launchPath string - Full path to the executable
any
{TaskBuilder}