Socket
Socket
Sign inDemoInstall

run-applescript

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

run-applescript - npm Package Compare versions

Comparing version 6.0.0 to 6.1.0

28

index.d.ts

@@ -0,1 +1,22 @@

export type Options = {
/**
Change the output style.
When `false`, returns the value in a [recompilable source form](https://ss64.com/osx/osascript.html).
@default true
@example
```
import {runAppleScript} from 'run-applescript';
const result = await runAppleScript('return "unicorn"', {humanReadableOutput: false});
console.log(result);
//=> '"unicorn"'
```
*/
readonly humanReadableOutput?: boolean;
};
/**

@@ -17,3 +38,6 @@ Run AppleScript asynchronously.

*/
export function runAppleScript(script: string): Promise<string>;
export function runAppleScript(
script: string,
options?: Options
): Promise<string>;

@@ -36,2 +60,2 @@ /**

*/
export function runAppleScriptSync(script: string): string;
export function runAppleScriptSync(script: string, options?: Options): string;

12

index.js
import process from 'node:process';
import execa from 'execa';
export async function runAppleScript(script) {
export async function runAppleScript(script, {humanReadableOutput = true} = {}) {
if (process.platform !== 'darwin') {

@@ -9,7 +9,9 @@ throw new Error('macOS only');

const {stdout} = await execa('osascript', ['-e', script]);
const outputArguments = humanReadableOutput ? [] : ['-ss'];
const {stdout} = await execa('osascript', ['-e', script, outputArguments]);
return stdout;
}
export function runAppleScriptSync(script) {
export function runAppleScriptSync(script, {humanReadableOutput = true} = {}) {
if (process.platform !== 'darwin') {

@@ -19,4 +21,6 @@ throw new Error('macOS only');

const {stdout} = execa.sync('osascript', ['-e', script]);
const outputArguments = humanReadableOutput ? [] : ['-ss'];
const {stdout} = execa.sync('osascript', ['-e', script, ...outputArguments]);
return stdout;
}
{
"name": "run-applescript",
"version": "6.0.0",
"version": "6.1.0",
"description": "Run AppleScript and get the result",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -24,12 +24,50 @@ # run-applescript

### runAppleScript(script)
### runAppleScript(script, options?)
Returns a `Promise<string>` with the script result.
### runAppleScriptSync(script)
#### script
Type: `string`
The script to run.
#### options
Type: `object`
##### humanReadableOutput
Type: `boolean`\
Default: `true`
Change the output style.
When `false`, returns the value in a [recompilable source form](https://ss64.com/osx/osascript.html).
### runAppleScriptSync(script, options?)
Returns a `string` with the script result.
#### script
Type: `string`
The script to run.
#### options
Type: `object`
##### humanReadableOutput
Type: `boolean`\
Default: `true`
Change the output style.
When `false`, returns the value in a [recompilable source form](https://ss64.com/osx/osascript.html).
## Related
- [run-jxa](https://github.com/sindresorhus/run-jxa) - Run JXA code and get the result
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc