<commit_before>'use strict';
let tls = require('tls');
let url = require('url');
let tty = require('tty');
let Heroku = require('heroku-client');
let co = require('co');
let errors = require('./errors');
let term = require('./term');
let heroku;

function startDyno(app, command) {
  return heroku.apps(app).dynos().create({
    command: command,
    attach: true,
    env: tty.isatty(1) ? term.getTermSize() : {}
  });
}

function attachToRendezvous(uri) {
  let c = tls.connect(uri.port, uri.hostname);
  c.setEncoding('utf8');
  process.stdin.setEncoding('utf8');
  c.on('connect', function () {
    c.write(uri.path.substr(1) + '\r\n');
    if (!tty.isatty(0)) {
      setTimeout(function () {
        process.stdin.on('readable', function () {
          c.write(String(process.stdin.read()));
        });
        process.stdin.on('end', function () {
          c.end();
        });
      }, 10000);
    }
  });
  if (tty.isatty(0)) {
    process.stdin.setRawMode(true);
    process.stdin.pipe(c);
  }
  let firstLine = true;
  c.on('data', function (data) {
    // discard first line
    if (firstLine) { firstLine = false; return; }
    data = data.replace('\r\n', '\n');
    let exitCode = data.match(/^heroku-command-exit-status (\d+)$/m);
    if (exitCode) {
      process.stdout.write(data.replace(/^heroku-command-exit-status \d+$/m, ''));
      process.exit(exitCode[1]);
    }
    process.stdout.write(data);
  });
  c.on('timeout', function () {
    console.error('timed out');
  });
  c.on('end', function () {
    process.exit(0);
  });
}

module.exports = function run (context) {
  co(function* () {
    heroku = new Heroku({token: context.auth.password});
    let command = context.args.join(' ');
    process.stdout.write(`Running \`${command}\` attached to terminal... `);
    command = `${command}; echo heroku-command-exit-status $?`;
    let dyno = yield startDyno(context.app, command);
    console.log(`up, ${dyno.name}`);
    attachToRendezvous(url.parse(dyno.attach_url));
  }).catch(errors.handleErr);
};
<commit_msg>removed non-working piping functionality<commit_after>'use strict';
let tls = require('tls');
let url = require('url');
let tty = require('tty');
let Heroku = require('heroku-client');
let co = require('co');
let errors = require('./errors');
let term = require('./term');
let heroku;

function startDyno(app, command) {
  return heroku.apps(app).dynos().create({
    command: command,
    attach: true,
    env: tty.isatty(1) ? term.getTermSize() : {}
  });
}

function attachToRendezvous(uri) {
  let c = tls.connect(uri.port, uri.hostname);
  c.setEncoding('utf8');
  process.stdin.setEncoding('utf8');
  c.on('connect', function () {
    c.write(uri.path.substr(1) + '\r\n');
  });
  if (tty.isatty(0)) {
    process.stdin.setRawMode(true);
    process.stdin.pipe(c);
  }
  let firstLine = true;
  c.on('data', function (data) {
    // discard first line
    if (firstLine) { firstLine = false; return; }
    data = data.replace('\r\n', '\n');
    let exitCode = data.match(/^heroku-command-exit-status (\d+)$/m);
    if (exitCode) {
      process.stdout.write(data.replace(/^heroku-command-exit-status \d+$/m, ''));
      process.exit(exitCode[1]);
    }
    process.stdout.write(data);
  });
  c.on('timeout', function () {
    console.error('timed out');
  });
  c.on('end', function () {
    process.exit(0);
  });
}

module.exports = function run (context) {
  co(function* () {
    heroku = new Heroku({token: context.auth.password});
    let command = context.args.join(' ');
    process.stdout.write(`Running \`${command}\` attached to terminal... `);
    command = `${command}; echo heroku-command-exit-status $?`;
    let dyno = yield startDyno(context.app, command);
    console.log(`up, ${dyno.name}`);
    attachToRendezvous(url.parse(dyno.attach_url));
  }).catch(errors.handleErr);
};

{'fraction_non_alphanumeric': 0.2012987012987013, 'fraction_numerical': 0.005194805194805195, 'mean_word_length': 3.3711691259931897, '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': '7034017', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1347, 'n_words': 247}