<commit_before>import { resolve } from 'path'
import { Command } from 'commander'
import { start } from 'repl'
import { inspect } from 'util'
import { LanguageService, LanguageServiceHost } from 'typescript'
import { readFileSync } from 'fs'
import Module = require('module')
import extend = require('xtend')
import { runInThisContext } from 'vm'
import { register } from '../typescript-node'

var program = new Command('ts-node')
var pkg = require('../../package.json')

program.option('-e, --eval [code]', 'Evaluate code')
program.option('-p, --print [code]', 'Evaluate code and print result')
program.option('--compiler [name]', 'Specify a custom TypeScript compiler')
program.option('--ignoreWarnings [codes]', 'Specify a custom TypeScript compiler', list)
program.option('--configFile [path]', 'Specify a custom TypeScript compiler')

program.version(pkg.version)
program.usage('[options] [ -e script | script.js ] [arguments]')
program.parse(process.argv)

// TypeScript files must always end with `.ts`.
const EVAL_FILENAME = '[eval].ts'

const cwd = process.cwd()
const opts = program.opts()
const print = opts.print
const eval = opts.eval
const code: string = eval == null ? print : eval

// Register returns environment options, helps creating a new language service.
const compileInline = register(opts)

// Defer creation of eval services.
let files: { [filename: string]: { text: string, version: number } }
let service: LanguageService

if (typeof code === 'string') {
  global.__filename = EVAL_FILENAME
  global.__dirname = cwd

  const module = new Module(global.__filename)
  module.filename = global.__filename
  module.paths = Module._nodeModulePaths(global.__dirname)

  global.exports = module.exports
  global.module = module
  global.require = module.require.bind(module)

  var result = _eval(code, global.__filename)

  if (print != null) {
    var output = typeof result === 'string' ? result : inspect(result)
    process.stdout.write(output + '\n')
  }
} else {
  if (program.args.length) {
    let index = 2
    let skip = false

    // Skip over TS configuration options.
    for (; index < process.argv.length; index++) {
      if (skip) {
        skip = false
        continue
      }

      const arg = process.argv[index]

      // Break on unknown argument value.
      if (arg.charAt(0) === '-') {
        const value = opts[arg.substr(2)]

        if (value && value !== true) {
          skip = true
        }

        continue
      }

      break
    }

    const args = process.argv.slice(index)

    // Make the filename absolute.
    args[0] = resolve(args[0])

    process.argv = ['node'].concat(args)
    process.execArgv.unshift(__filename)

    Module.runMain()
  } else {
    startRepl()
  }
}

/**
 * Evaluate the code snippet.
 */
function _eval (code: string, filename: string) {
  // Adding `;` before the code is jank, but avoids issues with source map
  // columns becoming negative.
  return runInThisContext(compileInline(filename, ';' + code), filename)
}
<commit_msg>Remove semicolon before code with eval<commit_after>import { resolve } from 'path'
import { Command } from 'commander'
import { start } from 'repl'
import { inspect } from 'util'
import { LanguageService, LanguageServiceHost } from 'typescript'
import { readFileSync } from 'fs'
import Module = require('module')
import extend = require('xtend')
import { runInThisContext } from 'vm'
import { register } from '../typescript-node'

var program = new Command('ts-node')
var pkg = require('../../package.json')

program.option('-e, --eval [code]', 'Evaluate code')
program.option('-p, --print [code]', 'Evaluate code and print result')
program.option('--compiler [name]', 'Specify a custom TypeScript compiler')
program.option('--ignoreWarnings [codes]', 'Specify a custom TypeScript compiler', list)
program.option('--configFile [path]', 'Specify a custom TypeScript compiler')

program.version(pkg.version)
program.usage('[options] [ -e script | script.js ] [arguments]')
program.parse(process.argv)

// TypeScript files must always end with `.ts`.
const EVAL_FILENAME = '[eval].ts'

const cwd = process.cwd()
const opts = program.opts()
const print = opts.print
const eval = opts.eval
const code: string = eval == null ? print : eval

// Register returns environment options, helps creating a new language service.
const compileInline = register(opts)

// Defer creation of eval services.
let files: { [filename: string]: { text: string, version: number } }
let service: LanguageService

if (typeof code === 'string') {
  global.__filename = EVAL_FILENAME
  global.__dirname = cwd

  const module = new Module(global.__filename)
  module.filename = global.__filename
  module.paths = Module._nodeModulePaths(global.__dirname)

  global.exports = module.exports
  global.module = module
  global.require = module.require.bind(module)

  var result = _eval(code, global.__filename)

  if (print != null) {
    var output = typeof result === 'string' ? result : inspect(result)
    process.stdout.write(output + '\n')
  }
} else {
  if (program.args.length) {
    let index = 2
    let skip = false

    // Skip over TS configuration options.
    for (; index < process.argv.length; index++) {
      if (skip) {
        skip = false
        continue
      }

      const arg = process.argv[index]

      // Break on unknown argument value.
      if (arg.charAt(0) === '-') {
        const value = opts[arg.substr(2)]

        if (value && value !== true) {
          skip = true
        }

        continue
      }

      break
    }

    const args = process.argv.slice(index)

    // Make the filename absolute.
    args[0] = resolve(args[0])

    process.argv = ['node'].concat(args)
    process.execArgv.unshift(__filename)

    Module.runMain()
  } else {
    startRepl()
  }
}

/**
 * Evaluate the code snippet.
 */
function _eval (code: string, filename: string) {
  return runInThisContext(compileInline(filename, code), filename)
}

{'fraction_non_alphanumeric': 0.13430583501006035, 'fraction_numerical': 0.001676727028839705, 'mean_word_length': 3.395725865880619, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6393540', 'n_tokens_mistral': 1775, 'n_tokens_neox': 1732, 'n_words': 534}