Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.

Commit f0e6054

Browse files
committed
Automate brave-core install for Windows. Includes an updated Squirrel stub executable.
Fixes brave/brave-browser#1540 Fixes brave/brave-browser#1782 - Stub executable detects brave-core and will launch it (instead of browser-laptop) - Friendly name of app (as shown in Add/Remove programs and Default app settings) to `Brave (old)` - Dependencies updated
1 parent 646212b commit f0e6054

10 files changed

+3690
-3659
lines changed

app/windowsInit.js

+45
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,41 @@ function CopyManifestFile () {
5656
execSync(cmd)
5757
}
5858

59+
const getBraveCoreInstallerPath = () => {
60+
const os = require('os')
61+
const appDir = getBraveBinPath()
62+
return path.join(appDir, 'resources',
63+
os.arch() === 'x32' ? 'BraveBrowserSetup32.exe' : 'BraveBrowserSetup64.exe')
64+
}
65+
66+
function InstallBraveCore () {
67+
const fs = require('fs')
68+
69+
// expected install paths
70+
const braveCoreInstallLocations = [
71+
'%USERPROFILE%\\AppData\\Local\\BraveSoftware\\Brave-Browser\\Application',
72+
'%ProgramFiles(x86)%\\BraveSoftware\\Brave-Browser\\Application',
73+
'%ProgramFiles%\\BraveSoftware\\Brave-Browser\\Application'
74+
]
75+
76+
// check for existing installations
77+
for (let i=0; i < braveCoreInstallLocations.length; i++) {
78+
const path = braveCoreInstallLocations[i]
79+
const resolvedPath = path.replace(/%([^%]+)%/g, function(_, variableToResolve) {
80+
return process.env[variableToResolve]
81+
})
82+
if (fs.existsSync(resolvedPath)) {
83+
return false
84+
}
85+
}
86+
87+
// brave-core is not installed; go ahead with silent install
88+
const cmd = getBraveCoreInstallerPath() + " /silent /install"
89+
execSync(cmd)
90+
91+
return true
92+
}
93+
5994
// windows installation events etc...
6095
if (process.platform === 'win32') {
6196
const shouldQuit = require('electron-squirrel-startup')
@@ -86,6 +121,16 @@ if (process.platform === 'win32') {
86121
// Sync to avoid file path in use on uninstall
87122
spawnSync(getBraveDefaultsBinPath(), ['-uninstall'])
88123
}
124+
// silent install brave-core
125+
if (isSquirrelFirstRun || isSquirrelInstall || isSquirrelUpdate) {
126+
if (InstallBraveCore()) {
127+
// relaunch and append argument expected in:
128+
// https://github.com/brave/brave-browser/issues/1545
129+
app.relaunch({args: ['--relaunch', '--upgrade-from-muon']})
130+
app.exit()
131+
return
132+
}
133+
}
89134

90135
if (shouldQuit(channel)) {
91136
process.exit(0)

0 commit comments

Comments
 (0)