process.ts 797 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2019-2021 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. import { invokeTauriCommand } from './helpers/tauri'
  5. /**
  6. * Exits immediately with the given `exitCode`.
  7. *
  8. * @param exitCode The exit code to use
  9. * @returns
  10. */
  11. async function exit(exitCode: number = 0): Promise<void> {
  12. return invokeTauriCommand({
  13. __tauriModule: 'Process',
  14. mainThread: true,
  15. message: {
  16. cmd: 'exit',
  17. exitCode
  18. }
  19. })
  20. }
  21. /**
  22. * Exits the current instance of the app then relaunches it.
  23. *
  24. * @returns
  25. */
  26. async function relaunch(): Promise<void> {
  27. return invokeTauriCommand({
  28. __tauriModule: 'Process',
  29. mainThread: true,
  30. message: {
  31. cmd: 'relaunch'
  32. }
  33. })
  34. }
  35. export { exit, relaunch }