osascript-promise

1.0.0 • Public • Published

osascript-promise

stable

Execute Applescript from Node via Promises. A wrapper around node-osascript by @fweinb. Pairs well with tj/co.

var osascript = require('osascript-promise')
 
osascript('tell application "Google Chrome" to get URL of active tab of first window')
    .then(function (result) {
        console.log(result)
    })

Works using any-promise, so native promises, bluebird, rsvp, when, and q are all supported without any changes to your code.

Usage

NPM

This promisifies the execute method from node-osascript.

osascript(command[, variables])

Pass your Applescript in via the command variable. Multiline scripts work well using the ES6 template string syntax:

osascript(`
    tell application "Safari"
        activate
        open location "http://example.com"
    end tell
`).then(() => console.log('Success!'))

Applescript variables can be passed to the script as an object in the second argument:

osascript('display dialog message', { message: 'Hello from Node' })
    .then(() => console.log('Success!'))

License

MIT, see LICENSE.md for details.

Package Sidebar

Install

npm i osascript-promise

Weekly Downloads

4

Version

1.0.0

License

MIT

Last publish

Collaborators

  • rosszurowski