runAppleScript
Function that executes an AppleScript script.
Signature
There are two ways to use the function.
The first one should be preferred when executing a static script.
The second one can be used to pass arguments to a script.
Arguments
script
is the script to execute.arguments
is an array of strings to pass as arguments to the script.
With a few options:
options.humanReadableOutput
is a boolean to tell the script what form to output. By default,runAppleScript
returns its results in human-readable form: strings do not have quotes around them, characters are not escaped, braces for lists and records are omitted, etc. This is generally more useful, but can introduce ambiguities. For example, the lists{"foo", "bar"}
and{{"foo", {"bar"}}}
would both be displayed as ‘foo, bar’. To see the results in an unambiguous form that could be recompiled into the same value, sethumanReadableOutput
tofalse
.options.language
is a string to specify whether the script is usingAppleScript
orJavaScript
. By default, it will assume that it's usingAppleScript
.options.signal
is a Signal object that allows you to abort the request if required via an AbortController object.options.timeout
is a number. If greater than0
, the parent will send the signalSIGTERM
if the script runs longer than timeout milliseconds. By default, the execution will timeout after 10000ms (eg. 10s).options.parseOutput
is a function that accepts the output of the script as an argument and returns the data the hooks will return - see ParseExecOutputHandler. By default, the function will returnstdout
as a string.
Return
Returns a Promise which resolves to a string by default. You can control what it returns by passing options.parseOutput
.
Example
Types
ParseExecOutputHandler
A function that accepts the output of the script as an argument and returns the data the function will return.
Last updated