{"size": 1100, "ext": "js", "max_stars_repo_path": "bin/build-csv/download-csv.js", "max_stars_repo_name": "MichaelHornsbyTZ/pokedex.org", "max_stars_repo_stars_event_min_datetime": "2015-11-23T17:57:03.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T16:29:15.000Z", "max_issues_repo_path": "bin/build-csv/download-csv.js", "max_issues_repo_name": "MichaelHornsbyTZ/pokedex.org", "max_issues_repo_issues_event_min_datetime": "2015-11-23T18:39:17.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-22T01:42:30.000Z", "max_forks_repo_path": "bin/build-csv/download-csv.js", "max_forks_repo_name": "MichaelHornsbyTZ/pokedex.org", "max_forks_repo_forks_event_min_datetime": "2015-11-23T22:43:47.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-03T21:42:01.000Z"}
{"max_stars_count": 2504, "max_issues_count": 79, "max_forks_count": 444, "avg_line_length": 26.8292682927, "max_line_length": 95, "alphanum_fraction": 0.6436363636}
const fetch = require('node-fetch');
const mkdirp = require('mkdirp');
const fs = require('fs');

(function getCSV() {
  // create the CSV directory
  mkdirp('csv');
  // download relevant CSV files
  const csv_base_URL = 'https://raw.githubusercontent.com/PokeAPI/pokeapi/master/data/v2/csv/';
  const files = [
    'ability_names.csv',
    'types.csv',
    'type_efficacy.csv',
    'stats.csv',
    'moves.csv',
    'move_names.csv',
    'move_flavor_text.csv',
    'egg_group_prose.csv',
    'growth_rate_prose.csv',
    'move_names.csv',
    'evolution_triggers.csv',
    'pokemon_egg_groups.csv',
    'pokemon_abilities.csv',
    'pokemon_evolution.csv',
    'pokemon_moves.csv',
    'pokemon_move_methods.csv',
    'pokemon.csv',
    'pokemon_stats.csv',
    'pokemon_types.csv',
    'pokemon_species.csv',
    'pokemon_species_names.csv',
    'pokemon_species_flavor_text.csv',
  ];

  for (let i = 0; i < files.length; i++) {
    fetch(`${csv_base_URL}${files[i]}`)
      .then(res => res.body.pipe(fs.createWriteStream(`csv/${files[i]}`)))
      .catch(console.log.bind(console));
  }
})();
