Skip to content

rosszurowski/osascript-promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

osascript-promise

stable

Execute Applescript from Node via Promises. A wrapper around node-osascript by @fweinb. Pairs well with await and async.

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.

About

Execute Applescript from Node via Promises

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published