run-applescript
Advanced tools
+7
-0
@@ -20,2 +20,9 @@ export type Options = { | ||
| readonly humanReadableOutput?: boolean; | ||
| /** | ||
| An AbortSignal that can be used to cancel the AppleScript execution. | ||
| Only supported by the async function. | ||
| */ | ||
| readonly signal?: AbortSignal; | ||
| }; | ||
@@ -22,0 +29,0 @@ |
+7
-2
@@ -7,3 +7,3 @@ import process from 'node:process'; | ||
| export async function runAppleScript(script, {humanReadableOutput = true} = {}) { | ||
| export async function runAppleScript(script, {humanReadableOutput = true, signal} = {}) { | ||
| if (process.platform !== 'darwin') { | ||
@@ -15,3 +15,8 @@ throw new Error('macOS only'); | ||
| const {stdout} = await execFileAsync('osascript', ['-e', script, outputArguments]); | ||
| const execOptions = {}; | ||
| if (signal) { | ||
| execOptions.signal = signal; | ||
| } | ||
| const {stdout} = await execFileAsync('osascript', ['-e', script, outputArguments], execOptions); | ||
| return stdout.trim(); | ||
@@ -18,0 +23,0 @@ } |
+1
-1
| { | ||
| "name": "run-applescript", | ||
| "version": "7.0.0", | ||
| "version": "7.1.0", | ||
| "description": "Run AppleScript and get the result", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
+6
-0
@@ -47,2 +47,8 @@ # run-applescript | ||
| ##### signal | ||
| Type: `AbortSignal` | ||
| An AbortSignal that can be used to cancel the AppleScript execution. | ||
| ### runAppleScriptSync(script, options?) | ||
@@ -49,0 +55,0 @@ |
5355
7.06%77
13.24%79
8.22%