module.exports = function()

in src/browser.js [40:102]


module.exports = function (opts) {
    opts = opts || {};
    let target = opts.target || 'default';
    const url = opts.url || '';

    target = target.toLowerCase();
    if (target === 'default') {
        open(url);
        return Promise.resolve();
    } else {
        return getBrowser(target, opts.dataDir).then(browser => {
            let args;
            let urlAdded = false;

            switch (process.platform) {
            case 'darwin':
                args = ['open'];
                if (target === 'chrome') {
                    // Chrome needs to be launched in a new window. Other browsers, particularly, opera does not work with this.
                    args.push('-n');
                }
                args.push('-a', browser);
                break;
            case 'win32':
                // On Windows, we really want to use the "start" command. But, the rules regarding arguments with spaces, and
                // escaping them with quotes, can get really arcane. So the easiest way to deal with this is to pass off the
                // responsibility to "cmd /c", which has that logic built in.
                //
                // Furthermore, if "cmd /c" double-quoted the first parameter, then "start" will interpret it as a window title,
                // so we need to add a dummy empty-string window title: http://stackoverflow.com/a/154090/3191

                if (target === 'edge') {
                    browser += `:${url}`;
                    urlAdded = true;
                }

                args = ['cmd /c start ""', browser];
                break;
            case 'linux':
                // if a browser is specified, launch it with the url as argument
                // otherwise, use xdg-open.
                args = [browser];
                break;
            }

            if (!urlAdded) {
                args.push(url);
            }
            const command = args.join(' ');
            const result = exec(command);
            result.catch(() => {
                // Assume any error means that the browser is not installed and display that as a more friendly error.
                throw new Error(NOT_INSTALLED.replace('%target%', target));
            });
            return result;

            // return exec(command).catch(function (error) {
            //     // Assume any error means that the browser is not installed and display that as a more friendly error.
            //     throw new Error(NOT_INSTALLED.replace('%target%', target));
            // });
        });
    }
};