<commit_before>/**
 * Hooks into `require()` to watch for modifications of the required
 * file. If a modification is detected, the process exits with code
 * `101`.
 */

/**
 * Module dependencies.
 */
var fs = require('fs');
var Path = require('path');

/**
 * Watches the given module's filename.
 */
function watch(module) {
  if (!module.loaded) {
    fs.watchFile(module.filename, {interval : 500, persistent: false}, function(cur, prev) {
      if (cur && +cur.mtime !== +prev.mtime) {
        process.exit(101);
      }
    });
  }
}

/**
 * This is how the argv array looks like:
 * `['node', '/path/to/wrapper.js', '--option1', '--optionN', 'script', 'arg1', 'argN']`
 * ... so we remove ourself:
 */
process.argv.splice(1, 1);

/** Find the first arg that is not an option, starting at index 1 */
var arg;
for (var i=1; i < process.argv.length; i++) {
  arg = process.argv[i];
  if (!/^-/.test(arg)) {
    break;
  }
}

/** Resolve the location of the main script relative to cwd */
var main = Path.resolve(process.cwd(), arg);

/** Hook into `require()` */
function hookInto(ext) {
  var extensionHandler = require.extensions[ext];
  require.extensions[ext] = function(module, filename) {
    if (module.id == main) {
      module.id = '.';
      module.parent = null;
      process.mainModule = module;
    }
    watch(module);
    extensionHandler(module, filename);
    if (ext == '.js' && Path.basename(filename, ext) == 'coffee-script') {
      hookInto('.coffee');
    }
  };
}

hookInto('.js');

if (Path.extname(main) == '.coffee') {
  require('coffee-script');
}

/** Load the wrapped script */
require(main);<commit_msg>Added new line at eof<commit_after>/**
 * Hooks into `require()` to watch for modifications of the required
 * file. If a modification is detected, the process exits with code
 * `101`.
 */

/**
 * Module dependencies.
 */
var fs = require('fs');
var Path = require('path');

/**
 * Watches the given module's filename.
 */
function watch(module) {
  if (!module.loaded) {
    fs.watchFile(module.filename, {interval : 500, persistent: false}, function(cur, prev) {
      if (cur && +cur.mtime !== +prev.mtime) {
        process.exit(101);
      }
    });
  }
}

/**
 * This is how the argv array looks like:
 * `['node', '/path/to/wrapper.js', '--option1', '--optionN', 'script', 'arg1', 'argN']`
 * ... so we remove ourself:
 */
process.argv.splice(1, 1);

/** Find the first arg that is not an option, starting at index 1 */
var arg;
for (var i=1; i < process.argv.length; i++) {
  arg = process.argv[i];
  if (!/^-/.test(arg)) {
    break;
  }
}

/** Resolve the location of the main script relative to cwd */
var main = Path.resolve(process.cwd(), arg);

/** Hook into `require()` */
function hookInto(ext) {
  var extensionHandler = require.extensions[ext];
  require.extensions[ext] = function(module, filename) {
    if (module.id == main) {
      module.id = '.';
      module.parent = null;
      process.mainModule = module;
    }
    watch(module);
    extensionHandler(module, filename);
    if (ext == '.js' && Path.basename(filename, ext) == 'coffee-script') {
      hookInto('.coffee');
    }
  };
}

hookInto('.js');

if (Path.extname(main) == '.coffee') {
  require('coffee-script');
}

/** Load the wrapped script */
require(main);

{'fraction_non_alphanumeric': 0.18524142119647738, 'fraction_numerical': 0.009110233829334954, 'mean_word_length': 3.107231920199501, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2515495', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1078, 'n_words': 307}