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.5.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: v1.5.1
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Oct 15, 2016

  1. Skip non-TypeScript compilable extensions

    Hopefully makes #223 leave me alone.
    blakeembrey committed Oct 15, 2016
    Copy the full SHA
    380ab99 View commit details
  2. v1.5.1

    blakeembrey committed Oct 15, 2016
    Copy the full SHA
    d53fcac View commit details
Showing with 13 additions and 5 deletions.
  1. +1 −1 package.json
  2. +12 −4 src/index.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.5.0",
"version": "1.5.1",
"preferGlobal": true,
"description": "TypeScript execution environment and REPL for node",
"main": "dist/index.js",
16 changes: 12 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -128,6 +128,7 @@ export function slash (value: string): string {

export interface Register {
cwd: string
extensions: string[]
compile (code: string, fileName: string, lineOffset?: number): string
getTypeInfo (fileName: string, position: number): TypeInfo
}
@@ -178,6 +179,7 @@ export function register (options: Options = {}): () => Register {
const ts: typeof TS = require(compiler)
const config = readConfig(compilerOptions, project, cwd, ts)
const configDiagnostics = filterDiagnostics(config.errors, ignoreWarnings, disableWarnings)
const extensions = ['.ts', '.tsx']

const cachedir = join(
resolve(cwd, cacheDirectory),
@@ -194,6 +196,7 @@ export function register (options: Options = {}): () => Register {

// Enable `allowJs` when flag is set.
if (config.options.allowJs) {
extensions.push('.js')
registerExtension('.js', ignore, service)
}

@@ -348,7 +351,7 @@ export function register (options: Options = {}): () => Register {
}
}

return { cwd, compile, getTypeInfo }
return { cwd, compile, getTypeInfo, extensions }
}

function service () {
@@ -370,10 +373,15 @@ export function register (options: Options = {}): () => Register {
/**
* Check if the filename should be ignored.
*/
function shouldIgnore (filename: string, service: () => Register, ignore: RegExp[]) {
function shouldIgnore (filename: string, ignore: RegExp[], service: () => Register) {
const relname = slash(filename)
const extension = extname(filename)

return ignore.some(x => x.test(relname))
if (service().extensions.indexOf(extension) > -1) {
return ignore.some(x => x.test(relname))
}

return false
}

/**
@@ -383,7 +391,7 @@ function registerExtension (ext: string, ignore: RegExp[], service: () => Regist
const old = require.extensions[ext] || require.extensions['.js']

require.extensions[ext] = function (m, filename) {
if (shouldIgnore(filename, service, ignore)) {
if (shouldIgnore(filename, ignore, service)) {
return old(m, filename)
}