<commit_before>module.exports = function(query, defBinds, useDefaults, spinner, moduleCallback) {
  //read query, check binds, prompt or use defBinds


  var qBinds = [],
    //remove comments
    sql = query.replace(/\/\*[.\s\S]*?\*\/|--.*?[\n\r]/g, ''),
    //find binds
    //bindPattern = /[:].[a-z_0-9]+/g;
    //now bind pattern ignores : inside quotes (date formats)
    bindPattern = /[:].[A-Za-z_0-9]+(?=([^']*'[^']*')*[^']*$)/g;

  while (result = bindPattern.exec(sql)) {
    var r = result[0].replace(':', '');
    if (qBinds.indexOf(r) == -1) qBinds.push(r);
  }

  function replaceBinds(query, binds) {
    for (var i = 0; i < qBinds.length; i++) {
      try {
        //try replacing all binds with default
        query = query.replace(new RegExp(':' + qBinds[i], "g"), binds[qBinds[i]]);
      } catch (e) {
        return moduleCallback('Problem finding bind for "' + r + '"' + e);
      }
    }
    return query;
  }

  if (useDefaults) {
    //return formatted query
    return moduleCallback(null, replaceBinds(sql, defBinds), defBinds);
  }



  //if not using defBinds, prompt

  var prompt = require('prompt'),
    colors = require('colors'),
    prompts = {
      properties: {

      }
    };

  prompt.message = colors.green('Enter bind variable');

  for (var i = 0; i < qBinds.length; i++) {
    prompts.properties[qBinds[i]] = {
      default: defBinds[qBinds[i]],
      description: colors.green(qBinds[i])
    }
  }

  spinner.stop(true);
  prompt.start();
  prompt.get(prompts, function(err, result) {
    if (err) return moduleCallback(err);
    spinner.start();
    moduleCallback(null, replaceBinds(sql, result), result);
  });
}<commit_msg>change to opt object, fix spinner<commit_after>module.exports = function(query, opt, moduleCallback) {
  //read query, check binds, prompt or use defBinds

  var qBinds = [],
    //remove comments
    sql = query.replace(/\/\*[.\s\S]*?\*\/|--.*?[\n\r]/g, ''),
    //find binds
    //bindPattern = /[:].[a-z_0-9]+/g;
    //now bind pattern ignores : inside quotes (date formats)
    bindPattern = /[:].[A-Za-z_0-9]+(?=([^']*'[^']*')*[^']*$)/g,
    defBinds = opt.cfg.defaultBindVars,
    spinner = opt.spinner;

  while (result = bindPattern.exec(sql)) {
    var r = result[0].replace(':', '');
    if (qBinds.indexOf(r) == -1) qBinds.push(r);
  }

  function replaceBinds(query, binds) {
    for (var i = 0; i < qBinds.length; i++) {
      try {
        //try replacing all binds with default
        query = query.replace(new RegExp(':' + qBinds[i], "g"), binds[qBinds[i]]);
      } catch (e) {
        return moduleCallback('Problem finding bind for "' + r + '"' + e);
      }
    }
    return query;
  }

  //return formatted query
  if (opt.binds) return moduleCallback(null, replaceBinds(sql, defBinds), defBinds);

  //if not using defBinds, prompt
  var prompt = require('prompt'),
    colors = require('colors'),
    prompts = {
      properties: {

      }
    };

  prompt.message = colors.green('Enter bind variable');

  for (var i = 0; i < qBinds.length; i++) {
    prompts.properties[qBinds[i]] = {
      default: defBinds[qBinds[i]],
      description: colors.green(qBinds[i])
    }
  }

  if (spinner) spinner.stop(true);
  prompt.start();
  prompt.get(prompts, function(err, result) {
    if (err) return moduleCallback(err);
    if (spinner) spinner.start();
    moduleCallback(null, replaceBinds(sql, result), result);
  });
}
{'fraction_non_alphanumeric': 0.1896551724137931, 'fraction_numerical': 0.004675628287551139, 'mean_word_length': 2.846067415730337, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3050874', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1189, 'n_words': 271}