<commit_before>var walkSync = require('./utilities/walk-sync').walkSync,
    fs = require('fs-extra'),
    chalk = require('chalk'),
    RSVP = require("rsvp"),
    _ = require('lodash-node'),
    path = require('path');

RSVP.on("error", function(error) {
  console.error(error);
  console.error(error.stack);
});

function keypress(stdin) {
  return new RSVP.Promise(function(resolve) {
    stdin.once("data", function(data) {
      resolve(data.toString().trim());
    });
  });
}

function confirm(question, callback) {
  var stdin = process.stdin, stdout = process.stdout;

  stdin.resume();
  stdout.write(question + " (y/n) ");
  stdin.setRawMode(true);

  return new RSVP.Promise(function(resolve, reject) {
    keypress(stdin).then(function(data) {
      console.log("got data: ", data);

      if(data == "y") {
        resolve(true);<commit_msg>Refactor stdin event-handling for eventual use of denodeify<commit_after>var walkSync = require('./utilities/walk-sync').walkSync,
    fs = require('fs-extra'),
    chalk = require('chalk'),
    RSVP = require("rsvp"),
    _ = require('lodash-node'),
    path = require('path');

RSVP.on("error", function(error) {
  console.error(error);
  console.error(error.stack);
});

// Wnat to use denodeify around stdin.once, but couldn't.
// Got some kind of undefined error down in once
function prompt() {
  return new RSVP.Promise(function(resolve, reject) {
    process.stdin.once("data", function(data) {
      resolve(data);
    });
  });
}

function keypress(stdin) {
  return prompt().then(function(data) {
    return data.toString().trim();
  });
}

function confirm(question, callback) {
  var stdin = process.stdin, stdout = process.stdout;

  stdin.resume();
  stdout.write(question + " (y/n) ");
  stdin.setRawMode(true);

  return new RSVP.Promise(function(resolve, reject) {
    keypress(stdin).then(function(data) {
      console.log("got data: ", data);

      if(data == "y") {
        resolve(true);
{'fraction_non_alphanumeric': 0.17285205897305542, 'fraction_numerical': 0.0, 'mean_word_length': 3.7766990291262137, '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': '1303532', 'n_tokens_mistral': 661, 'n_tokens_neox': 643, 'n_words': 124}