index.d.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. export type Options = {
  2. /**
  3. Change the output style.
  4. When `false`, returns the value in a [recompilable source form](https://ss64.com/osx/osascript.html).
  5. @default true
  6. @example
  7. ```
  8. import {runAppleScript} from 'run-applescript';
  9. const result = await runAppleScript('return "unicorn"', {humanReadableOutput: false});
  10. console.log(result);
  11. //=> '"unicorn"'
  12. ```
  13. */
  14. readonly humanReadableOutput?: boolean;
  15. };
  16. /**
  17. Run AppleScript asynchronously.
  18. @param script - The script to run.
  19. @returns The script result.
  20. @example
  21. ```
  22. import {runAppleScript} from 'run-applescript';
  23. const result = await runAppleScript('return "unicorn"');
  24. console.log(result);
  25. //=> 'unicorn'
  26. ```
  27. */
  28. export function runAppleScript(
  29. script: string,
  30. options?: Options
  31. ): Promise<string>;
  32. /**
  33. Run AppleScript synchronously.
  34. @param script - The script to run.
  35. @returns The script result.
  36. @example
  37. ```
  38. import {runAppleScriptSync} from 'run-applescript';
  39. const result = runAppleScriptSync('return "unicorn"');
  40. console.log(result);
  41. //=> 'unicorn'
  42. ```
  43. */
  44. export function runAppleScriptSync(script: string, options?: Options): string;