<commit_before>'use strict';

const branchName = require('branch-name');
const buildVersion = require('build-version');

const buildData = (option) => {
    const config = Object.assign({}, option);
    return Promise.all([
        config.branch || branchName.assumeMaster(),
        config.version || buildVersion()
    ])
        .then((data) => {
            return {
                branch  : data[0],
                version : data[1]
            };
        });
};

module.exports = buildData;<commit_msg>New feature: get data from most recent build<commit_after>'use strict';

const fs = require('fs');
const path = require('path');
const branchName = require('branch-name');
const buildVersion = require('build-version');

const realpath = (fp) => {
    return new Promise((resolve, reject) => {
        fs.realpath(fp, (err, resolvedPath) => {
            if (err) {
                reject(err);
                return;
            }
            resolve(resolvedPath);
        });
    });
};

const buildData = (option) => {
    const config = Object.assign({}, option);
    return Promise.all([
        config.branch || branchName.assumeMaster(),
        config.version || buildVersion()
    ])
        .then((data) => {
            return {
                branch  : data[0],
                version : data[1]
            };
        });
};

buildData.latest = (option) => {
    const config = Object.assign(
        {
            cwd : ''
        },
        option
    );

    if (config.branch && config.version) {
        return Promise.resolve({
            branch  : config.branch,
            version : config.version
        });
    }

    const linkPath = config.branch ? path.join('build', config.branch, 'latest') : 'latest-build';

    return realpath(path.join(config.cwd, linkPath)).then((resolvedPath) => {
        return {
            branch  : config.branch || path.basename(path.join(resolvedPath, '..')),
            version : config.version || path.basename(resolvedPath)
        };
    });
};

module.exports = buildData;
{'fraction_non_alphanumeric': 0.14926829268292682, 'fraction_numerical': 0.001951219512195122, 'mean_word_length': 1.9811046511627908, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, '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': '4238231', 'n_tokens_mistral': 569, 'n_tokens_neox': 558, 'n_words': 118}