<commit_before>const util = require('util');
const exec = util.promisify(require('child_process').exec);

async function getChangedFiles() {
  const { stdout, stderr } = await exec(`git diff --name-only HEAD...$TRAVIS_BRANCH`);
  // TODO: How do I properly handle stderr?
  return stdout.trim().split('\n');
}

async function hasChangelog(changedFiles) {
  return changedFiles.some(path => path.includes('/CHANGELOG.js'));
}

async function checkForChangelog() {
  const changedFiles = await getChangedFiles();
  return hasChangelog(changedFiles);
}

async function main() {
  const hasChangelog = await checkForChangelog();
  let exitCode;
  if (hasChangelog) {
    console.log('Found a changelog entry. Thanks!');
    exitCode = 0;
  } else {
    console.error('Error: Changelog entry missing.\n' +
      'A changelog entry is required. Please explain your change in a relevant CHANGELOG file. Use the spec specific CHANGELOG file if it was a spec/class specific change. If it affects many specs, use the CHANGELOG file in the root src folder.');
    exitCode = 1;
  }
  process.exit(exitCode);
}

main();
<commit_msg>Improve error message<commit_after>const util = require('util');
const exec = util.promisify(require('child_process').exec);

async function getChangedFiles() {
  // eslint-disable-next-line no-unused-vars
  const { stdout, stderr } = await exec(`git diff --name-only HEAD...$TRAVIS_BRANCH`);
  // TODO: How do I properly handle stderr?
  return stdout.trim().split('\n');
}

async function hasChangelog(changedFiles) {
  return changedFiles.some(path => path.includes('/CHANGELOG.js'));
}

async function checkForChangelog() {
  const changedFiles = await getChangedFiles();
  return hasChangelog(changedFiles);
}

async function main() {
  const hasChangelog = await checkForChangelog();
  let exitCode;
  if (hasChangelog) {
    console.log('Found a changelog entry. Thanks!');
    exitCode = 0;
  } else {
    console.error('Error: Changelog entry missing.\n' +
      'A changelog entry is required. Please explain your change in a relevant CHANGELOG file.\n' +
      'Use the spec specific CHANGELOG file if it was a spec/class specific change. If it\n' +
      'affects many specs, you can use the CHANGELOG file in the root src folder.');
    exitCode = 1;
  }
  process.exit(exitCode);
}

main();

{'fraction_non_alphanumeric': 0.12086021505376345, 'fraction_numerical': 0.0017204301075268817, 'mean_word_length': 4.089715536105033, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6863182', 'n_tokens_mistral': 726, 'n_tokens_neox': 727, 'n_words': 224}