process.cjs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 'use strict';
  2. var tauri = require('./helpers/tauri.cjs');
  3. // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
  4. // SPDX-License-Identifier: Apache-2.0
  5. // SPDX-License-Identifier: MIT
  6. /**
  7. * Perform operations on the current process.
  8. *
  9. * This package is also accessible with `window.__TAURI__.process` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
  10. * @module
  11. */
  12. /**
  13. * Exits immediately with the given `exitCode`.
  14. * @example
  15. * ```typescript
  16. * import { exit } from '@tauri-apps/api/process';
  17. * await exit(1);
  18. * ```
  19. *
  20. * @param exitCode The exit code to use.
  21. * @returns A promise indicating the success or failure of the operation.
  22. *
  23. * @since 1.0.0
  24. */
  25. async function exit(exitCode = 0) {
  26. return tauri.invokeTauriCommand({
  27. __tauriModule: 'Process',
  28. message: {
  29. cmd: 'exit',
  30. exitCode
  31. }
  32. });
  33. }
  34. /**
  35. * Exits the current instance of the app then relaunches it.
  36. * @example
  37. * ```typescript
  38. * import { relaunch } from '@tauri-apps/api/process';
  39. * await relaunch();
  40. * ```
  41. *
  42. * @returns A promise indicating the success or failure of the operation.
  43. *
  44. * @since 1.0.0
  45. */
  46. async function relaunch() {
  47. return tauri.invokeTauriCommand({
  48. __tauriModule: 'Process',
  49. message: {
  50. cmd: 'relaunch'
  51. }
  52. });
  53. }
  54. exports.exit = exit;
  55. exports.relaunch = relaunch;