Github user TimBarham commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/327#discussion_r42565322
  
    --- Diff: cordova-serve/src/browser.js ---
    @@ -95,16 +105,93 @@ function getBrowser(target, dataDir) {
                 'firefox': 'firefox',
                 'opera': 'opera'
             },
    -        'linux' : {
    -            'chrome': 'google-chrome' + chromeArgs ,
    +        'linux': {
    +            'chrome': 'google-chrome' + chromeArgs,
                 'chromium': 'chromium-browser' + chromeArgs,
                 'firefox': 'firefox',
                 'opera': 'opera'
             }
         };
    -    target = target.toLowerCase();
         if (target in browsers[process.platform]) {
    -        return Q(browsers[process.platform][target]);
    +        var browser = browsers[process.platform][target];
    +        if (process.platform === 'win32') {
    +            // Windows displays a dialog if the browser is not installed. 
We'd prefer to avoid that.
    +            return checkBrowserExistsWindows(browser, 
target).then(function () {
    +                return browser;
    +            });
    +        } else {
    +            return Q(browser);
    +        }
         }
    -    return Q.reject('Browser target not supported: ' + target);
    +    return Q.reject(NOT_SUPPORTED.replace('%target%', target));
    +}
    +
    +function checkBrowserExistsWindows(browser, target) {
    +    var promise = target === 'edge' ? edgeSupported() : 
browserInstalled(browser);
    +    return promise.catch(function (error) {
    +        return Q.reject((error && error.toString() || 
NOT_INSTALLED).replace('%target%', target));
    +    });
    +}
    +
    +function edgeSupported() {
    +    var d = Q.defer();
    +
    +    child_process.exec('ver', function (err, stdout, stderr) {
    --- End diff --
    
    I originally used the exec module and the logic actuallly ended up simpler 
this way. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org

Reply via email to