fix: 修复linux上配置文件路径错误的问题

This commit is contained in:
2020-07-25 23:32:51 +08:00
parent 3b34423192
commit b1bb523ec4
+4 -2
View File
@@ -1,4 +1,5 @@
const fs = require('fs');
const path = require('path');
const { promisify } = require('util');
const { debounce } = require('lodash');
@@ -17,8 +18,9 @@ const config = {
skipTrayIcon: false
};
let configPath = path.resolve(path.dirname(process.execPath), 'config.json');
try {
let userConfig = fs.readFileSync('./config.json');
let userConfig = fs.readFileSync(configPath);
if (userConfig) {
Object.assign(config, JSON.parse(userConfig.toString()));
}
@@ -28,7 +30,7 @@ catch { }
async function flushConfig() {
const flush = promisify(fs.writeFile.bind(fs));
try {
await flush('./config.json', JSON.stringify(config, null, 4));
await flush(configPath, JSON.stringify(config, null, 4));
}
catch {
const { notify } = require('./tools');