Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: TypeStrong/ts-node
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.7.3
Choose a base ref
...
head repository: TypeStrong/ts-node
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.0.0
Choose a head ref
  • 3 commits
  • 3 files changed
  • 3 contributors

Commits on Dec 29, 2016

  1. Fix preloading of modules (#258)

    Jontem authored and blakeembrey committed Dec 29, 2016
    Copy the full SHA
    50df9b1 View commit details
  2. Use new Script for node > v4 (#256)

    xaclincoln authored and blakeembrey committed Dec 29, 2016
    Copy the full SHA
    5623aff View commit details
  3. v2.0.0

    blakeembrey committed Dec 29, 2016
    Copy the full SHA
    9409899 View commit details
Showing with 13 additions and 6 deletions.
  1. +1 −1 package.json
  2. +3 −5 src/_bin.ts
  3. +9 −0 src/index.spec.ts
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-node",
"version": "1.7.3",
"version": "2.0.0",
"preferGlobal": true,
"description": "TypeScript execution environment and REPL for node",
"main": "dist/index.js",
8 changes: 3 additions & 5 deletions src/_bin.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import Module = require('module')
import minimist = require('minimist')
import chalk = require('chalk')
import { diffLines } from 'diff'
import { createScript } from 'vm'
import { Script } from 'vm'
import { register, VERSION, getFile, fileExists, TSError, parse } from './index'

interface Argv {
@@ -161,9 +161,7 @@ const service = register({
})

// Require specified modules before start-up.
for (const id of arrify(argv.require)) {
Module._load(id)
}
;(Module as any)._preloadModules(arrify(argv.require))

/**
* Eval helpers.
@@ -267,7 +265,7 @@ function _eval (input: string, context: any) {

for (const change of changes) {
if (change.added) {
const script = createScript(change.value, EVAL_FILENAME)
const script = new Script(change.value, EVAL_FILENAME)

result = script.runInNewContext(context)
}
9 changes: 9 additions & 0 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -169,6 +169,15 @@ describe('ts-node', function () {
return done()
})
})

it('should support require from node modules', function (done) {
exec(`${BIN_EXEC} -r typescript -e "console.log('success')"`, function (err, stdout) {
expect(err).to.not.exist
expect(stdout).to.equal('success\n')

return done()
})
})
})

describe('register', function () {