hs.task
Module
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.new
Create a new task
Hammerspoon 2/Modules/hs.task/HSTaskModule.swift:25
Declaration
hs.task.new(launchPath, arguments, completionCallback, environment, streamingCallback) -> HSTask
Parameters
-
launchPathstringThe full path to the executable to run
-
argumentsstring[]An array of arguments to pass to the executable
-
completionCallbackJSValueOptional callback function called when the task terminates
-
environmentJSValueOptional dictionary of environment variables for the task
-
streamingCallbackJSValueOptional callback function called when the task produces output
Return Value
A task object. Call start() to begin execution.
hs.task.runAsync
Create and run a task asynchronously
Hammerspoon 2/Modules/hs.task/hs.task.js:9
Declaration
hs.task.runAsync(launchPath, args, options, options, options, options, legacyStreamCallback) -> any
Parameters
-
launchPathstring- Full path to the executable
-
argsstring[]- Array of arguments
-
optionsObject|Function- Options object or legacy callback
-
optionsObject.environment - Environment variables (optional)
-
optionsstring.workingDirectory - Working directory (optional)
-
optionsFunction.onOutput - Callback for streaming output: (stream, data) => {} (optional)
-
legacyStreamCallbackFunction- Legacy streaming callback (optional)
Return Value
{Promise<{exitCode: number, stdout: string, stderr: string}>}
hs.task.shell
Run a shell command asynchronously
Hammerspoon 2/Modules/hs.task/hs.task.js:89
Declaration
hs.task.shell(command, options) -> any
Parameters
-
commandstring- Shell command to execute
-
optionsObject- Options (same as run)
Return Value
{Promise<{exitCode: number, stdout: string, stderr: string}>}
hs.task.parallel
Run multiple tasks in parallel
Hammerspoon 2/Modules/hs.task/hs.task.js:99
Declaration
hs.task.parallel(tasks) -> Promise
Parameters
-
tasksArray- Array of task specifications: [{path, args, options}, ...]
Return Value
Array of results
hs.task.builder
Create a task builder for fluent API
Hammerspoon 2/Modules/hs.task/hs.task.js:125
Declaration
hs.task.builder(launchPath) -> any
Parameters
-
launchPathstring- Full path to the executable
Return Value
{TaskBuilder}