cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vladimir-kotikov <...@git.apache.org>
Subject [GitHub] cordova-lib pull request: On Windows, verify browsers installed be...
Date Tue, 20 Oct 2015 22:41:21 GMT
Github user vladimir-kotikov commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/327#discussion_r42564428
  
    --- 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 --
    
    Is there any chance to reuse `./exec` module here. Looks like it contains almost the same
logic.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message