2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 19:39:07 +00:00
books/electron/settings.js
2019-11-20 00:47:56 +05:30

28 lines
597 B
JavaScript

const os = require('os');
const path = require('path');
const fs = require('fs');
const { writeFile } = require('frappejs/server/utils');
const homedir = os.homedir();
const configFilePath = path.join(homedir, '.config', 'frappe-accounting', 'settings.json');
function getSettings() {
let settings;
try {
settings = JSON.parse(fs.readFileSync(configFilePath) || '{}');
} catch (e) {
settings = {};
}
return settings;
}
async function saveSettings(settings) {
await writeFile(configFilePath, JSON.stringify(settings));
}
module.exports = {
getSettings,
saveSettings
};