Skip to content

Commit

Permalink
Fix Firefox ESR variant not found
Browse files Browse the repository at this point in the history
  • Loading branch information
jojje committed Jun 10, 2024
1 parent a5807d5 commit f979f6d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ function getPathToExe(hive, appName) {

return getRegistryValue(hive, rootKey, "CurrentVersion").then(function(version) {
return getRegistryValue(hive, path.join(rootKey, version, "Main"), "PathToExe");
}).catch(function() { // fallback on checking for latest version on multi-version or ESR installs
return findLatestVersionExePath(hive, rootKey);
});
}

Expand All @@ -114,6 +116,27 @@ function getRegistryValue(hive, key, name) {
});
}

// ESR is registered using the multi-version scheme; under a subkey: <hive>\SOFTWARE\Mozilla\Mozilla Firefox\<version-key>
// E.g. HKLM\SOFTWARE\Mozilla\Mozilla Firefox\115.11.0 ESR (x64 en-US)
function findLatestVersionExePath(hive, key) {
return when.promise(function(resolve, reject) {
const ffKey = new Winreg({ hive, key });
ffKey.keys(function(error, subKeys) {
if (!error && subKeys.length > 0) {
const latestVersionKey = subKeys.sort(function(a,b) { // reverse sort
return b.path.localeCompare(a.path);
})[0];
const subKeyPath = latestVersionKey.path.replace(hive, ''); // strip the hive prefix so we can re-use getRegistryValue
resolve(getRegistryValue(hive, path.join(subKeyPath, "Main"), "PathToExe"))
} else if (!error) {
reject("No Firefox version sub-keys found under: " + ffKey.path);
} else {
reject(error);
}
});
});
}

normalizeBinary.paths = {
"firefox on osx": "/Applications/Firefox.app/Contents/MacOS/firefox",
// the name of the beta application bundle is the same as the stable one
Expand Down

0 comments on commit f979f6d

Please sign in to comment.