balena-cli/lib/resin/data/data-prefix.coffee

20 lines
385 B
CoffeeScript
Raw Normal View History

mkdirp = require('mkdirp')
2014-11-26 18:22:01 +00:00
fsUtils = require('./fs-utils/fs-utils')
2014-11-07 16:42:02 +00:00
prefix = null
exports.get = ->
return prefix
2014-11-17 19:20:19 +00:00
exports.set = (newPrefix, callback) ->
2014-11-07 16:42:02 +00:00
if not fsUtils.isValidPath(newPrefix)
2014-11-17 19:20:19 +00:00
return callback?(new Error('Invalid path'))
2014-11-07 16:42:02 +00:00
mkdirp newPrefix, (error) ->
return callback?(error) if error?
prefix = newPrefix
return callback?()
2014-11-07 16:42:02 +00:00
exports.clear = ->
prefix = null