<commit_before>var riot = require('riot')
var path = require('path')

/**
 * Configure Riot Preprocessor to compile all tags
 * @param {array} args - args
 * @param {array} config - config
 * @param {array} logger - logger
 * @param {array} helper - helper
 * @returns {function} preprocessor
 */
function createRiotPreprocessor(args, config, logger, helper) {
  config = config || {}

  var log = logger.create('preprocessor.riot')
  var options = helper.merge(args.options || {}, config.options || {})

  return function(content, file, done) {
    var result = null
    log.debug('Processing "%s".', file.originalPath)
    if (!/\.js$/.test(file.path)) file.path = file.path + '.js'
    try {
      result = riot.compile(content, options)
    } catch (e) {
      log.error('%s\n  at %s:%d', e.message, file.originalPath, e.location.first_line)
      return done(e, null)
    }
    done(null, result)
  }
}
createRiotPreprocessor.$inject = ['args', 'config.riotPreprocessor', 'logger', 'helper']

/**
 * Configure Riot framework to be included in the DOM during testing<commit_msg>Fix a bug of '[TypeError: Cannot read property 'first_line' of undefined]'<commit_after>var riot = require('riot')
var path = require('path')

/**
 * Configure Riot Preprocessor to compile all tags
 * @param {array} args - args
 * @param {array} config - config
 * @param {array} logger - logger
 * @param {array} helper - helper
 * @returns {function} preprocessor
 */
function createRiotPreprocessor(args, config, logger, helper) {
  config = config || {}

  var log = logger.create('preprocessor.riot')
  var options = helper.merge(args.options || {}, config.options || {})

  return function(content, file, done) {
    var result = null
    log.debug('Processing "%s".', file.originalPath)
    if (!/\.js$/.test(file.path)) file.path = file.path + '.js'
    try {
      result = riot.compile(content, options)
    } catch (e) {
      if (!e) {
        log.error('%s\n  at %s:%d', e.message, file.originalPath, e.location.first_line)
	  }
      return done(e, null)
    }
    done(null, result)
  }
}
createRiotPreprocessor.$inject = ['args', 'config.riotPreprocessor', 'logger', 'helper']

/**
 * Configure Riot framework to be included in the DOM during testing
{'fraction_non_alphanumeric': 0.15569395017793594, 'fraction_numerical': 0.0, 'mean_word_length': 3.571138211382114, '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': '6751589', 'n_tokens_mistral': 710, 'n_tokens_neox': 694, 'n_words': 200}