{"id":20639105,"url":"https://github.com/wtfaremyinitials/osa2","last_synced_at":"2025-04-15T22:51:37.181Z","repository":{"id":57316444,"uuid":"87863909","full_name":"wtfaremyinitials/osa2","owner":"wtfaremyinitials","description":"Interact with Apple's Open Scripting Architecture in node.js","archived":false,"fork":false,"pushed_at":"2018-03-10T23:17:27.000Z","size":43,"stargazers_count":70,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T02:12:20.707Z","etag":null,"topics":["javascript-for-automation","jxa","node","nodejs","osascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wtfaremyinitials.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-10T22:37:03.000Z","updated_at":"2025-03-25T03:42:14.000Z","dependencies_parsed_at":"2022-08-25T21:00:48.561Z","dependency_job_id":null,"html_url":"https://github.com/wtfaremyinitials/osa2","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtfaremyinitials%2Fosa2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtfaremyinitials%2Fosa2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtfaremyinitials%2Fosa2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtfaremyinitials%2Fosa2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wtfaremyinitials","download_url":"https://codeload.github.com/wtfaremyinitials/osa2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249167434,"owners_count":21223505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript-for-automation","jxa","node","nodejs","osascript"],"created_at":"2024-11-16T15:22:28.209Z","updated_at":"2025-04-15T22:51:37.166Z","avatar_url":"https://github.com/wtfaremyinitials.png","language":"JavaScript","funding_links":[],"categories":["Node.js helpers"],"sub_categories":[],"readme":"osa2\n===\n\n![](https://img.shields.io/npm/dm/osa2.svg)\n![](https://img.shields.io/npm/v/osa2.svg)\n![](https://img.shields.io/npm/l/osa2.svg)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n\n\u003e Interact with Apple's Open Scripting Architecture from node.js\n\nThis module provides a Promise interface to macOS's automation and scripting APIs.\n\n`osa2` is intended for use in libraries or full applications. If you're looking\nto write simple automation scripts, check out [jxa](https://www.npmjs.com/package/jxa).\n\nInstallation\n===\n\n```bash\nnpm install osa2 --save\n```\n\nUsage\n===\n\nGet the currently playing iTunes track\n\n```js\nvar osa = require('osa2')\n\nvar track = osa(() =\u003e {\n    return Application('iTunes').currentTrack.name()\n})\n\ntrack().then(console.log).catch(console.error)\n```\n\nShow an alert\n\n```js\nvar osa = require('osa2')\n\nfunction alert(message) {\n    return osa(text =\u003e {\n        var app = Application.currentApplication()\n        app.includeStandardAdditions = true\n        app.displayAlert(text)\n    })(message)\n}\n\nalert('Hello World')\n```\n\nAPI\n===\n\n### Execute code in the JavaScript for Automation environment\n\n`osa(function) -\u003e function`\n\nWraps `function` to be run inside Apple's JavaScript for Automation environment.\n\n**function**\n\nType: `function`\n\nThe code to be run inside the JXA environment. ***NOTE:*** `function` cannot close over variables in a parent's scope.\nPass data as arguments explicitly instead.\n\n**return**\n\nType: `function`\n\nReturns a new function with the same arguments as `function`, but when called\nthe code is run inside the JXA environment. This is done asynchronously,\ntherefore promise is returned.\n\n```js\nvar greet = osa(name =\u003e `Hello from JXA, ${name}!`)\n\ngreet('Will').then(text =\u003e {\n    console.log(text) // Hello from JXA, Will!\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwtfaremyinitials%2Fosa2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwtfaremyinitials%2Fosa2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwtfaremyinitials%2Fosa2/lists"}