{"size": 670, "ext": "js", "max_stars_repo_path": "cli.js", "max_stars_repo_name": "camjc/coronadatascraper", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cli.js", "max_issues_repo_name": "camjc/coronadatascraper", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cli.js", "max_forks_repo_name": "camjc/coronadatascraper", "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": 30.4545454545, "max_line_length": 96, "alphanum_fraction": 0.6791044776}
import path from 'path';
import generate from './index.js';
import * as fs from './lib/fs.js';
import * as stringify from './lib/stringify.js';
import argv from './lib/cliArgs.js';

async function writeData({ locations, report }) {
  let date = process.env['SCRAPE_DATE'] ? '-' + process.env['SCRAPE_DATE'] : '';

  await fs.ensureDir('dist');

  await fs.writeFile(path.join('dist', `data${date}.json`), JSON.stringify(locations, null, 2));

  await fs.writeCSV(path.join('dist', `data${date}.csv`), stringify.csvForDay(locations));

  await fs.writeJSON(path.join('dist', `report.json`), report);

  return { locations };
}

generate(argv.date, argv).then(writeData);
