From c67d4ba0c301c49bf7d7497839f5c854533002e4 Mon Sep 17 00:00:00 2001 From: Stephen Cavaliere Date: Sat, 25 Feb 2017 09:54:57 -0500 Subject: [PATCH] fix(@angular/cli): ignore ts-node when attempting to run karma with a linked cli (#4997) fixes #4568, #4177 --- lib/bootstrap-local.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/bootstrap-local.js b/lib/bootstrap-local.js index a4e2d58e3438..a4043c34437f 100644 --- a/lib/bootstrap-local.js +++ b/lib/bootstrap-local.js @@ -12,7 +12,7 @@ global.angularCliPackages = require('./packages'); const compilerOptions = JSON.parse(fs.readFileSync(path.join(__dirname, '../tsconfig.json'))); const oldRequireTs = require.extensions['.ts']; -require.extensions['.ts'] = function(m, filename) { +require.extensions['.ts'] = function (m, filename) { // If we're in node module, either call the old hook or simply compile the // file without transpilation. We do not touch node_modules/**. // We do touch `Angular CLI` files anywhere though. @@ -52,6 +52,9 @@ if (!__dirname.match(new RegExp(`\\${path.sep}node_modules\\${path.sep}`))) { const Module = require('module'); const oldLoad = Module._load; Module._load = function (request, parent) { + if (request.match(/ts-node/) && parent && parent.id && parent.id.match(/karma/)) { + throw new Error(); + } if (request in packages) { return oldLoad.call(this, packages[request].main, parent); } else if (request.startsWith('@angular/cli/')) {