osascript-promise
v1.0.0
Published
Execute Applescript through Node via Promises
Downloads
14
Maintainers
Readme
osascript-promise
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
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.