Skip to content

Commit

Permalink
Speed up servers.json loading
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Nov 16, 2018
1 parent 2f8ad44 commit 5d13d0c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/scripts/servers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* globals $ */

import jetpack from 'fs-jetpack';
import { EventEmitter } from 'events';
import { remote, ipcRenderer } from 'electron';
Expand Down Expand Up @@ -77,8 +75,11 @@ class Servers extends EventEmitter {

// Load server info from server config file
if (Object.keys(hosts).length === 0) {
const path = jetpack.find(remote.app.getPath('userData'), { matching: 'servers.json' })[0] ||
jetpack.find(jetpack.path(remote.app.getAppPath(), '..'), { matching: 'servers.json' })[0];
const { app } = remote;
const userDir = jetpack.cwd(app.getPath('userData'));
const appDir = jetpack.cwd(jetpack.path(app.getAppPath(), app.getAppPath().endsWith('.asar') ? '..' : '.'));
const path = userDir.find({ matching: 'servers.json', recursive: false })[0] ||
appDir.find({ matching: 'servers.json', recursive: false })[0];

if (path) {
const pathToServerJson = jetpack.path(path);
Expand Down

0 comments on commit 5d13d0c

Please sign in to comment.