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

Commit

Permalink
Automate brave-core install for Windows. Includes an updated Squirrel…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
bsclifton committed Nov 7, 2018
1 parent 646212b commit f0e6054
Show file tree
Hide file tree
Showing 10 changed files with 3,690 additions and 3,659 deletions.
45 changes: 45 additions & 0 deletions app/windowsInit.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,41 @@ function CopyManifestFile () {
execSync(cmd)
}

const getBraveCoreInstallerPath = () => {
const os = require('os')
const appDir = getBraveBinPath()
return path.join(appDir, 'resources',
os.arch() === 'x32' ? 'BraveBrowserSetup32.exe' : 'BraveBrowserSetup64.exe')
}

function InstallBraveCore () {
const fs = require('fs')

// expected install paths
const braveCoreInstallLocations = [
'%USERPROFILE%\\AppData\\Local\\BraveSoftware\\Brave-Browser\\Application',
'%ProgramFiles(x86)%\\BraveSoftware\\Brave-Browser\\Application',
'%ProgramFiles%\\BraveSoftware\\Brave-Browser\\Application'
]

// check for existing installations
for (let i=0; i < braveCoreInstallLocations.length; i++) {
const path = braveCoreInstallLocations[i]
const resolvedPath = path.replace(/%([^%]+)%/g, function(_, variableToResolve) {
return process.env[variableToResolve]
})
if (fs.existsSync(resolvedPath)) {
return false
}
}

// brave-core is not installed; go ahead with silent install
const cmd = getBraveCoreInstallerPath() + " /silent /install"
execSync(cmd)

return true
}

// windows installation events etc...
if (process.platform === 'win32') {
const shouldQuit = require('electron-squirrel-startup')
Expand Down Expand Up @@ -86,6 +121,16 @@ if (process.platform === 'win32') {
// Sync to avoid file path in use on uninstall
spawnSync(getBraveDefaultsBinPath(), ['-uninstall'])
}
// silent install brave-core
if (isSquirrelFirstRun || isSquirrelInstall || isSquirrelUpdate) {
if (InstallBraveCore()) {
// relaunch and append argument expected in:
// https://github.com/brave/brave-browser/issues/1545
app.relaunch({args: ['--relaunch', '--upgrade-from-muon']})
app.exit()
return
}
}

if (shouldQuit(channel)) {
process.exit(0)
Expand Down
Loading

0 comments on commit f0e6054

Please sign in to comment.