chokidar = require "chokidar" nodemailer = require "nodemailer" path = require "path" fs = require "fs" watcher = chokidar.watch "./errors", depth: 0, ignoreInitial: true mailer = nodemailer.createTransport() processFile = (filePath) -> fs.readFile filePath, (err, data) -> try parsedData = JSON.parse(data) catch error console.log "Error report not complete yet, retrying #{filePath} in 1 second..." setTimeout (-> processFile(filePath) ), 1000 return errorMessage = parsedData?.message ? "UNKNOWN ERROR" textStack = parsedData?.stack?.replace(/\u001b(?:\[\??(?:\d\;*)*[A-HJKSTfminsulh])?/g, "") ? "" message = """ A failure occurred. #{filePath} is attached. #{textStack} """ htmlMessage = """ A failure occurred. #{filePath} is attached.
#{textStack}""".replace(/\n/g, "