/
process.ts
58 lines (53 loc) · 1.37 KB
/
process.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
/**
* Perform operations on the current process.
*
* 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`.
* @module
*/
import { invokeTauriCommand } from './helpers/tauri'
/**
* Exits immediately with the given `exitCode`.
* @example
* ```typescript
* import { exit } from '@tauri-apps/api/process';
* await exit(1);
* ```
*
* @param exitCode The exit code to use.
* @returns A promise indicating the success or failure of the operation.
*
* @since 1.0.0
*/
async function exit(exitCode: number = 0): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Process',
message: {
cmd: 'exit',
exitCode
}
})
}
/**
* Exits the current instance of the app then relaunches it.
* @example
* ```typescript
* import { relaunch } from '@tauri-apps/api/process';
* await relaunch();
* ```
*
* @returns A promise indicating the success or failure of the operation.
*
* @since 1.0.0
*/
async function relaunch(): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Process',
message: {
cmd: 'relaunch'
}
})
}
export { exit, relaunch }