/**
 * Shell Utility
 *
 * Run shell commands with proper error handling
 */
import { spawn } from 'child_process';
/**
 * Run a shell command and return a promise
 */
export async function runCommand(cmd, options = {}) {
    const { cwd = process.cwd(), silent = false, env } = options;
    return new Promise((resolve, reject) => {
        const proc = spawn(cmd, {
            cwd,
            stdio: silent ? 'pipe' : 'inherit',
            shell: true,
            env: env || process.env,
        });
        proc.on('close', (code) => {
            if (code === 0) {
                resolve();
            }
            else {
                reject(new Error(`Command failed with exit code ${code}: ${cmd}`));
            }
        });
        proc.on('error', (err) => {
            reject(new Error(`Failed to run command: ${cmd}\n${err.message}`));
        });
    });
}
//# sourceMappingURL=shell.js.map