<commit_before>'use strict';

require('./check-deps');

var chalk = require('chalk'),
    inquirer = require('inquirer');

var CommonUtil = {};

CommonUtil.header = function(grunt, msg, color) {
  msg = color ? chalk[color](msg) : msg;
  var line = Array(msg.length + 1).join('-');
  line = color ? chalk[color](line) : line;

  grunt.log.subhead(msg);
  grunt.log.writeln(line);
};

CommonUtil.createPrompt = function(input, options) {
  options = options || {};

  var prompt = {
    name: input.key,
    message: input.label,
    type: 'input'
  };

  if(input.description) {
    prompt.message += ' [' + input.description + ']';
  }

  // Required
  if(input.required) {
    prompt.message = prompt.message + '*';
    if(options.validateRequired) {
      prompt.validate = function(item) {
        return !!item;
      };
    }
  }

  // Select type
  if(input.type === 'select') {
    prompt.type = 'list';
    prompt.choices = input.input_options.map(function(choice) {
      return {
        name: choice.label,
        value: choice.value
      };
    });
    if(!input.required || !options.validateRequired) {
      prompt.choices.unshift({
        name: '(none)',
        value: ''
      });
    }
  } else if(input.type === 'datetime') {
    prompt.message += ' ⌚ ';
  } else if(input.type === 'boolean') {
    prompt.message += ' ☯ ';
  }

  prompt.message = prompt.message += ':';<commit_msg>Fixed NPE for older runs.json files<commit_after>'use strict';

require('./check-deps');

var chalk = require('chalk'),
    inquirer = require('inquirer');

var CommonUtil = {};

CommonUtil.header = function(grunt, msg, color) {
  msg = color ? chalk[color](msg) : msg;
  var line = Array(msg.length + 1).join('-');
  line = color ? chalk[color](line) : line;

  grunt.log.subhead(msg);
  grunt.log.writeln(line);
};

CommonUtil.createPrompt = function(input, options) {
  options = options || {};

  var prompt = {
    name: input.key,
    message: input.label,
    type: 'input'
  };

  if(input.description) {
    prompt.message += ' [' + input.description + ']';
  }

  // Required
  if(input.required) {
    prompt.message = prompt.message + '*';
    if(options.validateRequired) {
      prompt.validate = function(item) {
        return !!item;
      };
    }
  }

  // Select type
  if(input.type === 'select') {
    prompt.type = 'list';
    if(input.input_options) {
      prompt.choices = input.input_options.map(function(choice) {
        return {
          name: choice.label,
          value: choice.value
        };
      });
      if(!input.required || !options.validateRequired) {
        prompt.choices.unshift({
          name: '(none)',
          value: ''
        });
      }
    }

  } else if(input.type === 'datetime') {
    prompt.message += ' ⌚ ';
  } else if(input.type === 'boolean') {
    prompt.message += ' ☯ ';
  }

  prompt.message = prompt.message += ':';
{'fraction_non_alphanumeric': 0.17836156239198064, 'fraction_numerical': 0.000691323885240235, 'mean_word_length': 2.5728395061728393, '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': '5680025', 'n_tokens_mistral': 982, 'n_tokens_neox': 952, 'n_words': 174}