<commit_before>var _ = require('lodash');
var fs = require('fs');
var semver = require('semver');
var path = require('canonical-path');

var basePath;
var outputFolder;
var currentVersion;
module.exports = {
  name: 'version-data',
  description: 'Give a list of all available versions to the template',
  runBefore: ['pages-data'],
  init: function(config) {
    basePath = config.get('basePath');
    outputFolder = config.get('rendering.outputFolder');
    currentVersion = config.get('currentVersion');
  },
  process: function(docs, extraData) {
    var docsBaseFolder = path.resolve(basePath, outputFolder, 'docs');

    //Array of versions sorted backwards
    var versions = fs.readdirSync(docsBaseFolder)
      .filter(semver.valid)
      .sort(semver.rcompare);

    //Add current version to the top of the list if not exists
    !_.contains(versions, currentVersion) && versions.unshift(currentVersion);

    //Add nightly to the top of the list if not exists
    !_.contains(versions, 'nightly') && versions.unshift('nightly');

    versions = versions.map(function(ver) {
      return {
        href: '/docs/' + ver,
        name: ver
      };
    });
    extraData.version = {
      list: versions,
      current: _.find(versions, { name: currentVersion }),
      //Stable = most recent (first) valid semver version
      stable: _.find(versions, function(v) { return semver.valid(v.name); })
    };
  }
};<commit_msg>docs: make stable be nightly if testing<commit_after>var _ = require('lodash');
var fs = require('fs');
var semver = require('semver');
var path = require('canonical-path');

var basePath;
var outputFolder;
var currentVersion;
module.exports = {
  name: 'version-data',
  description: 'Give a list of all available versions to the template',
  runBefore: ['pages-data'],
  init: function(config) {
    basePath = config.get('basePath');
    outputFolder = config.get('rendering.outputFolder');
    currentVersion = config.get('currentVersion');
  },
  process: function(docs, extraData) {
    var docsBaseFolder = path.resolve(basePath, outputFolder, 'docs');

    //Array of versions sorted backwards
    var versions = fs.readdirSync(docsBaseFolder)
      .filter(semver.valid)
      .sort(semver.rcompare);

    //Add current version to the top of the list if not exists
    !_.contains(versions, currentVersion) && versions.unshift(currentVersion);

    //Add nightly to the top of the list if not exists
    !_.contains(versions, 'nightly') && versions.unshift('nightly');

    versions = versions.map(function(ver) {
      return {
        href: '/docs/' + ver,
        name: ver
      };
    });
    extraData.version = {
      list: versions,
      current: _.find(versions, { name: currentVersion }),
      //Stable = most recent (first) valid semver version
      stable: _.find(versions, function(v) { return semver.valid(v.name); }) ||
        _.first(versions)
    };
  }
};
{'fraction_non_alphanumeric': 0.13566289825282632, 'fraction_numerical': 0.0, 'mean_word_length': 3.4376899696048633, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '339558', 'n_tokens_mistral': 861, 'n_tokens_neox': 846, 'n_words': 237}