var fs = require("fs");
const createScheduler = require('probot-scheduler');
const Freeze = require('./lib/freeze');
const formatParser = require('./lib/format-parser');
const githubHelper = require('./lib/github-helper');

/* Configuration Variables */

module.exports = robot => {
  robot.on('integration_installation.added', installationEvent);
  robot.on('issue_comment', handleFreeze);
  createScheduler(robot);

  robot.on('schedule.repository', handleThaw);

  async function installationEvent(context) {
    const config = await context.config('probot-snooze.yml', fs.readFileSync('./etc/defaults.js'));

    context.github.issues.getLabel(context.repositories_added[0]({
      name: config.labelName}).catch(() => {
        return context.github.issues.createLabel(context.repositories_added[0]({
          name: config.labelName,
          color: config.labelColor
        }));
      }));
  }

  async function handleFreeze(context) {
    const config = await context.config('probot-snooze.yml', fs.readFileSync('./etc/defaults.js'));
    const freeze = new Freeze(context.github, config);

    const comment = context.payload.comment;
    freeze.config.perform = true;
    if (freeze.config.perform && !context.isBot && freeze.freezable(comment)) {
      freeze.freeze(
        context,
        freeze.propsHelper(comment.user.login, comment.body)
    );
    }
  }

  async function handleThaw(context) {
    const config = await context.config('probot-snooze.yml', fs.readFileSync('./etc/defaults.js'));
    const freeze = new Freeze(context.github, config);

    context.github.search.issues({q:'label:' + freeze.config.labelName, repo:context.repo().full_name}).then(resp => {
      resp.data.items.forEach(issue => {
        context.github.issues.getComments(githubHelper.parseCommentURL(issue.comments_url)).then(resp => {
          return freeze.getLastFreeze(resp.data);
        }).then(lastFreezeComment => {
          if (freeze.unfreezable(lastFreezeComment)) {
            freeze.unfreeze(issue, formatParser.propFromComment(lastFreezeComment));
          }
        });
      });
    });
    console.log('scheduled thaw run complete');
  }
};

@@ -558,32 +558,43 @@
 ot-snooze.yml', 
+JSON.parse(
 fs.readFileSync(
@@ -608,24 +608,32 @@
 defaults.js'
+,'utf8')
 ));%0A%0A    con
@@ -1010,32 +1010,43 @@
 ot-snooze.yml', 
+JSON.parse(
 fs.readFileSync(
@@ -1056,32 +1056,40 @@
 etc/defaults.js'
+,'utf8')
 ));%0A    const fr
@@ -1443,32 +1443,33 @@
 (context) %7B%0A    
+ 
 const config = a
@@ -1509,16 +1509,27 @@
 e.yml', 
+JSON.parse(
 fs.readF
@@ -1555,20 +1555,29 @@
 ults.js'
+,'utf8')
 ));%0A
+%0A
     cons

fix json reading process