# applescript-promise

> Easily execute arbitrary AppleScript code on OS X through NodeJS with Promises.

Latest version **0.0.6** (published 2017-08-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install applescript-promise
pnpm add applescript-promise
yarn add applescript-promise
bun add applescript-promise
```

## Health

**Score 5/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2017-08-30 |
| First published | 2017-08-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Lucas Bento |
| Maintainers | lucasbento |
| Keywords | apple, applescript, es6, mac, node, osascript, osx, promise |

## Links

- npm: https://www.npmjs.com/package/applescript-promise
- Repository: https://github.com/lucasbento/node-applescript-promise
- Homepage: https://github.com/lucasbento/node-applescript-promise#readme
- Issues: https://github.com/lucasbento/node-applescript-promise/issues
- npm.io page: https://npm.io/package/applescript-promise

## Dependencies (2)

- [applescript](https://npm.io/package/applescript.md) github:lucasbento/node-applescript
- [babel-polyfill](https://npm.io/package/babel-polyfill.md) ^6.20.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.0.6 (latest) — 2017-08-30
- 0.0.5 — 2017-08-30
- 0.0.4 — 2017-08-30
- 0.0.3 — 2017-08-30
- 0.0.2 — 2017-08-28
- 0.0.1 — 2017-08-28

## README

# node-applescript-promise ![](https://api.travis-ci.org/lucasbento/node-applescript-promise.svg?branch=master)

A high-level way to execute AppleScript code through NodeJS and retrieve
the result as a native JavaScript object. Underneath the hood, this
module is just a simple wrapper around the OS X `osascript` command.

### Why?
AppleScripts are the only way to communicate and interact with certain
external OS X processes, for example [iTunes](http://www.itunes.com).

Easy Install
------------

```sh
yarn add applescript-promise
```

Requirements
------------

 * Mac (or Hackintosh) running [OS X](http://www.apple.com/macosx) (tested with Sierra)
 * [NodeJS](http://nodejs.org) (v4.4.7 or newer)

Usage
-----

The `node-applescript-promise` module provides `execString` and `execFile` functions
to easily execute AppleScript commands and buffer the output into a calback.

```js
import applescript from 'applescript';

// Very basic AppleScript command. Returns the song name of each
// currently selected track in iTunes as an 'Array' of 'String's.

const script = 'tell application "iTunes" to get name of selection';

applescript.execString(script)
  .then((tracks) => {
    tracks.forEach(songName => console.log(songName);
  })
  .catch((error) => {
    // Something went wrong
    console.log('error:', error);
  });
```

`execFile` works the exact same way, except you pass the _path_ of the AppleScript
(`*.applescript`) file as the first argument instead of the command itself, and you
may pass an optional `Array` of strings as a second argument to send to the applescript file.

License
-------

The `node-applescript-promise` module is licensed under the MIT license.

This module is a merely wrapper over [node-applescript](https://github.com/TooTallNate/node-applescript/).

---
_Source: https://npm.io/package/applescript-promise · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
