Cleanup init.js
This commit is contained in:
parent
8f62e79243
commit
892026458d
1 changed files with 11 additions and 21 deletions
|
@ -65,7 +65,7 @@ process.on('uncaughtException', function (error) {
|
|||
})
|
||||
|
||||
// Emit 'exit' event on quit.
|
||||
var app = require('electron').app
|
||||
const {app} = require('electron')
|
||||
|
||||
app.on('quit', function (event, exitCode) {
|
||||
process.emit('exit', exitCode)
|
||||
|
@ -86,15 +86,12 @@ if (process.platform === 'win32') {
|
|||
// form `com.squirrel.PACKAGE-NAME.OUREXE`. We need to call
|
||||
// app.setAppUserModelId with a matching identifier so that renderer processes
|
||||
// will inherit this value.
|
||||
var updateDotExe = path.join(
|
||||
path.dirname(process.execPath),
|
||||
'..',
|
||||
'update.exe')
|
||||
const updateDotExe = path.join(path.dirname(process.execPath), '..', 'update.exe')
|
||||
|
||||
if (fs.statSyncNoException(updateDotExe)) {
|
||||
var packageDir = path.dirname(path.resolve(updateDotExe))
|
||||
var packageName = path.basename(packageDir).replace(/\s/g, '')
|
||||
var exeName = path.basename(process.execPath).replace(/\.exe$/i, '').replace(/\s/g, '')
|
||||
if (fs.existsSync(updateDotExe)) {
|
||||
const packageDir = path.dirname(path.resolve(updateDotExe))
|
||||
const packageName = path.basename(packageDir).replace(/\s/g, '')
|
||||
const exeName = path.basename(process.execPath).replace(/\.exe$/i, '').replace(/\s/g, '')
|
||||
|
||||
app.setAppUserModelId(`com.squirrel.${packageName}.${exeName}`)
|
||||
}
|
||||
|
@ -108,15 +105,13 @@ require('./rpc-server')
|
|||
|
||||
// Load the guest view manager.
|
||||
require('./guest-view-manager')
|
||||
|
||||
require('./guest-window-manager')
|
||||
|
||||
// Now we try to load app's package.json.
|
||||
var packageJson = null
|
||||
var searchPaths = ['app', 'app.asar', 'default_app.asar']
|
||||
var i, len, packagePath
|
||||
for (i = 0, len = searchPaths.length; i < len; i++) {
|
||||
packagePath = searchPaths[i]
|
||||
let packagePath = null
|
||||
let packageJson = null
|
||||
const searchPaths = ['app', 'app.asar', 'default_app.asar']
|
||||
for (packagePath of searchPaths) {
|
||||
try {
|
||||
packagePath = path.join(process.resourcesPath, packagePath)
|
||||
packageJson = require(path.join(packagePath, 'package.json'))
|
||||
|
@ -157,14 +152,9 @@ if (packageJson.v8Flags != null) {
|
|||
v8.setFlagsFromString(packageJson.v8Flags)
|
||||
}
|
||||
|
||||
// Chrome 42 disables NPAPI plugins by default, reenable them here
|
||||
app.commandLine.appendSwitch('enable-npapi')
|
||||
|
||||
// Set the user path according to application's name.
|
||||
app.setPath('userData', path.join(app.getPath('appData'), app.getName()))
|
||||
|
||||
app.setPath('userCache', path.join(app.getPath('cache'), app.getName()))
|
||||
|
||||
app.setAppPath(packagePath)
|
||||
|
||||
// Load the chrome extension support.
|
||||
|
@ -177,7 +167,7 @@ require('./desktop-capturer')
|
|||
require('./api/protocol')
|
||||
|
||||
// Set main startup script of the app.
|
||||
var mainStartupScript = packageJson.main || 'index.js'
|
||||
const mainStartupScript = packageJson.main || 'index.js'
|
||||
|
||||
// Finally load app's main.js and transfer control to C++.
|
||||
Module._load(path.join(packagePath, mainStartupScript), Module, true)
|
||||
|
|
Loading…
Reference in a new issue