{"size": 887, "ext": "js", "max_stars_repo_path": "build/getEntries.js", "max_stars_repo_name": "AD-feiben/lw-chart", "max_stars_repo_stars_event_min_datetime": "2020-05-05T17:59:22.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-04T05:05:44.000Z", "max_issues_repo_path": "build/getEntries.js", "max_issues_repo_name": "AD-feiben/lw-chart", "max_issues_repo_issues_event_min_datetime": "2021-10-06T18:29:59.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-16T09:07:45.000Z", "max_forks_repo_path": "build/getEntries.js", "max_forks_repo_name": "AD-feiben/lw-chart", "max_forks_repo_forks_event_min_datetime": "2020-05-09T06:12:52.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-04T05:05:47.000Z"}
{"max_stars_count": 10, "max_issues_count": 10, "max_forks_count": 4, "avg_line_length": 23.972972973, "max_line_length": 70, "alphanum_fraction": 0.5569334837}
const path = require('path');
const fs = require('fs');

function resolve(dir) {
  return path.join(__dirname, '..', dir);
}

function formatEntryName(str) {
  str = str.replace(/\.[a-z]+/, '');
  str = str.replace(/\-\S/, (s) => s.replace(/\-/, '').toUpperCase());
  str = str.replace(/^\S/, (s) => s.toUpperCase());
  return str;
}

function getEntries (dirName) {
  let libs = {};
  let files = fs.readdirSync(resolve(dirName));
  files.map(file => {
    const fPath = path.join(dirName, file);
    const stat = fs.statSync(fPath);
    if (stat.isFile() === true) {
      if (file === 'index.ts') {
        libs['index'] = resolve(fPath);
        return;
      }
      if (file === 'lw-chart.ts') {
        libs['LWChart'] = resolve(fPath);
        return;
      }
      libs[formatEntryName(file)] = resolve(fPath);
    }
  });
  return libs;
}

module.exports = getEntries('src');;
