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: v3.2.1
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: v3.2.2
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Jul 24, 2017

  1. Copy the full SHA
    fba8b2d View commit details
  2. 3.2.2

    blakeembrey committed Jul 24, 2017
    Copy the full SHA
    b99b6bc View commit details
Showing with 7 additions and 6 deletions.
  1. +1 −1 package.json
  2. +5 −4 src/index.ts
  3. +1 −1 tests/emit-compiled.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": "3.2.1",
"version": "3.2.2",
"description": "TypeScript execution environment and REPL for node",
"main": "dist/index.js",
"bin": {
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -469,7 +469,7 @@ function readThrough (
debug('readThrough', fileName)

const [value, sourceMap] = compile(code, fileName, lineOffset)
const output = updateOutput(value, fileName, sourceMap)
const output = updateOutput(value, fileName, sourceMap, getExtension)

cache.outputs[fileName] = output

@@ -494,7 +494,7 @@ function readThrough (
} catch (err) {/* Ignore. */}

const [value, sourceMap] = compile(code, fileName, lineOffset)
const output = updateOutput(value, fileName, sourceMap)
const output = updateOutput(value, fileName, sourceMap, getExtension)

cache.outputs[fileName] = output
writeFileSync(outputPath, output)
@@ -506,11 +506,12 @@ function readThrough (
/**
* Update the output remapping the source map.
*/
function updateOutput (outputText: string, fileName: string, sourceMap: string) {
function updateOutput (outputText: string, fileName: string, sourceMap: string, getExtension: (fileName: string) => string) {
const base64Map = new Buffer(updateSourceMap(sourceMap, fileName), 'utf8').toString('base64')
const sourceMapContent = `data:application/json;charset=utf-8;base64,${base64Map}`
const sourceMapLength = `${basename(fileName)}.map`.length + (getExtension(fileName).length - extname(fileName).length)

return outputText.replace(/[^=]+$/, sourceMapContent)
return outputText.slice(0, -1 * sourceMapLength) + sourceMapContent
}

/**
2 changes: 1 addition & 1 deletion tests/emit-compiled.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ extensions.forEach(ext => {
const _compile = m._compile

m._compile = (code, path) => {
console.log(code)
console.error(code)
return _compile.call(this, code, path)
}