feat(process): add plugin (#348)

This commit is contained in:
Lucas Fernandes Nogueira
2023-05-09 12:00:44 -03:00
committed by GitHub
parent 61e7d6ede5
commit 012d32e8ed
19 changed files with 440 additions and 2 deletions
+45
View File
@@ -0,0 +1,45 @@
// 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-plugin-process-api';
* 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-plugin-process-api';
* 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 };