<commit_before>const { join } = require('path');
const CacheConf = require('cache-conf');
const { ZEL } = require('./constants');
const { bufferToJSON, get, sync } = require('./utils');

/**
 * Fetches the zel configuration file from the remote repository.
 *
 * @param {String} repoName - The repo name
 * @return {Promise<Object>} - The configuration object
 */
const fetchZelFile = (repoName) => new Promise((resolve, reject) => {
    get(`https://api.github.com/repos/${repoName}/contents/${ZEL.FILE}`)
        .then((resp) => {
            if (resp.message === 'Not Found') {
                reject(`${repoName} not found.`);
            }
            const config = bufferToJSON(resp.content, `"${ZEL.FILE}" from ${repoName}`);
            resolve(config);
        })
        .catch((err) => reject(err));
});

/**
 * Retrieve the zel configuration of the specified repository name.
 *
 * Config are cached into the `ZEL.CACHEDIR` directory
 * and expires with a timeout set to `ZEL.CACHETIMEOUT`.
 *
 * @param {String} repoName - The repo name
 * @return {Promise<Object>} - The configuration object
 */
const getZelFile = (repoName) => new Promise((resolve, reject) => {
    const cache = new CacheConf({
        configName: ZEL.FILE,
        cwd: join(ZEL.CACHEDIR, repoName),
    });

    if (cache.isExpired() || !cache.has('config')) {
        return fetchZelFile(repoName)<commit_msg>missing cache key (#21)<commit_after>const { join } = require('path');
const CacheConf = require('cache-conf');
const { ZEL } = require('./constants');
const { bufferToJSON, get, sync } = require('./utils');

/**
 * Fetches the zel configuration file from the remote repository.
 *
 * @param {String} repoName - The repo name
 * @return {Promise<Object>} - The configuration object
 */
const fetchZelFile = (repoName) => new Promise((resolve, reject) => {
    get(`https://api.github.com/repos/${repoName}/contents/${ZEL.FILE}`)
        .then((resp) => {
            if (resp.message === 'Not Found') {
                reject(`${repoName} not found.`);
            }
            const config = bufferToJSON(resp.content, `"${ZEL.FILE}" from ${repoName}`);
            resolve(config);
        })
        .catch((err) => reject(err));
});

/**
 * Retrieve the zel configuration of the specified repository name.
 *
 * Config are cached into the `ZEL.CACHEDIR` directory
 * and expires with a timeout set to `ZEL.CACHETIMEOUT`.
 *
 * @param {String} repoName - The repo name
 * @return {Promise<Object>} - The configuration object
 */
const getZelFile = (repoName) => new Promise((resolve, reject) => {
    const cache = new CacheConf({
        configName: ZEL.FILE,
        cwd: join(ZEL.CACHEDIR, repoName),
    });

    if (cache.isExpired('config') || !cache.has('config')) {
        return fetchZelFile(repoName)
{'fraction_non_alphanumeric': 0.16251778093883357, 'fraction_numerical': 0.0007112375533428165, 'mean_word_length': 3.0768115942028986, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5728318', 'n_tokens_mistral': 832, 'n_tokens_neox': 839, 'n_words': 228}