<commit_before>var readline = require('readline');
var fs = require('fs');
var util = require('util');
var path = require('path');
var glob = require('glob');

var helper = require('./helper');
var logger = require('./logger');
var constant = require('./constants');

var log = logger.create('init');

var JS_TPL_PATH = __dirname + '/../config.tpl.js';
var COFFEE_TPL_PATH = __dirname + '/../config.tpl.coffee';


var COLORS_ON = {
  END: '\x1B[39m',
  NYAN: '\x1B[36m',
  GREEN: '\x1B[32m',
  BOLD: '\x1B[1m',
  bold: function(str) {
    return this.BOLD + str + '\x1B[22m';
  },
  green: function(str) {
    return this.GREEN + str + this.END;
  }
};

// nasty global
var colors = COLORS_ON;

var COLORS_OFF = {
  END: '',
  NYAN: '',
  GREEN: '',
  BOLD: '',
  bold: function(str) {
    return str;
  },
  green: function(str) {
    return str;
  }
};

var validatePattern = function(value) {
  if (!glob.sync(value).length) {
    log.warn('There is no file matching this pattern.\n' + colors.NYAN);
  }
};


var validateBrowser = function(name) {
  var moduleName = 'karma-' + name.toLowerCase().replace('canary', '') + '-launcher';

  try {
    require(moduleName);
  } catch (e) {
    log.warn('Missing "%s" plugin.\n  npm install %s --save-dev' + colors.NYAN, moduleName, moduleName);
  }

  // TODO(vojta): check if the path resolves to a binary
};

var validateFramework = function(name) {
  try {
    require('karma-' + name);
  } catch (e) {
    log.warn('Missing "karma-%s" plugin.\n  npm install karma-%s --save-dev' + colors.NYAN, name, name);
  }
};

var validateRequireJs = function(useRequire) {
  if (useRequire) {
    validateFramework('requirejs');
  }
};


var questions = [{
  id: 'framework',
  question: 'Which testing framework do you want to use ?',
  hint: 'Press tab to list possible options. Enter to move to the next question.',
  options: ['jasmine', 'mocha', 'qunit', ''],
  validate: validateFramework
}, {
  id: 'requirejs',
  question: 'Do you want to use Require.js ?',
  hint: 'This will add Require.js plugin.\n' +
        'Press tab to list possible options. Enter to move to the next question.',
  options: ['no', 'yes'],
  validate: validateRequireJs,
  boolean: true
}, {
  id: 'browsers',
  question: 'Do you want to capture a browser automatically ?',<commit_msg>style: make jshint happy<commit_after>var readline = require('readline');
var fs = require('fs');
var util = require('util');
var path = require('path');
var glob = require('glob');

var helper = require('./helper');
var logger = require('./logger');
var constant = require('./constants');

var log = logger.create('init');

var JS_TPL_PATH = __dirname + '/../config.tpl.js';
var COFFEE_TPL_PATH = __dirname + '/../config.tpl.coffee';


var COLORS_ON = {
  END: '\x1B[39m',
  NYAN: '\x1B[36m',
  GREEN: '\x1B[32m',
  BOLD: '\x1B[1m',
  bold: function(str) {
    return this.BOLD + str + '\x1B[22m';
  },
  green: function(str) {
    return this.GREEN + str + this.END;
  }
};

// nasty global
var colors = COLORS_ON;

var COLORS_OFF = {
  END: '',
  NYAN: '',
  GREEN: '',
  BOLD: '',
  bold: function(str) {
    return str;
  },
  green: function(str) {
    return str;
  }
};

var validatePattern = function(value) {
  if (!glob.sync(value).length) {
    log.warn('There is no file matching this pattern.\n' + colors.NYAN);
  }
};


var validateBrowser = function(name) {
  var moduleName = 'karma-' + name.toLowerCase().replace('canary', '') + '-launcher';

  try {
    require(moduleName);
  } catch (e) {
    log.warn('Missing "%s" plugin.\n  npm install %s --save-dev' + colors.NYAN, moduleName,
        moduleName);
  }

  // TODO(vojta): check if the path resolves to a binary
};

var validateFramework = function(name) {
  try {
    require('karma-' + name);
  } catch (e) {
    log.warn('Missing "karma-%s" plugin.\n  npm install karma-%s --save-dev' + colors.NYAN, name,
        name);
  }
};

var validateRequireJs = function(useRequire) {
  if (useRequire) {
    validateFramework('requirejs');
  }
};


var questions = [{
  id: 'framework',
  question: 'Which testing framework do you want to use ?',
  hint: 'Press tab to list possible options. Enter to move to the next question.',
  options: ['jasmine', 'mocha', 'qunit', ''],
  validate: validateFramework
}, {
  id: 'requirejs',
  question: 'Do you want to use Require.js ?',
  hint: 'This will add Require.js plugin.\n' +
        'Press tab to list possible options. Enter to move to the next question.',
  options: ['no', 'yes'],
  validate: validateRequireJs,
  boolean: true
}, {
  id: 'browsers',
  question: 'Do you want to capture a browser automatically ?',
{'fraction_non_alphanumeric': 0.17173023055375997, 'fraction_numerical': 0.006033182503770739, 'mean_word_length': 3.4041745730550286, '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': '1241687', 'n_tokens_mistral': 1619, 'n_tokens_neox': 1592, 'n_words': 449}