How to use the tc-source-content-updater.getOtherTnsOLVersions function in tc-source-content-updater

To help you get started, we’ve selected a few tc-source-content-updater examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github unfoldingWord / translationCore / src / js / helpers / ResourcesHelpers.js View on Github external
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

tc-source-content-updater

Module that updates source content for the desktop application translationCore.

MIT
Latest version published 3 days ago

Package Health Score

64 / 100
Full package analysis