2020-06-27 18:20:00 +03:00
|
|
|
import { promisified } from './tauri'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* spawns a process
|
|
|
|
*
|
|
|
|
* @param command the name of the cmd to execute e.g. 'mkdir' or 'node'
|
|
|
|
* @param [args] command args
|
|
|
|
* @return promise resolving to the stdout text
|
|
|
|
*/
|
2020-08-19 05:36:46 +03:00
|
|
|
async function execute(
|
|
|
|
command: string,
|
|
|
|
args?: string | string[]
|
|
|
|
): Promise<string> {
|
2020-06-27 18:20:00 +03:00
|
|
|
if (typeof args === 'object') {
|
|
|
|
Object.freeze(args)
|
|
|
|
}
|
|
|
|
|
|
|
|
return await promisified({
|
|
|
|
cmd: 'execute',
|
|
|
|
command,
|
|
|
|
args: typeof args === 'string' ? [args] : args
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-08-19 05:36:46 +03:00
|
|
|
export { execute }
|