// Splits the aggregated JSON file into individual JSON files per EIN
// Files are then available to Jekyll in the _data folder
const fs = require('fs');

fs.readFile('aggregated.json', 'utf8', function(err, data) {
  if (err) {
    console.log(err);
  }
  const array = JSON.parse(data);
  array.forEach(function(item) {
    const ein = item.ein;
    item.last_updated.toISOString();
    item.last_updated_irs.toISOString();

    const doc = JSON.stringify(item, null, 4);

    fs.writeFileSync('ein/' + ein + '.json', doc, 'utf-8');
    console.log('File saved for ' + ein);
  });
});

// Splits the aggregated JSON file into individual JSON files per EIN
// Files are then available to Jekyll in the _data folder
const fs = require('fs');

fs.readFile('aggregated.json', 'utf8', function(err, data) {
  if (err) {
    console.log(err);
  }
  const array = JSON.parse(data);
  array.forEach(function(item) {
    const ein = item.ein;

    const doc = JSON.stringify(item, null, 4);

    fs.writeFileSync('ein/' + ein + '.json', doc, 'utf-8');
    console.log('File saved for ' + ein);
  });
});

Revert "Prep for Codeship"