<commit_before>
/**
 * Don't allow multiple copies of this module
 * because that would mess everything up.
 */

if (global.EXIT_THEN_1) {
  console.error('Another copy of `exit-then` was found. Please `npm dedupe`.')
  module.exports = global.EXIT_THEN_1
  return
}

var Promise = require('native-or-bluebird')
var timeout = require('timeout-then')

var fns = module.exports = []

/**
 * Custom minimum timeout interval.
 */

var EXIT_TIMEOUT = parseInt(process.env.EXIT_TIMEOUT, 0) || 0
if (EXIT_TIMEOUT) fns.push(function () {
  return timeout(EXIT_TIMEOUT)
})

process.on('SIGINT', onexit)
process.on('SIGTERM', onexit)
process.on('uncaughtException', function (err) {
  console.error(err.stack)
  onexit(err)
})

function onexit(err) {
  if (!(err instanceof Error)) err = null
  Promise.all(fns.map(function (fn) {
    return fn(err)
  })).then(function () {
    process.exit(0)
  }).catch(function (err) {
    console.error(err.stack)
    process.exit(1)
  })
}
<commit_msg>make a global reference. duh<commit_after>
/**
 * Don't allow multiple copies of this module
 * because that would mess everything up.
 */

if (global.EXIT_THEN_1) {
  console.error('Another copy of `exit-then` was found. Please `npm dedupe`.')
  module.exports = global.EXIT_THEN_1
  return
}

var Promise = require('native-or-bluebird')
var timeout = require('timeout-then')

var fns = module.exports = []

/**
 * Make a global version based on version.
 */
 
global.EXIT_THEN_1 = {
  fns: fns,
  onexit: onexit
}

/**
 * Custom minimum timeout interval.
 */

var EXIT_TIMEOUT = parseInt(process.env.EXIT_TIMEOUT, 0) || 0
if (EXIT_TIMEOUT) fns.push(function () {
  return timeout(EXIT_TIMEOUT)
})

process.on('SIGINT', onexit)
process.on('SIGTERM', onexit)
process.on('uncaughtException', function (err) {
  console.error(err.stack)
  onexit(err)
})

function onexit(err) {
  if (!(err instanceof Error)) err = null
  Promise.all(fns.map(function (fn) {
    return fn(err)
  })).then(function () {
    process.exit(0)
  }).catch(function (err) {
    console.error(err.stack)
    process.exit(1)
  })
}

{'fraction_non_alphanumeric': 0.1510791366906475, 'fraction_numerical': 0.006235011990407674, 'mean_word_length': 3.9785202863961815, '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': '6354020', 'n_tokens_mistral': 732, 'n_tokens_neox': 741, 'n_words': 172}