Add config file API

pull/1/head
Alex Beregszaszi 8 years ago
parent fae021f4a2
commit 86f84d5350
  1. 2
      src/app.js
  2. 28
      src/app/config.js

@ -11,6 +11,7 @@ var GistHandler = require('./app/gist-handler')
var gistHandler = new GistHandler()
var Storage = require('./app/storage')
var Config = require('./app/config')
var Editor = require('./app/editor')
var Renderer = require('./app/renderer')
var Compiler = require('./app/compiler')
@ -40,6 +41,7 @@ var run = function () {
var self = this
this.event = new EventManager()
var storage = new Storage()
var config = new Config(storage)
function loadFiles (files) {
for (var f in files) {

@ -0,0 +1,28 @@
'use strict'
var CONFIG_FILE = '.browser-solidity.json'
function Config (storage) {
this.items = {}
// load on instantiation
var config = storage.get(CONFIG_FILE)
if (config) {
this.items = JSON.parse(config)
}
this.exists = function (key) {
return this.items[key] !== undefined
}
this.get = function (key) {
return this.items[key]
}
this.set = function (key, content) {
this.items[key] = content
storage.set(CONFIG_FILE, JSON.stringify(this.items))
}
}
module.exports = Config
Loading…
Cancel
Save