Skip to content

Commit

Permalink
Add config file API
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Jan 12, 2017
1 parent fae021f commit 86f84d5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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) {
Expand Down
28 changes: 28 additions & 0 deletions src/app/config.js
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 86f84d5

Please sign in to comment.