mirror of
https://github.com/tauri-apps/tauri-plugin-process.git
synced 2026-01-31 00:55:17 +01:00
Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de> Committed via a GitHub action: https://github.com/tauri-apps/plugins-workspace/actions/runs/5038084282 Co-authored-by: lucasfernog <lucasfernog@users.noreply.github.com>
46 lines
1.0 KiB
TypeScript
46 lines
1.0 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
|
|
*/
|
|
|
|
import { invoke } from "@tauri-apps/api/tauri";
|
|
|
|
/**
|
|
* 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 1.0.0
|
|
*/
|
|
async function exit(code = 0): Promise<void> {
|
|
return 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 1.0.0
|
|
*/
|
|
async function relaunch(): Promise<void> {
|
|
return invoke("plugin:process|restart");
|
|
}
|
|
|
|
export { exit, relaunch };
|