<commit_before>
var sys = require("sys");
var fs = require("fs");
var spawn = require("child_process").spawn;
var fileExtensionPattern;

exports.run = run;

function run (args) {
  var arg, next, watch, program, extensions, executor;
  while (arg = args.shift()) {
    if (arg === "--help" || arg === "-h" || arg === "-?") {
      return help();
    } else if (arg === "--watch" || arg === "-w") {
      watch = args.shift();
    } else if (arg === "--extensions" || arg === "-e") {
      extensions = args.shift();
    } else if (arg === "--exec" || arg === "-x") {
      executor = args.shift();
    } else if (arg.indexOf("-") && !args.length) {
      // Assume last arg is the program
      program = arg;
    }
  }
  if (!program) {
    return help();
  }
  if (!watch) {
    watch = ".";
  }

  var programExt = program.match(/.*\.(.*)/);
  programExt = programExt && programExt[1];

  if (!extensions) {
    // If no extensions passed try to guess from the program
    extensions = "node|js";
    if (programExt && extensions.indexOf(programExt) == -1)
      extensions += "|" + programExt;
  }
  fileExtensionPattern = new RegExp(".*\.(" + extensions + ")");
  
  if (!executor) {
    executor = (programExt === "coffee") ? "coffee" : "node";
  }
  
  sys.puts("")
  sys.debug("Running node-supervisor with");<commit_msg>Stricter matching of file extensions<commit_after>
var sys = require("sys");
var fs = require("fs");
var spawn = require("child_process").spawn;
var fileExtensionPattern;

exports.run = run;

function run (args) {
  var arg, next, watch, program, extensions, executor;
  while (arg = args.shift()) {
    if (arg === "--help" || arg === "-h" || arg === "-?") {
      return help();
    } else if (arg === "--watch" || arg === "-w") {
      watch = args.shift();
    } else if (arg === "--extensions" || arg === "-e") {
      extensions = args.shift();
    } else if (arg === "--exec" || arg === "-x") {
      executor = args.shift();
    } else if (arg.indexOf("-") && !args.length) {
      // Assume last arg is the program
      program = arg;
    }
  }
  if (!program) {
    return help();
  }
  if (!watch) {
    watch = ".";
  }

  var programExt = program.match(/.*\.(.*)/);
  programExt = programExt && programExt[1];

  if (!extensions) {
    // If no extensions passed try to guess from the program
    extensions = "node|js";
    if (programExt && extensions.indexOf(programExt) == -1)
      extensions += "|" + programExt;
  }
  fileExtensionPattern = new RegExp("^.*\.(" + extensions + ")$");
  
  if (!executor) {
    executor = (programExt === "coffee") ? "coffee" : "node";
  }
  
  sys.puts("")
  sys.debug("Running node-supervisor with");
{'fraction_non_alphanumeric': 0.2094670145359672, 'fraction_numerical': 0.0014908684308609765, 'mean_word_length': 2.7123098201936378, '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': '2177322', 'n_tokens_mistral': 877, 'n_tokens_neox': 866, 'n_words': 241}