Use AppleScript from node.js
Execute AppleScript from node.js and process the results.
Table of Contents
Install
$ npm install node-osascript
Overview
Execute AppleScript and use the results of the javascript in node.
The result is transformed into a javascript object using PEG.js
So AppleScript lists are transformed into an Array
, Records into a plain object
and
Dates to the Date
type as well as Numbers
, Booleans
and Strings
.
Examples
Simple
var osascript = ; osascript;
Injecting Variables
You can inject a javascript object into the script to have acces to these variables.
var osascript = ; osascript;
Timeout
You can force an AppleScript to stop running
var osascript = ; var childProcess = osascript; //after 20 seconds, the AppleScript will be killed
API
Methods
execute(script, [variables], callback)
Execute the script
, if specified injecting the variables
into the AppleScript.
osascript;
executeFile(path, [variables], callback)
Execute file in path
, if specified injecting the variables
into the AppleScript.
osascript;
Tests
To run platform independent tests use:
npm test
If you are on macOS you can run all tests using:
npm testall
License
MIT