Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (27 sloc) 625 Bytes
# Description:
# None
#
# Dependencies:
# None
#
# Configuration:
# FILE_BRAIN_PATH
#
# Commands:
# None
#
# Author:
# dustyburwell
fs = require 'fs'
path = require 'path'
module.exports = (robot) ->
brainPath = process.env.FILE_BRAIN_PATH or '/var/hubot'
brainPath = path.join brainPath, 'brain-dump.json'
try
data = fs.readFileSync brainPath, 'utf-8'
if data
robot.brain.mergeData JSON.parse(data)
catch error
console.log('Unable to read file', error) unless error.code is 'ENOENT'
robot.brain.on 'save', (data) ->
fs.writeFileSync brainPath, JSON.stringify(data), 'utf-8'
You can’t perform that action at this time.