Parameterize configDirPath and move config.load in ctor

This commit is contained in:
Antonio Scandurra
2015-10-14 12:41:00 +02:00
parent d9af8686ed
commit b25d3e944b
8 changed files with 35 additions and 21 deletions

View File

@@ -4,12 +4,16 @@ fs = require "fs-plus"
module.exports =
class StorageFolder
constructor: (containingPath) ->
@path = path.join(containingPath, "storage")
@path = path.join(containingPath, "storage") if containingPath?
store: (name, object) ->
return unless @path?
fs.writeFileSync(@pathForKey(name), JSON.stringify(object), 'utf8')
load: (name) ->
return unless @path?
statePath = @pathForKey(name)
try
stateString = fs.readFileSync(statePath, 'utf8')