Skip to content

Commit

Permalink
Improve detection of Chrome channel variants (#61)
Browse files Browse the repository at this point in the history
* Improve detection of Chrome channel variants
* Breaking: remove 'bitness' from chrome metadata
* Refactor Chrome channel registry detection to a separate function
  • Loading branch information
pimterry authored and vweevers committed Nov 22, 2019
1 parent 3cc4100 commit 38f2c32
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
6 changes: 3 additions & 3 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion lib/browsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 12 additions & 2 deletions lib/chrome/find-progids.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
6 changes: 4 additions & 2 deletions lib/chrome/find-update-clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -45,7 +48,6 @@ function queryState (self, hive, guid, inWoW, done) {

const metadata = {
channel: getReleaseChannel(ap),
bitness: ap.has('x64') ? 64 : 32,
guid
}

Expand Down Expand Up @@ -91,5 +93,5 @@ function getReleaseChannel (ap) {
if (ap.has(channel)) return channel
}

return 'stable'
return null
}
1 change: 0 additions & 1 deletion lib/finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 38f2c32

Please sign in to comment.