Skip to content

Commit

Permalink
Write to appdata rather than application path
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshulse committed Dec 31, 2017
1 parent 1805246 commit a10f95f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 11 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ const username = require('username');
const request = require('request');
const randomstring = require('randomstring');
const fs = require('fs');
const mkdirp = require('mkdirp');

if (fs.existsSync('hashkey.txt')) {
global.hashKey = fs.readFileSync('hashkey.txt', 'utf-8');
let appDataPath = path.join(app.getAppPath('appData'), 'sc2replaystats');

mkdirp.sync(appDataPath);

let hashKeyPath = path.join(appDataPath, 'hashkey.txt');

if (fs.existsSync(hashKeyPath)) {

global.hashKey = fs.readFileSync(hashKeyPath, 'utf-8');
} else {
global.hashKey = '';
}
Expand All @@ -27,7 +35,7 @@ if (fs.existsSync('manifest.json')) {
ipcMain.on('set-hash', (event, arg) => {
global.hashKey = arg;

fs.writeFileSync('hashkey.txt', arg, 'utf-8');
fs.writeFileSync(hashKeyPath, arg, 'utf-8');
});

function createWindow() {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
"dependencies": {
"chokidar": "^2.0.0",
"form-data": "^2.3.1",
"mkdirp": "^0.5.1",
"randomstring": "^1.1.5",
"request": "^2.83.0",
"username": "^3.0.0"
},
"build": {
"publish": ["github"]
"publish": [
"github"
]
}
}

0 comments on commit a10f95f

Please sign in to comment.