Install run-applescript
mainInstall the package using npm to run AppleScript from your JavaScript/TypeScript code.
npm install run-applescriptrepository·main·Indexed 41 days ago
https://github.com/sindresorhus/run-applescriptA utility for executing AppleScript from JavaScript and TypeScript environments. Version 7.1.0 provides asynchronous execution via runAppleScript() and synchronous execution via runAppleScriptSync(), with options to control human-readable output and execution cancellation using AbortSignal.
Install the package using npm to run AppleScript from your JavaScript/TypeScript code.
npm install run-applescriptUse runAppleScriptSync to execute an AppleScript and receive the result as a string immediately. This will block the execution thread until the script completes.
import {runAppleScriptSync} from 'run-applescript';
const result = runAppleScriptSync('return "unicorn"');
console.log(result);
//=> 'unicorn'Use runAppleScript to execute an AppleScript and receive the result as a Promise<string>. This is the preferred method for non-blocking execution.
import {runAppleScript} from 'run-applescript';
const result = await runAppleScript('return "unicorn"');
console.log(result);
//=> 'unicorn'Both runAppleScript and runAppleScriptSync accept an optional options object to control execution behavior:
humanReadableOutput (boolean, default: true): Determines the output format. If set to false, the result is returned in a recompilable source form.signal (AbortSignal): An AbortSignal that can be used to cancel the AppleScript execution (available in runAppleScript).// Example using humanReadableOutput: false
const result = await runAppleScript('return "unicorn"', {
nonHumanReadable: false
});