import { exec } from 'child_process';

export const asyncExec = (command: string): Promise<string> => {
  return new Promise((resolve, reject) => {
    exec(command, { maxBuffer: 2048 * 2048 }, (error, stdout, stderr) => {
      if (error) {
        console.error({ error });
        reject({ error, message: 'Something went wrong' });
      }
      resolve(stdout || stderr);
    });
  });
}
