run-applescript
Advanced tools
Comparing version
14
index.js
'use strict'; | ||
const execa = require('execa'); | ||
module.exports = str => { | ||
module.exports = script => { | ||
if (process.platform !== 'darwin') { | ||
return Promise.reject(new Error('Only OS X is supported')); | ||
return Promise.reject(new Error('macOS only')); | ||
} | ||
return execa.stdout('osascript', ['-e', str]); | ||
return execa.stdout('osascript', ['-e', script]); | ||
}; | ||
module.exports.sync = script => { | ||
if (process.platform !== 'darwin') { | ||
throw new Error('macOS only'); | ||
} | ||
return execa.sync('osascript', ['-e', script]).stdout; | ||
}; |
{ | ||
"name": "run-applescript", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Run AppleScript and get the result", | ||
@@ -22,3 +22,3 @@ "license": "MIT", | ||
"keywords": [ | ||
"osx", | ||
"macos", | ||
"mac", | ||
@@ -31,3 +31,3 @@ "applescript", | ||
"dependencies": { | ||
"execa": "^0.4.0" | ||
"execa": "^0.8.0" | ||
}, | ||
@@ -37,6 +37,3 @@ "devDependencies": { | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
} |
@@ -9,3 +9,3 @@ # run-applescript [](https://travis-ci.org/sindresorhus/run-applescript) | ||
``` | ||
$ npm install --save run-applescript | ||
$ npm install run-applescript | ||
``` | ||
@@ -19,11 +19,29 @@ | ||
runApplescript('return "unicorn"').then(result => { | ||
(async () => { | ||
const result = await runApplescript('return "unicorn"'); | ||
console.log(result); | ||
//=> 'unicorn' | ||
}); | ||
})(); | ||
``` | ||
## API | ||
### runAppleScript(script) | ||
Returns a `Promise<string>` with the script result. | ||
### runAppleScript.sync(script) | ||
Returns a `string` with the script result. | ||
## Related | ||
- [run-jxa](https://github.com/sindresorhus/run-jxa) - Run JXA code and get the result | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
Sorry, the diff of this file is not supported yet
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
2891
16.34%14
75%46
64.29%0
-100%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
Updated