{"size": 608, "ext": "js", "max_stars_repo_path": "src/helpers/folderExists.js", "max_stars_repo_name": "rocjs/roc", "max_stars_repo_stars_event_min_datetime": "2016-03-29T19:01:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T13:12:01.000Z", "max_issues_repo_path": "src/helpers/folderExists.js", "max_issues_repo_name": "baseonmars/roc", "max_issues_repo_issues_event_min_datetime": "2016-04-01T13:57:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-01-09T15:56:02.000Z", "max_forks_repo_path": "src/helpers/folderExists.js", "max_forks_repo_name": "baseonmars/roc", "max_forks_repo_forks_event_min_datetime": "2016-04-19T02:10:41.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-09T15:14:30.000Z"}
{"max_stars_count": 464, "max_issues_count": 87, "max_forks_count": 34, "avg_line_length": 28.9523809524, "max_line_length": 119, "alphanum_fraction": 0.7006578947}
import fs from 'fs';

import getAbsolutePath from './getAbsolutePath';

/**
* Verifies if a folder exists.
*
* @param {string} filepath - The filepath to check. Will make it absolute if not already using {@link getAbsolutePath}.
* @param {string} [directory] - The directory to base the filepath on.
*
* @returns {boolean} - Whether or not it is a folder.
*/
export default function folderExists(filepath, directory) {
    const absoluteFilepath = getAbsolutePath(filepath, directory);
    try {
        return fs.statSync(absoluteFilepath).isDirectory();
    } catch (error) {
        return false;
    }
}
