提交学习笔记专用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.2 KiB

  1. # run-applescript
  2. > Run AppleScript and get the result
  3. ## Install
  4. ```sh
  5. npm install run-applescript
  6. ```
  7. ## Usage
  8. ```js
  9. import {runAppleScript} from 'run-applescript';
  10. const result = await runAppleScript('return "unicorn"');
  11. console.log(result);
  12. //=> 'unicorn'
  13. ```
  14. ## API
  15. ### runAppleScript(script, options?)
  16. Returns a `Promise<string>` with the script result.
  17. #### script
  18. Type: `string`
  19. The script to run.
  20. #### options
  21. Type: `object`
  22. ##### humanReadableOutput
  23. Type: `boolean`\
  24. Default: `true`
  25. Change the output style.
  26. When `false`, returns the value in a [recompilable source form](https://ss64.com/osx/osascript.html).
  27. ##### signal
  28. Type: `AbortSignal`
  29. An AbortSignal that can be used to cancel the AppleScript execution.
  30. ### runAppleScriptSync(script, options?)
  31. Returns a `string` with the script result.
  32. #### script
  33. Type: `string`
  34. The script to run.
  35. #### options
  36. Type: `object`
  37. ##### humanReadableOutput
  38. Type: `boolean`\
  39. Default: `true`
  40. Change the output style.
  41. When `false`, returns the value in a [recompilable source form](https://ss64.com/osx/osascript.html).
  42. ## Related
  43. - [run-jxa](https://github.com/sindresorhus/run-jxa) - Run JXA code and get the result