mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-23 11:36:13 +02:00
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
// 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.
|
|
* @module
|
|
*/
|
|
|
|
declare global {
|
|
interface Window {
|
|
__TAURI_INVOKE__: <T>(cmd: string, args?: unknown) => Promise<T>;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Exits immediately with the given `exitCode`.
|
|
* @example
|
|
* ```typescript
|
|
* import { exit } from '@tauri-apps/plugin-process';
|
|
* await exit(1);
|
|
* ```
|
|
*
|
|
* @param code The exit code to use.
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
*
|
|
* @since 2.0.0
|
|
*/
|
|
async function exit(code = 0): Promise<void> {
|
|
return window.__TAURI_INVOKE__("plugin:process|exit", { code });
|
|
}
|
|
|
|
/**
|
|
* Exits the current instance of the app then relaunches it.
|
|
* @example
|
|
* ```typescript
|
|
* import { relaunch } from '@tauri-apps/plugin-process';
|
|
* await relaunch();
|
|
* ```
|
|
*
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
*
|
|
* @since 2.0.0
|
|
*/
|
|
async function relaunch(): Promise<void> {
|
|
return window.__TAURI_INVOKE__("plugin:process|restart");
|
|
}
|
|
|
|
export { exit, relaunch };
|