Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (27 sloc) 0.625 kb
# 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'
Jump to Line
Something went wrong with that request. Please try again.