1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-09 08:45:55 +02:00
joplin/ElectronClient/main.js

41 lines
1.3 KiB
JavaScript
Raw Normal View History

// This is the basic initialization for the Electron MAIN process
2017-11-03 20:01:24 +02:00
// Make it possible to require("/lib/...") without specifying full path
require('app-module-path').addPath(__dirname);
2017-11-03 01:26:08 +02:00
const electronApp = require('electron').app;
const { ElectronAppWrapper } = require('./ElectronAppWrapper');
const { initBridge } = require('./bridge');
2017-11-14 12:53:18 +02:00
const { Logger } = require('lib/logger.js');
const { FsDriverNode } = require('lib/fs-driver-node.js');
const envFromArgs = require('./envFromArgs');
2017-11-03 01:26:08 +02:00
process.on('unhandledRejection', (reason, p) => {
console.error('Unhandled promise rejection', p, 'reason:', reason);
process.exit(1);
});
// Likewise, we want to know if a profile is specified early, in particular
// to save the window state data.
function profileFromArgs(args) {
if (!args) return null;
const profileIndex = args.indexOf('--profile');
if (profileIndex <= 0 || profileIndex >= args.length - 1) return null;
const profileValue = args[profileIndex + 1];
return profileValue ? profileValue : null;
}
2017-11-14 12:53:18 +02:00
Logger.fsDriver_ = new FsDriverNode();
const env = envFromArgs(process.argv);
const profilePath = profileFromArgs(process.argv);
const wrapper = new ElectronAppWrapper(electronApp, env, profilePath);
initBridge(wrapper);
wrapper.start().catch((error) => {
console.error('Electron App fatal error:');
console.error(error);
});