<commit_before>#!/usr/bin/env node

var readFileSync = require('fs').readFileSync;
var Promise = require('es6-promise').Promise; // jshint ignore:line

main();

function main() {
  var argv = require('./options')(process.argv.slice(2));

  if (argv.debug) {
    require('debug').enable('inliner');
  }

  var url = argv._.shift();

  if (argv.version) {
    console.log(require('../package.json').version || 'development');
    process.exit(0);
  }

  if ((!url && !argv.useStdin) || argv.help) {
    var usage = readFileSync(
      __dirname + '/../docs/usage.txt', 'utf8'
    );
    console.log(usage);
    process.exit(0);
  }

  var Inliner = require('../');

  var p = Promise.resolve(url);

  if (argv.useStdin) {
    p = new Promise(function (resolve) {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');

      var data = '';

      process.stdin.on('data', function(chunk) {
        data += chunk;
      });

      process.stdin.on('end', function() {
        resolve(data);
      });
    });
  }

  p.then(function (source) {
    var inliner = new Inliner(source, argv, function result(error, html) {
      if (error) {
        var message = Inliner.errors[error.code] || error.message;
        console.error(message);

        if (argv.debug) {
          console.error(error.stack);
        }<commit_msg>chore: fix linting issues<commit_after>#!/usr/bin/env node

var readFileSync = require('fs').readFileSync;
var Promise = require('es6-promise').Promise; // jshint ignore:line

main();

function main() {
  var argv = require('./options')(process.argv.slice(2));

  if (argv.debug) {
    require('debug').enable('inliner');
  }

  var url = argv._.shift();

  if (argv.version) {
    console.log(require('../package.json').version || 'development');
    process.exit(0);
  }

  if ((!url && !argv.useStdin) || argv.help) {
    var usage = readFileSync(
      __dirname + '/../docs/usage.txt', 'utf8'
    );
    console.log(usage);
    process.exit(0);
  }

  var Inliner = require('../');

  var p = Promise.resolve(url);

  if (argv.useStdin) {
    p = new Promise(function (resolve) {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');

      var data = '';

      process.stdin.on('data', function (chunk) {
        data += chunk;
      });

      process.stdin.on('end', function () {
        resolve(data);
      });
    });
  }

  p.then(function (source) {
    var inliner = new Inliner(source, argv, function result(error, html) {
      if (error) {
        var message = Inliner.errors[error.code] || error.message;
        console.error(message);

        if (argv.debug) {
          console.error(error.stack);
        }
{'fraction_non_alphanumeric': 0.18144560357675113, 'fraction_numerical': 0.004470938897168405, 'mean_word_length': 2.6088709677419355, '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': '3891859', 'n_tokens_mistral': 914, 'n_tokens_neox': 876, 'n_words': 168}