Refix for Linux

Most of this is fixing things that assume the OS is case insensitive.
This commit is contained in:
T H Hori 2017-12-12 09:19:31 +00:00 committed by GitHub
parent d55d027d69
commit 312e7204bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 7 deletions

View File

@ -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;
@ -34,9 +39,9 @@ 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"));
}
@ -44,7 +49,7 @@ function initStorage() {
bdStorage.get = function(i, m, pn) {
if (typeof bdStorage.data == "undefined") { initStorage(); }
if(m) return bdStorage.data[i] || "";
if(bdPluginStorage[pn] !== undefined) {
@ -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;
@ -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 {
@ -842,4 +847,4 @@ function exit(reason) {
BetterDiscord.prototype.init = function() {}//Compatibility
exports.BetterDiscord = BetterDiscord;
exports.BetterDiscord = BetterDiscord;