"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.needsChangelogs = exports.embedChangelogs = void 0;
const tslib_1 = require("tslib");
const p_map_1 = tslib_1.__importDefault(require("p-map"));
const template_1 = require("../../../util/template");
const changelog_1 = require("../update/pr/changelog");
async function embedChangelog(upgrade) {
    // getChangeLogJSON returns null on error, so don't try again
    if (upgrade.logJSON !== undefined) {
        return;
    }
    upgrade.logJSON = await (0, changelog_1.getChangeLogJSON)(upgrade);
}
async function embedChangelogs(branches) {
    await (0, p_map_1.default)(branches, embedChangelog, { concurrency: 10 });
}
exports.embedChangelogs = embedChangelogs;
function needsChangelogs(upgrade) {
    for (const field of template_1.exposedConfigOptions) {
        // fields set by `getChangeLogJSON`
        if ((0, template_1.containsTemplates)(upgrade[field], ['logJSON', 'releases'])) {
            return true;
        }
    }
    return false;
}
exports.needsChangelogs = needsChangelogs;
//# sourceMappingURL=index.js.map