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

var program = require('commander');

program
  .arguments('<url>')
  .option('-s --save-image <path>', 'Write PNG screenshot to <path>')
  .action(run)
  .parse(process.argv);

if(!process.argv.slice(2).length) {
  program.outputHelp();
}

function run(url) {
  var path = require('path');
  var childProcess = require('child_process');
  var phantomjs = require('phantomjs-prebuilt');
  var binPath = phantomjs.path;

  var childArgs = [
    path.join(__dirname, 'renderdom.js'),
    url
  ]

  if(program.saveImage) {
    childArgs.push(program.saveImage)
  }

  var child = childProcess.spawn(binPath, childArgs);
  child.stdout.on('data', function(data) {
    process.stdout.write(data);
  });
  child.stderr.on('data', function(data) {
    process.stderr.write(data);
  })
  child.on('close', function(code) {
    if(code !== 0) {
      process.stderr.write("WARN: child process exited with non-zero code: " + code);
    }
  });
}
<commit_msg>Read info from package.json<commit_after>#!/usr/bin/env node

var program = require('commander');
var package = require('./package.json');

program
  .arguments('<url>')
  .description(package.description)
  .version(package.version)
  .option('-s --save-image <path>', 'Write PNG screenshot to <path>')
  .action(run)
  .parse(process.argv);

if(!process.argv.slice(2).length) {
  program.outputHelp();
}

function run(url) {
  var path = require('path');
  var childProcess = require('child_process');
  var phantomjs = require('phantomjs-prebuilt');
  var binPath = phantomjs.path;

  var childArgs = [
    path.join(__dirname, 'renderdom.js'),
    url
  ]

  if(program.saveImage) {
    childArgs.push(program.saveImage)
  }

  var child = childProcess.spawn(binPath, childArgs);
  child.stdout.on('data', function(data) {
    process.stdout.write(data);
  });
  child.stderr.on('data', function(data) {
    process.stderr.write(data);
  })
  child.on('close', function(code) {
    if(code !== 0) {
      process.stderr.write("WARN: child process exited with non-zero code: " + code);
    }
  });
}

{'fraction_non_alphanumeric': 0.17441303306181122, 'fraction_numerical': 0.0019166267369429804, 'mean_word_length': 3.8333333333333335, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3445160', 'n_tokens_mistral': 726, 'n_tokens_neox': 701, 'n_words': 132}