|
|
|
|
|
const path = require( 'path' ); |
|
|
const { app } = require( 'electron' ); |
|
|
const { mkdirSync } = require( 'fs' ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const state = require( './lib/state' ); |
|
|
const config = require( './lib/config' ); |
|
|
const appData = path.join( app.getPath( 'appData' ), config.appPathName ); |
|
|
|
|
|
|
|
|
const logPath = process.env.WP_DEBUG_LOG |
|
|
? process.env.WP_DEBUG_LOG |
|
|
: path.join( appData, 'logs', 'wpdesktop-main.log' ); |
|
|
mkdirSync( path.dirname( logPath ), { recursive: true } ); |
|
|
state.setLogPath( logPath ); |
|
|
|
|
|
|
|
|
const Settings = require( './lib/settings' ); |
|
|
|
|
|
|
|
|
|
|
|
require( './app-handlers/exceptions' )(); |
|
|
|
|
|
|
|
|
let apppath = app.getAppPath(); |
|
|
if ( path.extname( apppath ) === '.asar' ) { |
|
|
apppath = path.dirname( apppath ); |
|
|
} |
|
|
process.chdir( apppath ); |
|
|
|
|
|
|
|
|
app.setPath( 'userData', appData ); |
|
|
|
|
|
|
|
|
app.allowRendererProcessReuse = true; |
|
|
|
|
|
|
|
|
if ( process.platform === 'linux' ) { |
|
|
app.disableHardwareAcceleration(); |
|
|
} |
|
|
|
|
|
|
|
|
app.enableSandbox(); |
|
|
|
|
|
if ( Settings.isDebug() ) { |
|
|
process.env.DEBUG = config.debug.namespace; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const log = require( './lib/logger' )( 'desktop:boot' ); |
|
|
log.info( `Booting ${ config.appPathName + ' v' + config.version }` ); |
|
|
log.info( `App Path: ${ app.getAppPath() }` ); |
|
|
log.info( `App Data: ${ app.getPath( 'userData' ) }` ); |
|
|
log.info( 'Settings:', Settings._getAll() ); |
|
|
|
|
|
if ( Settings.getSetting( 'proxy-type' ) === '' ) { |
|
|
log.info( 'Proxy: none' ); |
|
|
app.commandLine.appendSwitch( 'no-proxy-server' ); |
|
|
} else if ( Settings.getSetting( 'proxy-type' ) === 'custom' ) { |
|
|
log.info( |
|
|
'Proxy: ' + Settings.getSetting( 'proxy-url' ) + ':' + Settings.getSetting( 'proxy-port' ) |
|
|
); |
|
|
app.commandLine.appendSwitch( |
|
|
'proxy-server', |
|
|
Settings.getSetting( 'proxy-url' ) + ':' + Settings.getSetting( 'proxy-port' ) |
|
|
); |
|
|
|
|
|
if ( Settings.getSetting( 'proxy-pac' ) !== '' ) { |
|
|
log.info( 'Proxy PAC: ' + Settings.getSetting( 'proxy-pac' ) ); |
|
|
|
|
|
|
|
|
app.commandLine.appendSwitch( 'proxy-pac-url', Settings.getSetting( 'proxy-pac' ) ); |
|
|
} |
|
|
} |
|
|
|