Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

escape-string-applescript

sindresorhus1.2mMIT3.0.0

Escape a string for use in AppleScript

escape, string, applescript, osascript, quote, quotes, backslash

readme

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 escape-string-applescript

Usage

import {execFile} from 'child_process';
import escapeStringAppleScript from 'escape-string-applescript';

const string = escapeStringAppleScript('"i like unicorns"');
//=> '\"i like unicorns\"'

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

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