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

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

const GITHUB_TOKEN = process.env.GITHUB_TOKEN;

/**
 * Bump A-Frame Registry on changes to the registry.
 */
function bumpAframeRegistry (data) {
  if (!shouldBumpAframeRegistry(data)) { return Promise.resolve(false); }

  return new Promise(resolve => {
    console.log(`Bumping A-Frame Registry...`);
    async.series([
      execRegistryCommand('git pull --rebase origin master'),
      execRegistryCommand('node --max-old-space-size=200 /app/.heroku/node/bin/npm install'),
      execRegistryCommand(
        'node --max-old-space-size=200 /app/.heroku/node/bin/npm install --only="dev"'),
      execRegistryCommand('npm run config'),
      execRegistryCommand('npm run build'),
      execRegistryCommand('git add .'),
      execRegistryCommand('git commit -m "Bump Registry builds and site."'),
      execRegistryCommand(
        `git push https://${GITHUB_TOKEN}@github.com/${config.repoRegistry}.git master`)
    ], function asyncSeriesDone (err) {
      if (err) { return console.error(err); }
      console.log(`A-Frame Registry successfully bumped!`);
      resolve(true);
    });
  });
}
module.exports.bumpAframeRegistry= bumpAframeRegistry;

/**
 * Helper for async.js.
 */
function execRegistryCommand (command) {
  return callback => {
    console.log(`Running ${command}...`);
    childProcess.exec(command, {cwd: 'aframe-registry', stdio: 'inherit'}, (err, stdout) => {
      if (err) { console.error(err); }
      callback();
    });
  };
}

/**
 * Check if A-Frame commit has changes to the Registry.
 */
function shouldBumpAframeRegistry (data) {
  function commitHasRegistryChanges (commit) {
    return commit.modified.filter(function (file) {
      return file === 'registry.yml' || file === 'registry.json'
    }).length !== 0;
  }

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

  return hasRegistryChanges;
}
module.exports.shouldBumpAframeRegistry = shouldBumpAframeRegistry;
<commit_msg>log registry errors<commit_after>const async = require('async');
const childProcess = require('child_process');
const fs = require('fs');

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

const GITHUB_TOKEN = process.env.GITHUB_TOKEN;

/**
 * Bump A-Frame Registry on changes to the registry.
 */
function bumpAframeRegistry (data) {
  if (!shouldBumpAframeRegistry(data)) { return Promise.resolve(false); }

  return new Promise(resolve => {
    console.log(`Bumping A-Frame Registry...`);
    async.series([
      execRegistryCommand('git pull --rebase origin master'),
      execRegistryCommand('node --max-old-space-size=200 /app/.heroku/node/bin/npm install'),
      execRegistryCommand(
        'node --max-old-space-size=200 /app/.heroku/node/bin/npm install --only="dev"'),
      execRegistryCommand('npm run config'),
      execRegistryCommand('npm run build'),
      execRegistryCommand('git add .'),
      execRegistryCommand('git commit -m "Bump Registry builds and site."'),
      execRegistryCommand(
        `git push https://${GITHUB_TOKEN}@github.com/${config.repoRegistry}.git master`)
    ], function asyncSeriesDone (err) {
      if (err) { return console.error(err); }
      console.log(`A-Frame Registry successfully bumped!`);
      resolve(true);
    });
  });
}
module.exports.bumpAframeRegistry= bumpAframeRegistry;

/**
 * Helper for async.js.
 */
function execRegistryCommand (command) {
  return callback => {
    console.log(`Running ${command}...`);
    childProcess.exec(command, {
      cwd: 'aframe-registry',
      stdio: 'inherit'
    }, (err, stdout, stderr) => {
      if (err) { console.error(err); }
      if (stderr) { console.error(stderr); }
      callback();
    });
  };
}

/**
 * Check if A-Frame commit has changes to the Registry.
 */
function shouldBumpAframeRegistry (data) {
  function commitHasRegistryChanges (commit) {
    return commit.modified.filter(function (file) {
      return file === 'registry.yml' || file === 'registry.json'
    }).length !== 0;
  }

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

  return hasRegistryChanges;
}
module.exports.shouldBumpAframeRegistry = shouldBumpAframeRegistry;

{'fraction_non_alphanumeric': 0.1490222521915037, 'fraction_numerical': 0.003146774556080018, 'mean_word_length': 3.616182572614108, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2818441', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1315, 'n_words': 296}