<commit_before>#!/usr/bin/env node
var sprintf = require('util').format

var chalk = require('chalk')

var cli = require('../lib/cli')
  , lib = require('../lib')

var error = chalk.bold.red

module.exports = {
    exit: onExit
  , cli: onCli
}

cli(process.argv.slice(2), onCli)

function onCli(err, message, options) {
  if(err) {
    console.error(
        error(
            '\nYou had errors in your syntax. ' +
              'Use --help for further information.'
        )
    )
    err.forEach(function(e) {
      console.error(e.message)
    })

    return
  } else if(message) {
    console.log(message)

    return
  }

  lib(options, process, onExit)
}

function onExit(code, signal) {
  if(code > 0) {
    console.error(sprintf('\nphantomjs exited abnormally: %d'), code)
  }

  process.exit(code || signal === 'SIGTERM' ? 0 : 1)
}
<commit_msg>Don't ignore exit code on SIGTERM<commit_after>#!/usr/bin/env node
var sprintf = require('util').format

var chalk = require('chalk')

var cli = require('../lib/cli')
  , lib = require('../lib')

var error = chalk.bold.red

module.exports = {
    exit: onExit
  , cli: onCli
}

cli(process.argv.slice(2), onCli)

function onCli(err, message, options) {
  if(err) {
    console.error(
        error(
            '\nYou had errors in your syntax. ' +
              'Use --help for further information.'
        )
    )
    err.forEach(function(e) {
      console.error(e.message)
    })

    return
  } else if(message) {
    console.log(message)

    return
  }

  lib(options, process, onExit)
}

function onExit(code, signal) {
  if(code > 0) {
    console.error(sprintf('\nphantomjs exited abnormally: %d'), code)
  }

  process.exit(code || (signal === 'SIGTERM' ? 0 : 1))
}

{'fraction_non_alphanumeric': 0.15628604382929642, 'fraction_numerical': 0.00461361014994233, 'mean_word_length': 2.584710743801653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1253153', 'n_tokens_mistral': 631, 'n_tokens_neox': 603, 'n_words': 137}