{"size": 1086, "ext": "js", "max_stars_repo_path": "index.js", "max_stars_repo_name": "telemark-arkiv/visual-test-website", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "index.js", "max_issues_repo_name": "telemark-arkiv/visual-test-website", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "index.js", "max_forks_repo_name": "telemark-arkiv/visual-test-website", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.6818181818, "max_line_length": 109, "alphanum_fraction": 0.6712707182}
'use strict';

var action = process.argv[2];
var captureScreenshot = require('./lib/captureScreenshot');
var generateReport = require('./lib/generateReport');
var pages = require('./pages');
var imagesFolder = 'images/';

function screenshotHandler(err, data) {
  if (err) {
    console.error(err);
  } else {
    console.log(data.message);
  }
}

if (!action) {
  console.log('Please choose action');
  console.log('Use "capture" to capture screenshots');
  console.log('Use "compare" to compare screenshots and generate error report');
}

if (action === 'capture') {
  pages.forEach(function(page) {
    captureScreenshot({filename: imagesFolder + page.nameOriginal, url:page.urlOriginal}, screenshotHandler);
    captureScreenshot({filename: imagesFolder + page.nameNew, url:page.urlNew}, screenshotHandler);
  });
}

if (action === 'compare') {
  var options = {
    pages: pages,
    imagesFolder: imagesFolder,
    verbose: true
  };
  generateReport(options, function(error, data){
    if (error) {
      console.error(error);
    } else {
      console.log(data);
    }
  });
}
