-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.js
34 lines (31 loc) · 1.07 KB
/
settings.js
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
31
32
33
const fs = require("fs");
const path = require("path");
module.exports = {
settingsFromFile: function(){
const homedir = require('os').homedir();
const folder = path.join(homedir, '.eon-cmd-tools');
const file = path.join(homedir, '.eon-cmd-tools',"settings.conf");
if (!fs.existsSync(folder)) {
fs.mkdirSync(folder);
}
if (fs.existsSync(file)) {
return JSON.parse(fs.readFileSync(file));
}else{
return this.createSettingsJson("https://eon-rpc.horizenlabs.io");
}
},
settingsToFile: function(jsonSettings){
const homedir = require('os').homedir();
const folder = path.join(homedir, '.eon-cmd-tools');
const file = path.join(homedir, '.eon-cmd-tools', "settings.conf");
if (!fs.existsSync(folder)) {
fs.mkdirSync(folder);
}
fs.writeFileSync(file, JSON.stringify(jsonSettings));
},
createSettingsJson: function(baseUrl) {
return {
baseUrl: baseUrl
}
}
}