Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-osascript

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-osascript

Execute AppleScript from Node

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
561
decreased by-7.43%
Maintainers
1
Weekly downloads
 
Created
Source

node-osascript NPM version Build Status

Use AppleScript from node.js

Execute AppleScript from node.js and process the results.

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 = require('node-osascript');

osascript.execute('display dialog "What should I do?" buttons {"Go home", "Work", "Nothing"}\nset DlogResult to result\n return result', function(err, result, raw){
  if (err) return console.error(err)
  console.log(result, raw)
});

Injecting variables

You can inject a javascript object into the script to have acces to these variables.

var osascript = require('node-osascript');

osascript.execute('display dialog message', { message : "Hello from Node.JS" },function(err, result, raw){
  if (err) return console.error(err)
  console.log(result, raw)
});

API

Methods
execute(script, [variables], callback)

Execute the script, if specified injecting the variables into the AppleScript.

osascript.execute('script', { varName : 'value'}, function(error, result, raw){
  if (err) return console.error(err)
    console.log(result, raw)
});
executeFile(path, [variables], callback)

Execute file in path, if specified injecting the variables into the AppleScript.

osascript.executeFile('path/to/script.scpt', { varName : 'value'}, function(error, result, raw){
  if (err) return console.error(err)
    console.log(result, raw)
});

Tests

npm install grunt-cli --global
npm test

License

MIT

Changelog

1.0.1
  • Fix a bug where empty results where considert an error (Fix #2)
1.0.0
  • Stable release
  • Fix package.json
0.0.1
  • Inital release

Keywords

FAQs

Package last updated on 21 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc