-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathpresets.js
More file actions
30 lines (25 loc) · 871 Bytes
/
presets.js
File metadata and controls
30 lines (25 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const fs = require("fs");
const path = require("path");
const { app } = require("electron");
const presetsPath = path.resolve(app.getPath("userData"), "presets.json");
function loadPresets() {
if (fs.existsSync(presetsPath)) {
return JSON.parse(fs.readFileSync(presetsPath).toString().replaceAll("http://convert.deepnest.io", "https://converter.deepnest.app/convert").replaceAll("https://convert.deepnest.io", "https://converter.deepnest.app/convert"));
}
return {};
}
function savePreset(name, config) {
const presets = loadPresets();
presets[name] = config;
fs.writeFileSync(presetsPath, JSON.stringify(presets, null, 2));
}
function deletePreset(name) {
const presets = loadPresets();
delete presets[name];
fs.writeFileSync(presetsPath, JSON.stringify(presets, null, 2));
}
module.exports = {
loadPresets,
savePreset,
deletePreset,
};