Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Firefox ESR variant not found on Windows (fix #112) #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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