{"size": 756, "ext": "js", "max_stars_repo_path": "src/find-markdown-files.js", "max_stars_repo_name": "devonChurch/coconut-snowballs", "max_stars_repo_stars_event_min_datetime": "2018-09-17T00:08:05.000Z", "max_stars_repo_stars_event_max_datetime": "2018-09-17T00:08:05.000Z", "max_issues_repo_path": "src/find-markdown-files.js", "max_issues_repo_name": "devonChurch/coconut-snowballs", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/find-markdown-files.js", "max_forks_repo_name": "devonChurch/coconut-snowballs", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.0769230769, "max_line_length": 91, "alphanum_fraction": 0.6507936508}
module.exports = class FindMarkdownFiles {
  constructor({ globAsync, logger }) {
    this.globAsync = globAsync;
    this.logger = logger;
  }

  getFiles = markdownDir => this.globAsync(`${markdownDir}/**/*.md`, null);

  validateFiles = markdownFiles => {
    if (!markdownFiles.length) {
      this.logger.warn('no markdown files found');
      throw new Error();
    }
    this.logger.success(
      `found ${markdownFiles.length} markdown file${markdownFiles.length === 1 ? '' : 's'}`
    );
    markdownFiles.forEach(file => this.logger.info(file));
  };

  init = async markdownDir => {
    const markdownFiles = await this.getFiles(markdownDir);
    this.validateFiles(markdownFiles);
    return markdownFiles.length ? markdownFiles : [];
  };
};
