<commit_before>#! /usr/bin/env node

var program = require('commander');
var exec = require('child_process').exec;
var chalk = require('chalk');
var emojis = require("emojilib")

program
  .version('1.0.0')
  .option('-m', 'Your plain, old commit message.')
  .option('-k', 'A keyword to get a relevant emoji.')
  .parse(process.argv);

if (program.M) {
  exec('git commit -m "' + getEmoji() + program.args[0] + '"', function (error, stdout, stderr) {
    console.log(stdout);
  });
} else {
  console.log(chalk.red('You have to specify a commit message using the -m flag.'));
}

/**
 * @name getEmoji
 * @desc Gets an emoji to add to the commit message.
 */
function getEmoji() {
  // If a keyword was supplied, try to find one that is relevant.
  if (program.K) {
    var options = [];

    // Search over all emojis, looking for a matching keyword.
    for (var key in emojis) {
      if (emojis.hasOwnProperty(key)) {
        // If the keyword matches, add the emoji to an array of options.
        if (emojis[key].keywords && emojis[key].keywords.indexOf(program.args[1]) > -1) {
          options.push(key);
        }
      }
    }

    // If any options have been found, return a random option.
    if (options.length > 0) {
      return ' :' + options[Math.floor(Math.random() * options.length)] + ':';
    // If there are no options, just get a random emoji from the library.
    } else {
      var result;
      var count = 0;

      for (var prop in emojis) {
        if (Math.random() < 1 / ++count) {
          result = prop;
        }
      }

      return ':' + result + ': ';
    }
  // If no keyword is supplied, get a random emoji from the library.
  } else {
    var result;
    var count = 0;

    for (var prop in emojis) {
      if (Math.random() < 1 / ++count) {
        result = prop;
      }
    }
<commit_msg>:clock630: Fix a spacing issue in getEmoji.<commit_after>#! /usr/bin/env node

var program = require('commander');
var exec = require('child_process').exec;
var chalk = require('chalk');
var emojis = require("emojilib")

program
  .version('1.0.0')
  .option('-m', 'Your plain, old commit message.')
  .option('-s', 'A seach query to get a relevant emoji.')
  .option('-k', 'A keyword pertaining to common commit types.')
  .parse(process.argv);

if (program.M) {
  exec('git commit -m "' + getEmoji() + program.args[0] + '"', function (error, stdout, stderr) {
    console.log(stdout);
  });
} else {
  console.log(chalk.red('You have to specify a commit message using the -m flag.'));
}

/**
 * @name getEmoji
 * @desc Gets an emoji to add to the commit message.
 */
function getEmoji() {
  // If a search term is supplied, try to find one that is relevant.
  if (program.S) {
    var options = [];

    // Search over all emojis, looking for a matching keyword.
    for (var key in emojis) {
      if (emojis.hasOwnProperty(key)) {
        // If the keyword matches, add the emoji to an array of options.
        if (emojis[key].keywords && emojis[key].keywords.indexOf(program.args[1]) > -1) {
          options.push(key);
        }
      }
    }

    // If any options have been found, return a random option.
    if (options.length > 0) {
      return ' :' + options[Math.floor(Math.random() * options.length)] + ': ';
    // If there are no options, just get a random emoji from the library.
    } else {
      var result;
      var count = 0;

      for (var prop in emojis) {
        if (Math.random() < 1 / ++count) {
          result = prop;
        }
      }

      return ':' + result + ': ';
    }
  // If no keyword is supplied, get a random emoji from the library.
  } else {
    var result;
    var count = 0;

    for (var prop in emojis) {
      if (Math.random() < 1 / ++count) {
        result = prop;
      }
    }

{'fraction_non_alphanumeric': 0.1466065747613998, 'fraction_numerical': 0.006627783669141039, 'mean_word_length': 2.3868940754039496, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5018707', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1243, 'n_words': 408}