Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function preserveNeededOrigLangVersions(languageId, resourceId, resourcePath) {
let deleteOldResources = true; // by default we do not keep old versions of resources
if (BibleHelpers.isOriginalLanguageBible(languageId, resourceId)) {
const requiredVersions = getOtherTnsOLVersions(resourceId).sort((a, b) =>
-ResourceAPI.compareVersions(a, b) // do inverted sort
);
console.log('preserveNeededOrigLangVersions: requiredVersions', requiredVersions);
// see if we need to keep old versions of original language
if (requiredVersions && requiredVersions.length) {
deleteOldResources = false;
const highestRequired = requiredVersions[0];
const versions = ResourceAPI.listVersions(resourcePath);
console.log('preserveNeededOrigLangVersions: versions', versions);
for (let version of versions) {
if (!requiredVersions.includes(version)) {
const newerResource = ResourceAPI.compareVersions(version, highestRequired) > 0;
if (!newerResource) { // don't delete if newer version