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

Commits on Jan 1, 2017

  1. Copy the full SHA
    ee1e1e1 View commit details

Commits on Jan 19, 2017

  1. Copy the full SHA
    1ed4d6f View commit details

Commits on Feb 9, 2017

  1. Use os.homedir to calculate tmpdir (#267)

    shortenda authored and blakeembrey committed Feb 9, 2017
    Copy the full SHA
    da065ef View commit details
  2. v2.1.0

    blakeembrey committed Feb 9, 2017
    Copy the full SHA
    01fbfce View commit details
Showing with 12 additions and 5 deletions.
  1. +1 −1 README.md
  2. +2 −2 package.json
  3. +9 −2 src/index.ts
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ npm install -g typescript
## Usage

```sh
# Execute a script as you world normally with `node`.
# Execute a script as you would normally with `node`.
ts-node script.ts

# Starts the TypeScript REPL.
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": "2.0.0",
"version": "2.1.0",
"preferGlobal": true,
"description": "TypeScript execution environment and REPL for node",
"main": "dist/index.js",
@@ -54,7 +54,7 @@
"rimraf": "^2.5.4",
"semver": "^5.1.0",
"tslint": "^4.0.2",
"tslint-config-standard": "^2.0.0",
"tslint-config-standard": "^3.0.0",
"typescript": "^2.1.4",
"typings": "^2.0.0"
},
11 changes: 9 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { relative, basename, extname, resolve, dirname, join } from 'path'
import { readdirSync, writeFileSync, readFileSync, statSync } from 'fs'
import { EOL, tmpdir } from 'os'
import { EOL, tmpdir, homedir } from 'os'
import sourceMapSupport = require('source-map-support')
import extend = require('xtend')
import mkdirp = require('mkdirp')
@@ -134,6 +134,13 @@ export interface Register {
getTypeInfo (fileName: string, position: number): TypeInfo
}

function getTmpDir (): string {
const hash: string = crypto.createHash('sha1')
.update(homedir(), 'utf8')
.digest('hex')
return join(tmpdir(), `ts-node-${hash}`)
}

/**
* Register TypeScript compiler.
*/
@@ -149,7 +156,7 @@ export function register (options: Options = {}): () => Register {
const shouldCache = !!(options.cache == null ? DEFAULTS.cache : options.cache)
const fast = !!(options.fast == null ? DEFAULTS.fast : options.fast)
const project = options.project || DEFAULTS.project
const cacheDirectory = options.cacheDirectory || DEFAULTS.cacheDirectory || join(tmpdir(), 'ts-node')
const cacheDirectory = options.cacheDirectory || DEFAULTS.cacheDirectory || getTmpDir()
const compilerOptions = extend(DEFAULTS.compilerOptions, options.compilerOptions)
const originalJsHandler = require.extensions['.js']
let result: Register