Skip to content
Snippets Groups Projects
server.js 821 B
Newer Older
  • Learn to ignore specific revisions
  • James Long's avatar
    James Long committed
    require('./setRequireHook');
    require('module').globalPaths.push(__dirname + '/..');
    
    global.fetch = require('node-fetch');
    
    
    // Lazy load backend code
    
    James Long's avatar
    James Long committed
    function getBackend() {
    
      // eslint-disable-next-line import/extensions
    
    James Long's avatar
    James Long committed
      return require('loot-core/lib-dist/bundle.desktop.js');
    }
    
    if (process.argv[2] === '--subprocess') {
      let isDev = false;
    
      // let version = process.argv[3];
    
    James Long's avatar
    James Long committed
      let socketName = process.argv[4];
    
      // Start the app
    
      getBackend().initApp(isDev, socketName);
    
    James Long's avatar
    James Long committed
    } else if (process.argv[2] === '--standalone') {
      require('source-map-support').install();
    
      getBackend().initApp(true, 'actual-standalone');
    
    James Long's avatar
    James Long committed
    } else {
      let { ipcRenderer } = require('electron');
      let isDev = true;
    
      ipcRenderer.on('set-socket', (event, { name }) => {
    
        // Start the app
        getBackend().initApp(isDev, name);
    
    James Long's avatar
    James Long committed
      });
    }