{"size": 688, "ext": "js", "max_stars_repo_path": "src_logic/common/common.require.js", "max_stars_repo_name": "Flouse/easy-monitor", "max_stars_repo_stars_event_min_datetime": "2018-08-08T16:13:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-12T01:52:32.000Z", "max_issues_repo_path": "src_logic/common/common.require.js", "max_issues_repo_name": "Flouse/easy-monitor", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src_logic/common/common.require.js", "max_forks_repo_name": "Flouse/easy-monitor", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 5, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.6666666667, "max_line_length": 74, "alphanum_fraction": 0.5566860465}
'use strict';
const path = require('path');

module.exports = function (_common, config, logger, utils) {
    /**
     * @param {string} root 
     * @return {function}
     * @description 生成内部 require 方法，简便多层嵌套情况
    */
    function createRequire(root) {
        return function (filePath) {
            let res = {};
            try {
                logger.debug(`inner require file path is: ${filePath}`);
                res = require(path.join(root, filePath));
            } catch (e) { logger.error(`<${filePath}> load error: ${e}`) }

            return res;
        }
    }

    //根据配置文件提供的 src_root 设置项目根路径
    return createRequire(config.require && config.require.src_root)
};