/**
 * Cross-platform "open" utility — launches files/directories in the OS default handler.
 */
import { execFile } from 'child_process';
/** Convert any error thrown by openInEditor into a human-readable string. */
export function formatOpenError(error) {
    return error instanceof Error ? error.message : String(error);
}
/** Open a file or directory in the OS default editor/handler. */
export function openInEditor(path) {
    if (process.platform === 'win32') {
        return new Promise((resolve, reject) => {
            execFile('rundll32.exe', ['url.dll,FileProtocolHandler', path], { windowsHide: true }, (error) => {
                if (error) {
                    reject(error);
                    return;
                }
                resolve();
            });
        });
    }
    const command = process.platform === 'darwin' ? 'open' : 'xdg-open';
    return new Promise((resolve, reject) => {
        execFile(command, [path], (error) => {
            if (error) {
                reject(error);
                return;
            }
            resolve();
        });
    });
}
//# sourceMappingURL=open.js.map