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.5
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.1.0
Choose a head ref
  • 5 commits
  • 7 files changed
  • 3 contributors

Commits on May 26, 2018

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2e44bc0 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6c610b4 View commit details

Commits on May 30, 2018

  1. Document -T alias in README (#600)

    capaj authored and blakeembrey committed May 30, 2018
    Copy the full SHA
    70d68ef View commit details

Commits on Jun 3, 2018

  1. Copy the full SHA
    57f09b5 View commit details
  2. 6.1.0

    blakeembrey committed Jun 3, 2018
    Copy the full SHA
    ee5c1b3 View commit details
Showing with 114 additions and 124 deletions.
  1. +3 −3 .travis.yml
  2. +2 −1 README.md
  3. +23 −10 package-lock.json
  4. +3 −4 package.json
  5. +13 −10 src/bin.ts
  6. +2 −3 src/index.spec.ts
  7. +68 −93 src/index.ts
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -15,10 +15,10 @@ script:
- npm run test-cov

env:
- NODE=8 TYPESCRIPT=typescript@2.0
- NODE=6 TYPESCRIPT=typescript@latest
- NODE=8 TYPESCRIPT=typescript@latest
- NODE=8 TYPESCRIPT=typescript@next
- NODE=stable TYPESCRIPT=typescript@latest
- NODE=stable TYPESCRIPT=typescript@2.0
- NODE=stable TYPESCRIPT=typescript@next

node_js:
- stable
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -120,13 +120,14 @@ Supports `--print`, `--eval` and `--require` from [node.js CLI options](https://

_Environment variable denoted in parentheses._

* `--transpileOnly` Use TypeScript's faster `transpileModule` (`TS_NODE_TRANSPILE_ONLY`)
* `-T, --transpileOnly` Use TypeScript's faster `transpileModule` (`TS_NODE_TRANSPILE_ONLY`)
* `--cacheDirectory` Configure the output file cache directory (`TS_NODE_CACHE_DIRECTORY`)
* `-I, --ignore [pattern]` Override the path patterns to skip compilation (`TS_NODE_IGNORE`)
* `-P, --project [path]` Path to TypeScript JSON project file (`TS_NODE_PROJECT`)
* `-C, --compiler [name]` Specify a custom TypeScript compiler (`TS_NODE_COMPILER`)
* `-D, --ignoreDiagnostics [code]` Ignore TypeScript warnings by diagnostic code (`TS_NODE_IGNORE_DIAGNOSTICS`)
* `-O, --compilerOptions [opts]` JSON object to merge with compiler options (`TS_NODE_COMPILER_OPTIONS`)
* `--pretty` Use pretty diagnostic formatter (`TS_NODE_PRETTY`)
* `--no-cache` Disable the local TypeScript Node cache (`TS_NODE_CACHE`)
* `--skip-project` Skip project config resolution and loading (`TS_NODE_SKIP_PROJECT`)
* `--skip-ignore` Skip ignore checks (`TS_NODE_SKIP_IGNORE`)
33 changes: 23 additions & 10 deletions package-lock.json

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

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-node",
"version": "6.0.5",
"version": "6.1.0",
"description": "TypeScript execution environment and REPL for node",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@@ -70,16 +70,15 @@
"semver": "^5.1.0",
"tslint": "^5.0.0",
"tslint-config-standard": "^7.0.0",
"typescript": "^2.8.1"
"typescript": "^2.8.3"
},
"dependencies": {
"arrify": "^1.0.0",
"chalk": "^2.3.0",
"diff": "^3.1.0",
"make-error": "^1.1.1",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"source-map-support": "^0.5.3",
"source-map-support": "^0.5.6",
"yn": "^2.0.0"
}
}
23 changes: 13 additions & 10 deletions src/bin.ts
Original file line number Diff line number Diff line change
@@ -6,11 +6,10 @@ import { inspect } from 'util'
import arrify = require('arrify')
import Module = require('module')
import minimist = require('minimist')
import chalk from 'chalk'
import { diffLines } from 'diff'
import { Script } from 'vm'
import { readFileSync, statSync } from 'fs'
import { register, VERSION, DEFAULTS, TSError, parse, printError } from './index'
import { register, VERSION, DEFAULTS, TSError, parse } from './index'

interface Argv {
// Node.js-like options.
@@ -21,6 +20,7 @@ interface Argv {
help?: boolean
version?: boolean
// Register options.
pretty?: boolean
typeCheck?: boolean
transpileOnly?: boolean
cache?: boolean
@@ -38,7 +38,7 @@ interface Argv {
const argv = minimist<Argv>(process.argv.slice(2), {
stopEarly: true,
string: ['eval', 'print', 'compiler', 'project', 'ignoreDiagnostics', 'require', 'cacheDirectory', 'ignore'],
boolean: ['help', 'transpileOnly', 'typeCheck', 'version', 'cache', 'skipProject', 'skipIgnore'],
boolean: ['help', 'transpileOnly', 'typeCheck', 'version', 'cache', 'pretty', 'skipProject', 'skipIgnore'],
alias: {
eval: ['e'],
print: ['p'],
@@ -86,6 +86,7 @@ Options:
-D, --ignoreDiagnostics [code] Ignore TypeScript warnings by diagnostic code
-O, --compilerOptions [opts] JSON object to merge with compiler options
--pretty Use pretty diagnostic formatter
--no-cache Disable the local TypeScript Node cache
--skip-project Skip reading \`tsconfig.json\`
--skip-ignore Skip \`--ignore\` checks
@@ -101,6 +102,7 @@ const isPrinted = argv.print !== undefined

// Register the TypeScript compiler instance.
const service = register({
pretty: argv.pretty,
typeCheck: argv.typeCheck,
transpileOnly: argv.transpileOnly,
cache: argv.cache,
@@ -175,7 +177,7 @@ function evalAndExit (code: string, isPrinted: boolean) {
result = _eval(code)
} catch (error) {
if (error instanceof TSError) {
console.error(printError(error))
console.error(error.diagnosticText)
process.exit(1)
}

@@ -265,7 +267,7 @@ function startRepl () {

undo()

repl.outputStream.write(`${chalk.bold(name)}\n${comment ? `${comment}\n` : ''}`)
repl.outputStream.write(`${name}\n${comment ? `${comment}\n` : ''}`)
repl.displayPrompt()
}
})
@@ -275,7 +277,7 @@ function startRepl () {
* Eval code from the REPL.
*/
function replEval (code: string, _context: any, _filename: string, callback: (err?: Error, result?: any) => any) {
let err: any
let err: Error | undefined
let result: any

// TODO: Figure out how to handle completion here.
@@ -292,7 +294,8 @@ function replEval (code: string, _context: any, _filename: string, callback: (er
if (Recoverable && isRecoverable(error)) {
err = new Recoverable(error)
} else {
err = printError(error)
console.error(error.diagnosticText)
err = undefined
}
} else {
err = error
@@ -368,18 +371,18 @@ function fileExistsEval (path: string) {
}
}

const RECOVERY_CODES: number[] = [
const RECOVERY_CODES: Set<number> = new Set([
1003, // "Identifier expected."
1005, // "')' expected."
1109, // "Expression expected."
1126, // "Unexpected end of text."
1160, // "Unterminated template literal."
1161 // "Unterminated regular expression literal."
]
])

/**
* Check if a function can recover gracefully.
*/
function isRecoverable (error: TSError) {
return error.diagnostics.every(x => RECOVERY_CODES.indexOf(x.code) > -1)
return error.diagnosticCodes.every(code => RECOVERY_CODES.has(code))
}
5 changes: 2 additions & 3 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -122,9 +122,8 @@ describe('ts-node', function () {
}

expect(err.message).to.match(new RegExp(
// Node 0.10 can not override the `lineOffset` option.
'\\[eval\\]\\.ts \\(1,59\\): Argument of type \'(?:number|123)\' ' +
'is not assignable to parameter of type \'string\'\\. \\(2345\\)'
'TS2345: Argument of type \'(?:number|123)\' ' +
'is not assignable to parameter of type \'string\'\\.'
))

return done()
Loading