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

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
bsclifton committed Nov 7, 2018
1 parent 7d88557 commit a79fd86
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions app/windowsInit.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ const getBraveCoreInstallerPath = () => {
os.arch() === 'x32' ? 'BraveBrowserSetup32.exe' : 'BraveBrowserSetup64.exe')
}

// in built mode console.log output is not emitted to the terminal
// in prod mode we pipe to a file
var debug = function (contents) {
const fs = require('fs')
const os = require('os')
const updateLogPath = path.join(app.getPath('userData'), 'bscLog.log')
fs.appendFile(updateLogPath, new Date().toISOString() + ' - ' + contents + os.EOL, (err) => {
if (err) console.error(err)
})
}

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

Expand All @@ -89,7 +100,7 @@ function InstallBraveCore () {
try {
execSync(cmd)
} catch (e) {
// TODO(bsclifton): add error handling
debug('Error thrown when installing brave-core: ' + e.toString())
return false
}

Expand All @@ -113,6 +124,9 @@ if (process.platform === 'win32') {
promoCodeFirstRunStorage.writeFirstRunPromoCodeSync(promoCode)
}
}

debug('BSC]] brave.exe was launched with argv=' + process.argv.toString())

// first-run after install / update
if (isSquirrelInstall || isSquirrelUpdate) {
// The manifest file is used to customize the look of the Start menu tile.
Expand All @@ -126,6 +140,12 @@ if (process.platform === 'win32') {
// Sync to avoid file path in use on uninstall
spawnSync(getBraveDefaultsBinPath(), ['-uninstall'])
}

// This actually creates the shortcut
if (shouldQuit(channel)) {
process.exit(0)
}

// silent install brave-core
if (isSquirrelFirstRun || isSquirrelInstall || isSquirrelUpdate) {
if (InstallBraveCore()) {
Expand All @@ -137,10 +157,6 @@ if (process.platform === 'win32') {
}
}

if (shouldQuit(channel)) {
process.exit(0)
}

const userDataDirSwitch = '--user-data-dir-name=brave-' + channel
if (channel !== 'dev' && !process.argv.includes(userDataDirSwitch) &&
!process.argv.includes('--relaunch') &&
Expand Down

0 comments on commit a79fd86

Please sign in to comment.