Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
node-osascript
Advanced tools
Use AppleScript from node.js
Execute AppleScript from node.js and process the results.
$ npm install node-osascript
Execute AppleScript and use the results of the javascript in node.
The result is transformed into a javascript object using PEG.js
So AppleScript lists are transformed into an Array
, Records into a plain object
and
Dates to the Date
type as well as Numbers
, Booleans
and Strings
.
var osascript = require('node-osascript');
osascript.execute('display dialog "What should I do?" buttons {"Go home", "Work", "Nothing"}\nset DlogResult to result\n return result', function(err, result, raw){
if (err) return console.error(err)
console.log(result, raw)
});
You can inject a javascript object into the script to have acces to these variables.
var osascript = require('node-osascript');
osascript.execute('display dialog message', { message : "Hello from Node.JS" },function(err, result, raw){
if (err) return console.error(err)
console.log(result, raw)
});
You can force an AppleScript to stop running
var osascript = require('node-osascript');
var childProcess = osascript.execute('display dialog "What should I do?" buttons {"Go home", "Work", "Nothing"}\nset DlogResult to result\n return result', function(err, result, raw){
if (err) return console.error(err)
console.log(result, raw)
});
//after 20 seconds, the AppleScript will be killed
setTimeout(function(){
console.log('kill');
childProcess.stdin.pause();
childProcess.kill();
},20000)
execute(script, [variables], callback)
Execute the script
, if specified injecting the variables
into the AppleScript.
osascript.execute('script', { varName : 'value'}, function(err, result, raw){
if (err) return console.error(err)
console.log(result, raw)
});
executeFile(path, [variables], callback)
Execute file in path
, if specified injecting the variables
into the AppleScript.
osascript.executeFile('path/to/script.scpt', { varName : 'value'}, function(err, result, raw){
if (err) return console.error(err)
console.log(result, raw)
});
To run platform independent tests use:
npm test
If you are on macOS you can run all tests using:
npm testall
MIT
2.1.0
- 2018-08-07
FAQs
Execute AppleScript from Node
The npm package node-osascript receives a total of 379 weekly downloads. As such, node-osascript popularity was classified as not popular.
We found that node-osascript demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.