<commit_before>const async = require('async');
const fs = require('fs');

const config = require('../config');
const utils = require('./utils');

const execCommand = utils.execCommand;
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;

/**
 * Run `bumpdocs` on the aframe-site repository and deploy.
 */
function bumpAframeDocs (data) {
  if (!shouldBumpDocs(data)) { return Promise.resolve(false); }

  return new Promise(resolve => {
    console.log(`Bumping A-Frame docs...`);
    async.series([
      execCommand('git reset --hard HEAD', 'aframe-site'),
      execCommand('git reset --hard HEAD', 'aframevr.github.io'),
      execCommand('git pull --rebase origin master', 'aframe-site'),
      execCommand('git pull --rebase origin master', 'aframevr.github.io'),
      execCommand(
        'node --max-old-space-size=150 /app/.heroku/node/bin/npm install --only="dev"',
        'aframe-site'),
      execCommand('node --max-old-space-size=150 /app/.heroku/node/bin/npm install',
                  'aframe-site'),
      execCommand(
        'MULTIDEP_NPM_PATH=/app/.heroku/node/bin/npm MULTIDEP_MEMORY_LIMIT=75 ' +
        'npm run bumpdocs', 'aframe-site'),
      execCommand('npm run generate', 'aframe-site'),
      execCommand('cp -r public/* ../aframevr.github.io', 'aframe-site'),
      execCommand('git status', 'aframevr.github.io'),
      execCommand('git add .', 'aframevr.github.io'),
      execCommand(`git commit -m "Bump A-Frame documentation (${data.compare})."`,
                  'aframevr.github.io'),
      execCommand(
        `git push https://${GITHUB_TOKEN}@github.com/${config.repoSitePages}.git master`,
        'aframevr.github.io')
    ], function asyncSeriesDone (err) {
      if (err) { return console.error(err); }
      console.log(`A-Frame docs successfully bumped!`);
      resolve(true);
    });
  });
}
module.exports.bumpAframeDocs = bumpAframeDocs;

/**
 * Check if A-Frame commit has changes to the documentation.
 */
function shouldBumpDocs (data) {
  // Limit to master branch and documentation branches.
  if (data.ref !== 'refs/heads/master' && !data.ref.startsWith('refs/heads/docs-v')) {
    return false;
  }

  function commitHasDocsChanges (commit) {
    return commit.modified.filter(function (file) {
      return file.startsWith('docs/') && file.endsWith('.md');
    }).length !== 0;
  }

  let hasDocsChanges = false;
  data.commits.forEach(commit => {
    if (commitHasDocsChanges(commit)) {
      hasDocsChanges = true;
    }
  });

  return hasDocsChanges;
}
module.exports.shouldBumpDocs = shouldBumpDocs;
<commit_msg>increase mem<commit_after>const async = require('async');
const fs = require('fs');

const config = require('../config');
const utils = require('./utils');

const execCommand = utils.execCommand;
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;

/**
 * Run `bumpdocs` on the aframe-site repository and deploy.
 */
function bumpAframeDocs (data) {
  if (!shouldBumpDocs(data)) { return Promise.resolve(false); }

  return new Promise(resolve => {
    console.log(`Bumping A-Frame docs...`);
    async.series([
      execCommand('git reset --hard HEAD', 'aframe-site'),
      execCommand('git reset --hard HEAD', 'aframevr.github.io'),
      execCommand('git pull --rebase origin master', 'aframe-site'),
      execCommand('git pull --rebase origin master', 'aframevr.github.io'),
      execCommand(
        'node --max-old-space-size=200 /app/.heroku/node/bin/npm install --only="dev"',
        'aframe-site'),
      execCommand('node --max-old-space-size=200 /app/.heroku/node/bin/npm install',
                  'aframe-site'),
      execCommand(
        'MULTIDEP_NPM_PATH=/app/.heroku/node/bin/npm MULTIDEP_MEMORY_LIMIT=200 ' +
        'npm run bumpdocs', 'aframe-site'),
      execCommand('npm run generate', 'aframe-site'),
      execCommand('cp -r public/* ../aframevr.github.io', 'aframe-site'),
      execCommand('git status', 'aframevr.github.io'),
      execCommand('git add .', 'aframevr.github.io'),
      execCommand(`git commit -m "Bump A-Frame documentation (${data.compare})."`,
                  'aframevr.github.io'),
      execCommand(
        `git push https://${GITHUB_TOKEN}@github.com/${config.repoSitePages}.git master`,
        'aframevr.github.io')
    ], function asyncSeriesDone (err) {
      if (err) { return console.error(err); }
      console.log(`A-Frame docs successfully bumped!`);
      resolve(true);
    });
  });
}
module.exports.bumpAframeDocs = bumpAframeDocs;

/**
 * Check if A-Frame commit has changes to the documentation.
 */
function shouldBumpDocs (data) {
  // Limit to master branch and documentation branches.
  if (data.ref !== 'refs/heads/master' && !data.ref.startsWith('refs/heads/docs-v')) {
    return false;
  }

  function commitHasDocsChanges (commit) {
    return commit.modified.filter(function (file) {
      return file.startsWith('docs/') && file.endsWith('.md');
    }).length !== 0;
  }

  let hasDocsChanges = false;
  data.commits.forEach(commit => {
    if (commitHasDocsChanges(commit)) {
      hasDocsChanges = true;
    }
  });

  return hasDocsChanges;
}
module.exports.shouldBumpDocs = shouldBumpDocs;

{'fraction_non_alphanumeric': 0.16116504854368932, 'fraction_numerical': 0.0036893203883495147, 'mean_word_length': 3.2221311475409835, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '2843055', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1644, 'n_words': 345}