<commit_before>var http        = require('http'),
    url             = require('url'),
    request         = require('request'),
    fs              = require('fs'),
    path            = require('path'),
    stream          = require('stream'),
    
    options         = {},
    optionsFile     = process.cwd() + '/options.json',
    defaultOptions  = {
      data: './data/',
      host: 'localhost',
      port: 8000
    };

// OPTIONS
if ( ! fs.existsSync( optionsFile )) {
  fs.writeFile( optionsFile, JSON.stringify( defaultOptions, null, ' ' ), function( err ) {

    if ( err ) {
      console.log('ERROR occured while writing default options');
    }
  });
  options = defaultOptions;
  console.log('created a default options file for you ('+optionsFile+')');

} else {
  options = require( optionsFile );
}

// DATA DIR
if ( ! fs.existsSync( options.data ) || ! fs.statSync( options.data ).isDirectory()) {
  console.log('Please ensure that data directory exists...');
  process.exit(1);
}

// LOCAL PROXY SUPPORT
var requestDefaults = {};
if ( process.env.HTTP_PROXY ) {
  requestDefaults.proxy = process.env.HTTP_PROXY;
}
var r = request.defaults( requestDefaults );


http.createServer( function(req, res ) {

  var urlPath = url.parse( req.url ).path;
  console.log( Date().toLocaleString(), req.connection.remoteAddress, urlPath );

  if (!urlPath.match(/\.tgz$/g)) {
    return r.get('http://registry.npmjs.org' + req.url,
        function( err, response, body ) {

          try {
            body = JSON.parse( body );
          } catch( e ) {}

          versions = body.versions,
          name = body.name;
<commit_msg>ensure default version and name values<commit_after>var http        = require('http'),
    url             = require('url'),
    request         = require('request'),
    fs              = require('fs'),
    path            = require('path'),
    stream          = require('stream'),
    
    options         = {},
    optionsFile     = process.cwd() + '/options.json',
    defaultOptions  = {
      data: './data/',
      host: 'localhost',
      port: 8000
    };

// OPTIONS
if ( ! fs.existsSync( optionsFile )) {
  fs.writeFile( optionsFile, JSON.stringify( defaultOptions, null, ' ' ), function( err ) {

    if ( err ) {
      console.log('ERROR occured while writing default options');
    }
  });
  options = defaultOptions;
  console.log('created a default options file for you ('+optionsFile+')');

} else {
  options = require( optionsFile );
}

// DATA DIR
if ( ! fs.existsSync( options.data ) || ! fs.statSync( options.data ).isDirectory()) {
  console.log('Please ensure that data directory exists...');
  process.exit(1);
}

// LOCAL PROXY SUPPORT
var requestDefaults = {};
if ( process.env.HTTP_PROXY ) {
  requestDefaults.proxy = process.env.HTTP_PROXY;
}
var r = request.defaults( requestDefaults );


http.createServer( function(req, res ) {

  var urlPath = url.parse( req.url ).path;
  console.log( Date().toLocaleString(), req.connection.remoteAddress, urlPath );

  if (!urlPath.match(/\.tgz$/g)) {
    return r.get('http://registry.npmjs.org' + req.url,
        function( err, response, body ) {

          try {
            body = JSON.parse( body );
          } catch( e ) {}

          versions = body.versions || [],
          name = body.name || '';

{'fraction_non_alphanumeric': 0.15537488708220415, 'fraction_numerical': 0.0030111412225233363, 'mean_word_length': 2.410677618069815, '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': '3324967', 'n_tokens_mistral': 1014, 'n_tokens_neox': 981, 'n_words': 237}