<commit_before>var parse = require('shell-quote').parse;

var Shell = function(container, options) {
  this.options = options || {};
  this.container = container;
  this.timeout = options.timeout || 6000
  this.run = this.run.bind(this);
};

/**
 * Perform any necessary necessary 
 */
Shell.prototype.buildOptions = function() {
  var options = this.options || {};
  options.tty = options.tty || false;
  options.env = options.env || [
    'PWD=/',
  ];
  var self = this;
  //command = parse(options.command);
  //command.unshift('sh');
  return {
    Detach: false,
    stout: true,
    OpenStdout: true,
    AttachStdin: true,
    AttachStdout: true,
    AttachStderr: true,
    Tty: options.tty,
    // SSH errors were observed without having a PWD set.
    Env: options.env,
    Cmd: [ 'bash', '-c', options.command ],
  };
};

Shell.prototype.handleTimeout = function() {
};

// The log write stream needs to be handed in from the
// outside because that will be configured at the container level.
Shell.prototype.run = function(done) {
  console.log('RUNNING, SUCKER!');
  // TODO: This is bad - I should call this dockerContainer or something...
  var log = this.container.log;
  var container = this.container.container;
  var self = this;
  // TODO: We'll need a timeout.
  log.info('WTF', self.buildOptions());
  container.exec(self.buildOptions(), function(error, exec) {
    this.exec = exec;
    if (error) throw error;
    log.info('starting the exec');
      exec.start({stdin: true, stdout: true}, function(error, stream) {
        log.info('exec started');
        if (error) throw error;
        // TODO: Allow a write stream to be connected here.
        stream.pipe(process.stdout);
        stream.on('end', function() {
          log.info('exec stream ended');
          exec.inspect(function(error, data) {<commit_msg>Removing debug code.<commit_after>var parse = require('shell-quote').parse;

var Shell = function(container, options) {
  this.options = options || {};
  this.container = container;
  this.timeout = options.timeout || 6000
  this.run = this.run.bind(this);
};

/**
 * Perform any necessary necessary 
 */
Shell.prototype.buildOptions = function() {
  var options = this.options || {};
  options.tty = options.tty || false;
  options.env = options.env || [
    'PWD=/',
  ];
  var self = this;
  //command = parse(options.command);
  //command.unshift('sh');
  return {
    Detach: false,
    stout: true,
    OpenStdout: true,
    AttachStdin: true,
    AttachStdout: true,
    AttachStderr: true,
    Tty: options.tty,
    // SSH errors were observed without having a PWD set.
    Env: options.env,
    Cmd: [ 'bash', '-c', options.command ],
  };
};

Shell.prototype.handleTimeout = function() {
};

// The log write stream needs to be handed in from the
// outside because that will be configured at the container level.
Shell.prototype.run = function(done) {
  // TODO: This is bad - I should call this dockerContainer or something...
  var log = this.container.log;
  var container = this.container.container;
  var self = this;
  // TODO: We'll need a timeout.
  container.exec(self.buildOptions(), function(error, exec) {
    this.exec = exec;
    if (error) throw error;
    log.info('starting the exec');
      exec.start({stdin: true, stdout: true}, function(error, stream) {
        log.info('exec started');
        if (error) throw error;
        // TODO: Allow a write stream to be connected here.
        stream.pipe(process.stdout);
        stream.on('end', function() {
          log.info('exec stream ended');
          exec.inspect(function(error, data) {
{'fraction_non_alphanumeric': 0.14131637168141592, 'fraction_numerical': 0.0022123893805309734, 'mean_word_length': 3.0055370985603544, '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': '1186786', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1092, 'n_words': 322}