escape-string-applescript

Escape a string for use in AppleScript


Keywords
escape, string, applescript, osascript, quote, quotes, backslash
License
MIT
Install
npm install escape-string-applescript@3.0.0

Documentation

escape-string-applescript

Escape a string for use in AppleScript

According to the AppleScript docs, \ and " have special meaning and should be escaped.

Install

$ npm install --save escape-string-applescript

Usage

const {execFile} = require('child_process');
const escapeString = require('escape-string-applescript');

const str = escapeString('"i like unicorns"');
//=> '\"i like unicorns\"'

const script = `set unicornMessage to "${str}"`;

execFile('osascript', ['-e', script]);

Related

License

MIT © Sindre Sorhus