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: v6.0.2
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: v6.0.3
Choose a head ref
  • 4 commits
  • 3 files changed
  • 2 contributors

Commits on May 3, 2018

  1. Verified

    This commit was signed with the committer’s verified signature.
    masenf Masen Furer
    Copy the full SHA
    5af28ee View commit details

Commits on May 6, 2018

  1. Update @types/node

    blakeembrey committed May 6, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    masenf Masen Furer
    Copy the full SHA
    3a40962 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    masenf Masen Furer
    Copy the full SHA
    7a58901 View commit details
  3. 6.0.3

    blakeembrey committed May 6, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    nedbat Ned Batchelder
    Copy the full SHA
    df41bdb View commit details
Showing with 18 additions and 17 deletions.
  1. +6 −6 package-lock.json
  2. +2 −2 package.json
  3. +10 −9 src/bin.ts
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-node",
"version": "6.0.2",
"version": "6.0.3",
"description": "TypeScript execution environment and REPL for node",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@@ -54,7 +54,7 @@
"@types/minimist": "^1.2.0",
"@types/mkdirp": "^0.5.0",
"@types/mocha": "^5.0.0",
"@types/node": "^9.4.6",
"@types/node": "^10.0.3",
"@types/proxyquire": "^1.3.28",
"@types/react": "^16.0.2",
"@types/semver": "^5.3.34",
19 changes: 10 additions & 9 deletions src/bin.ts
Original file line number Diff line number Diff line change
@@ -172,7 +172,7 @@ function evalAndExit (code: string, isPrinted: boolean) {
let result: any

try {
result = _eval(code, global)
result = _eval(code)
} catch (error) {
if (error instanceof TSError) {
console.error(printError(error))
@@ -190,7 +190,7 @@ function evalAndExit (code: string, isPrinted: boolean) {
/**
* Evaluate the code snippet.
*/
function _eval (input: string, context: any) {
function _eval (input: string) {
const lines = EVAL_INSTANCE.lines
const isCompletion = !/\n$/.test(input)
const undo = appendEval(input)
@@ -213,17 +213,17 @@ function _eval (input: string, context: any) {
}

return changes.reduce((result, change) => {
return change.added ? exec(change.value, EVAL_FILENAME, context) : result
return change.added ? exec(change.value, EVAL_FILENAME) : result
}, undefined)
}

/**
* Execute some code.
*/
function exec (code: string, filename: string, context: any) {
function exec (code: string, filename: string) {
const script = new Script(code, { filename: filename })

return script.runInNewContext(context)
return script.runInThisContext()
}

/**
@@ -234,8 +234,9 @@ function startRepl () {
prompt: '> ',
input: process.stdin,
output: process.stdout,
terminal: process.stdout.isTTY,
eval: replEval,
useGlobal: false
useGlobal: true
})

// Bookmark the point where we should reset the REPL state.
@@ -245,7 +246,7 @@ function startRepl () {
resetEval()

// Hard fix for TypeScript forcing `Object.defineProperty(exports, ...)`.
exec('exports = module.exports', EVAL_FILENAME, (repl as any).context)
exec('exports = module.exports', EVAL_FILENAME)
}

reset()
@@ -273,7 +274,7 @@ function startRepl () {
/**
* Eval code from the REPL.
*/
function replEval (code: string, context: any, _filename: string, callback: (err?: Error, result?: any) => any) {
function replEval (code: string, _context: any, _filename: string, callback: (err?: Error, result?: any) => any) {
let err: any
let result: any

@@ -284,7 +285,7 @@ function replEval (code: string, context: any, _filename: string, callback: (err
}

try {
result = _eval(code, context)
result = _eval(code)
} catch (error) {
if (error instanceof TSError) {
// Support recoverable compilations using >= node 6.