Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

Get it to install on my Ubuntu box. #543

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Refix for Linux
Most of this is fixing things that assume the OS is case insensitive.
  • Loading branch information
thomas-hori committed Dec 12, 2017
commit 312e7204bfcd820cdbcda7429630959ff5da2061
19 changes: 12 additions & 7 deletions lib/BetterDiscord.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@

var _fs = require("fs");
var _config = require("./config.json");
var _utils = require("./utils");
var _utils;
try {
_utils = require("./utils");
} catch (e) {
_utils = require("./Utils");
}
var _utils2;
var _bdIpc = require('electron').ipcMain;
var _error = false;
Expand All @@ -34,17 +39,17 @@ bdPluginStorage.defaults = {
};

function initStorage() {
if(!_fs.existsSync(_cfg.dataPath + "/bdstorage.json")) {
if(!_fs.existsSync(_cfg.dataPath + "/bdStorage.json")) {
bdStorage.data = bdStorage.defaults.data;
_fs.writeFileSync(_cfg.dataPath + "/bdstorage.json", JSON.stringify(bdStorage, null, 4));
_fs.writeFileSync(_cfg.dataPath + "/bdStorage.json", JSON.stringify(bdStorage, null, 4));
} else {
bdStorage.data = JSON.parse(_fs.readFileSync(_cfg.dataPath + "/bdStorage.json"));
}
};


bdStorage.get = function(i, m, pn) {

if (typeof bdStorage.data == "undefined") { initStorage(); }
if(m) return bdStorage.data[i] || "";

if(bdPluginStorage[pn] !== undefined) {
Expand All @@ -62,7 +67,7 @@ bdStorage.get = function(i, m, pn) {
bdStorage.set = function(i, v, m, pn) {
if(m) {
bdStorage.data[i] = v;
_fs.writeFileSync(_cfg.dataPath + "/bdstorage.json", JSON.stringify(bdStorage.data, null, 4));
_fs.writeFileSync(_cfg.dataPath + "/bdStorage.json", JSON.stringify(bdStorage.data, null, 4));
} else {
if(bdPluginStorage[pn] === undefined) bdPluginStorage[pn] = {};
bdPluginStorage[pn][i] = v;
Expand All @@ -87,7 +92,7 @@ function BetterDiscord(mainWindow) {
function createAndCheckData() {
getUtils().log("Checking data/cache");

_cfg.dataPath = (_cfg.os == 'win32' ? process.env.APPDATA : _cfg.os == 'darwin' ? process.env.HOME + '/Library/Preferences' : '/var/local') + '/BetterDiscord/';
_cfg.dataPath = (_cfg.os == 'win32' ? process.env.APPDATA : _cfg.os == 'darwin' ? process.env.HOME + '/Library/Preferences' : process.env.HOME + '/.config') + '/BetterDiscord/';
_cfg.userFile = _cfg.dataPath + 'user.json';

try {
Expand Down Expand Up @@ -842,4 +847,4 @@ function exit(reason) {

BetterDiscord.prototype.init = function() {}//Compatibility

exports.BetterDiscord = BetterDiscord;
exports.BetterDiscord = BetterDiscord;