<commit_before>/* globals play test */
const fs = require('fs')
const vm = require('vm')
const chalk = require('chalk')
const jsmin = require('jsmin').jsmin

// handle 'message' event from parent
process.on('message', files => {
  try {
    let [inputFile, outputFile] = files
    console.log(chalk.bold('Loading script...'))
    vm.runInThisContext(fs.readFileSync(inputFile))
     // check for play function
    if (typeof play !== 'function') {
      throw new Error(`No 'play' function defined in ${inputFile}.`)
    }
    // now run test
    console.log(chalk.bold('Calling test function...'))
    if (typeof test === 'function') {
      // run test
      let success = test()
      console.log(`   ${success ? chalk.bgGreen('test passed') : chalk.bgRed('test failed')}`)
      if (!success) {
        throw new Error('Test function reported a failure.')
      }
    } else {
      console.log(chalk.yellow('**No test function**'))
    }
    // determine strokes
    let strokes = jsmin(play.toString(), 3).replace(/^\n+/, '').length
    console.log(`Completed in ${chalk.green.bold(strokes)} strokes`)
    // write out file
    fs.writeFile(outputFile, `let play=${play.toString()}`, err => {
      if (err) { throw err }
      console.log(chalk.green(`Output written to ${outputFile}`))
      process.send('')
    })
  } catch (error) {
    console.log(chalk.red(error.stack))
    process.send({error: error})
  }
})<commit_msg>Fixed stroke count and template.<commit_after>/* globals play test */
const fs = require('fs')
const vm = require('vm')
const chalk = require('chalk')
const jsmin = require('jsmin').jsmin

// handle 'message' event from parent
process.on('message', files => {
  try {
    let [inputFile, outputFile] = files
    console.log(chalk.bold('Loading script...'))
    vm.runInThisContext(fs.readFileSync(inputFile))
     // check for play function
    if (typeof play !== 'function') {
      throw new Error(`No 'play' function defined in ${inputFile}.`)
    }
    // now run test
    console.log(chalk.bold('Calling test function...'))
    if (typeof test === 'function') {
      // run test
      let success = test()
      console.log(`   ${success ? chalk.bgGreen('test passed') : chalk.bgRed('test failed')}`)
      if (!success) {
        throw new Error('Test function reported a failure.')
      }
    } else {
      console.log(chalk.yellow('**No test function**'))
    }
    // determine strokes
    let script = `let play=${play.toString()}`
    let strokes = jsmin(script, 3).replace(/^\n+/, '').length
    console.log(`Completed in ${chalk.green.bold(strokes)} strokes`)
    // write out file
    fs.writeFile(outputFile, script, err => {
      if (err) { throw err }
      console.log(chalk.green(`Output written to ${outputFile}`))
      process.send('')
    })
  } catch (error) {
    console.log(chalk.red(error.stack))
    process.send({error: error})
  }
})
{'fraction_non_alphanumeric': 0.16976584022038568, 'fraction_numerical': 0.0006887052341597796, 'mean_word_length': 2.9958734525447044, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4767092', 'n_tokens_mistral': 900, 'n_tokens_neox': 885, 'n_words': 233}