process.ts 510 B

123456789101112131415161718192021222324
  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(command: string, args?: string | string[]): Promise<string> {
  10. if (typeof args === 'object') {
  11. Object.freeze(args)
  12. }
  13. return await promisified({
  14. cmd: 'execute',
  15. command,
  16. args: typeof args === 'string' ? [args] : args
  17. })
  18. }
  19. export {
  20. execute
  21. }