You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2018/12/19 10:12:02 UTC
[cordova-serve] branch master updated: CB-14198: (all) Fix bug when
running simulate --target= under non-US Windows 10 (#14)
This is an automated email from the ASF dual-hosted git repository.
erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-serve.git
The following commit(s) were added to refs/heads/master by this push:
new 7a9c60f CB-14198: (all) Fix bug when running simulate --target= under non-US Windows 10 (#14)
7a9c60f is described below
commit 7a9c60ff8531c6b3b553577e844020305e3ebdb0
Author: Yuri Skorokhodov <yu...@yandex.ru>
AuthorDate: Wed Dec 19 13:11:57 2018 +0300
CB-14198: (all) Fix bug when running simulate --target= under non-US Windows 10 (#14)
* CB-14198: (all) Fix bug when running simulate --target= under non-US Windows 10
- change regex to parse stdout from reg.exe for browser recognition to be language independent
- Add tests for regItemPattern check, enhanced regexp pattern to avoid regression in the future
- Add "var" keyword to the "result" variable declaration
- Add test for non-latin registry key (Russian)
---
spec/browser.spec.js | 19 +++++++++++++++++++
src/browser.js | 2 +-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/spec/browser.spec.js b/spec/browser.spec.js
index 14bcc72..ccd0307 100644
--- a/spec/browser.spec.js
+++ b/spec/browser.spec.js
@@ -18,6 +18,7 @@ var child_process = require('child_process');
var rewire = require('rewire');
var browser = rewire("../src/browser");
+var regItemPattern = browser.__get__("regItemPattern");
function expectPromise(obj){
// 3 slightly different ways of verifying a promise
@@ -75,4 +76,22 @@ describe('browser', function() {
done(err);
});
});
+
+ it('should recognize browser from registry with key "Default" on English Windows 10', function(done) {
+ var result = regItemPattern.exec("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.EXE (Default) REG_SZ C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
+ expect(result[2]).toBe("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe")
+ done();
+ });
+
+ it('should recognize browser from registry with key "Standard" on non-English Windows 10', function(done) {
+ var result = regItemPattern.exec("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.EXE (Standard) REG_SZ C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
+ expect(result[2]).toBe("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe")
+ done();
+ });
+
+ it('should recognize browser with non-Latin registry key on Russian Windows 10', function(done) {
+ var result = regItemPattern.exec("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.EXE (�� 㬮�砭��) REG_SZ C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
+ expect(result[2]).toBe("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe")
+ done();
+ });
});
diff --git a/src/browser.js b/src/browser.js
index 289ac68..6d13f3a 100644
--- a/src/browser.js
+++ b/src/browser.js
@@ -199,7 +199,7 @@ function edgeSupported () {
return prom;
}
-var regItemPattern = /\s*\(Default\)\s+(REG_SZ)\s+([^\s].*)\s*/;
+var regItemPattern = /\s*\([^)]+\)\s+(REG_SZ)\s+([^\s].*)\s*/;
function browserInstalled (browser) {
// On Windows, the 'start' command searches the path then 'App Paths' in the registry.
// We do the same here. Note that the start command uses the PATHEXT environment variable
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org