From 38f2c32132f2eb469d4f8b7296df82634f88b847 Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Fri, 22 Nov 2019 18:30:23 +0100 Subject: [PATCH] Improve detection of Chrome channel variants (#61) * Improve detection of Chrome channel variants * Breaking: remove 'bitness' from chrome metadata * Refactor Chrome channel registry detection to a separate function --- cli.js | 6 +++--- lib/browsers.js | 6 +++++- lib/chrome/find-progids.js | 14 ++++++++++++-- lib/chrome/find-update-clients.js | 6 ++++-- lib/finder.js | 1 - readme.md | 3 --- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/cli.js b/cli.js index 60726f4..2c4d7cb 100644 --- a/cli.js +++ b/cli.js @@ -59,9 +59,9 @@ detect(argv._, argv, function (err, browsers, methods) { labels.push(b.channel.toUpperCase()) } - if (b.arch === 'amd64' || b.bitness === 64) { + if (b.arch === 'amd64') { labels.push('64-bit') - } else if (b.arch === 'i386' || b.bitness === 32) { + } else if (b.arch === 'i386') { labels.push('32-bit') } @@ -108,7 +108,7 @@ function ordered (a) { const remaining = new Set(Object.keys(a)) const objects = [] - for (const k of ['name', 'path', 'version', 'channel', 'arch', 'bitness']) { + for (const k of ['name', 'path', 'version', 'channel', 'arch']) { if (k in a) { b[k] = a[k] remaining.delete(k) diff --git a/lib/browsers.js b/lib/browsers.js index 096aa54..4c6315f 100644 --- a/lib/browsers.js +++ b/lib/browsers.js @@ -6,13 +6,17 @@ exports.chrome = { find: function () { // Joined with filename (or [browser name].exe) this.dir('LOCALAPPDATA', 'Google\\Chrome\\Application') - + this.dir('LOCALAPPDATA', 'Google\\Chrome Beta\\Application') + this.dir('LOCALAPPDATA', 'Google\\Chrome Dev\\Application') // Chrome Canary this.dir('LOCALAPPDATA', 'Google\\Chrome SxS\\Application') // programFiles() is a shortcut to dir() that checks both // "Program Files" and "Program Files (x86)" if on 64-bit Windows this.programFiles('Google\\Chrome\\Application') + this.programFiles('Google\\Chrome Beta\\Application') + this.programFiles('Google\\Chrome Dev\\Application') + this.programFiles('Google\\Chrome SxS\\Application') // Expanded to HKEY_LOCAL_MACHINE\Software, HKEY_CURRENT_USER\Software // and if on a x64 machine, their 32-bit (Software\WoW6432) counterparts. diff --git a/lib/chrome/find-progids.js b/lib/chrome/find-progids.js index 4552f5c..9940f4d 100644 --- a/lib/chrome/find-progids.js +++ b/lib/chrome/find-progids.js @@ -29,7 +29,7 @@ function queryHive (self, hive, done) { if (err) return next(err.notFound ? null : err) const metadata = { - channel: id === 'ChromeHTML' ? 'stable' : 'canary' + channel: getChromeChannel(id) } self.found(extractPath(bin), metadata, key, next) @@ -39,5 +39,15 @@ function queryHive (self, hive, done) { } function isChromeHTML (id) { - return id === 'ChromeHTML' || id.slice(0, 12) === 'ChromeSSHTM.' + return id === 'ChromeHTML' || + id === 'ChromeBHTML' || + id === 'ChromeDHTML' || + id.slice(0, 12) === 'ChromeSSHTM.' +} + +function getChromeChannel (id) { + if (id.startsWith('ChromeSSHTM.')) return 'canary' + if (id === 'ChromeBHTML') return 'beta' + if (id === 'ChromeDHTML') return 'dev' + return null // Unknown or ChromeHTML (which can be ambiguous) } diff --git a/lib/chrome/find-update-clients.js b/lib/chrome/find-update-clients.js index dc54fde..c702a96 100644 --- a/lib/chrome/find-update-clients.js +++ b/lib/chrome/find-update-clients.js @@ -7,12 +7,15 @@ const { basename, resolve, dirname } = require('path') const registry = require('../registry') const GUIDS = [ + '401C381F-E0DE-4B85-8BD8-3F3F14FBDA57', // dev + '8237E44A-0054-442C-B6B6-EA0509993955', // beta '8A69D345-D564-463C-AFF1-A69D9E530F96', // 32 '4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D', // 64 '4EA16AC7-FD5A-47C3-875B-DBF4A2008C20' // canary ] const CHANNELS = [ + 'stable', 'canary', 'beta', 'dev' @@ -45,7 +48,6 @@ function queryState (self, hive, guid, inWoW, done) { const metadata = { channel: getReleaseChannel(ap), - bitness: ap.has('x64') ? 64 : 32, guid } @@ -91,5 +93,5 @@ function getReleaseChannel (ap) { if (ap.has(channel)) return channel } - return 'stable' + return null } diff --git a/lib/finder.js b/lib/finder.js index 59c2684..44f6e96 100644 --- a/lib/finder.js +++ b/lib/finder.js @@ -194,7 +194,6 @@ Finder.prototype.found = function (bin, metadata, method, cb, _skipPre) { if (metadata) { if (metadata.channel) debugName.push(`(${metadata.channel})`) - if (metadata.bitness) debugName.push(`(${metadata.bitness})`) } debug('Found %s:\n - %s\n @ %s', debugName.join(' '), bin, method) diff --git a/readme.md b/readme.md index 7a14796..eb3b131 100644 --- a/readme.md +++ b/readme.md @@ -68,7 +68,6 @@ Additional properties are usually available but not guaranteed: - `uninstall` (object): Chrome only. Uninstaller info with: - `path` (string): path to installer; - `arguments` (array): arguments to installer in order to uninstall. -- `bitness` (number): Chrome only. 64 or 32. - `guid` (string): Chrome only. ## CLI @@ -234,7 +233,6 @@ On Windows 10 with `--json`: "version": "68.0.3436.0", "channel": "canary", "arch": "amd64", - "bitness": 64, "guid": "4EA16AC7-FD5A-47C3-875B-DBF4A2008C20", "info": { "FileVersion": "68.0.3436.0", @@ -264,7 +262,6 @@ On Windows 10 with `--json`: "version": "66.0.3359.181", "channel": "stable", "arch": "amd64", - "bitness": 64, "guid": "8A69D345-D564-463C-AFF1-A69D9E530F96", "info": { "FileVersion": "66.0.3359.181",