process.ts 514 B

12345678910111213141516171819202122232425
  1. import { promisified } from './tauri'
  2. /**
  3. * spawns a process
  4. *
  5. * @param command the name of the cmd to execute e.g. 'mkdir' or 'node'
  6. * @param [args] command args
  7. * @return promise resolving to the stdout text
  8. */
  9. async function execute(
  10. command: string,
  11. args?: string | string[]
  12. ): Promise<string> {
  13. if (typeof args === 'object') {
  14. Object.freeze(args)
  15. }
  16. return await promisified({
  17. cmd: 'execute',
  18. command,
  19. args: typeof args === 'string' ? [args] : args
  20. })
  21. }
  22. export { execute }