2
0
mirror of https://github.com/frappe/books.git synced 2025-01-23 23:28:24 +00:00
books/electron/settings.js

28 lines
597 B
JavaScript
Raw Normal View History

2018-04-16 18:33:54 +05:30
const os = require('os');
2018-04-18 12:17:00 +05:30
const path = require('path');
2018-10-22 23:32:47 +05:30
const fs = require('fs');
2018-04-16 18:33:54 +05:30
const { writeFile } = require('frappejs/server/utils');
const homedir = os.homedir();
const configFilePath = path.join(homedir, '.config', 'frappe-accounting', 'settings.json');
function getSettings() {
2018-07-14 18:45:21 +05:30
let settings;
try {
2018-10-22 23:32:47 +05:30
settings = JSON.parse(fs.readFileSync(configFilePath) || '{}');
2018-07-14 18:45:21 +05:30
} catch (e) {
settings = {};
}
2018-04-16 18:33:54 +05:30
2018-07-14 18:45:21 +05:30
return settings;
2018-04-16 18:33:54 +05:30
}
async function saveSettings(settings) {
2018-07-14 18:45:21 +05:30
await writeFile(configFilePath, JSON.stringify(settings));
2018-04-16 18:33:54 +05:30
}
module.exports = {
2018-07-14 18:45:21 +05:30
getSettings,
saveSettings
};