Skip to content

Commit 7b8f692

Browse files
delastevefilipesilva
authored andcommitted
fix(@angular/cli): ignore ts-node when attempting to run karma with a linked cli (angular#4997)
fixes angular#4568, angular#4177
1 parent 469e692 commit 7b8f692

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/bootstrap-local.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ global.angularCliPackages = require('./packages');
1212
const compilerOptions = JSON.parse(fs.readFileSync(path.join(__dirname, '../tsconfig.json')));
1313

1414
const oldRequireTs = require.extensions['.ts'];
15-
require.extensions['.ts'] = function(m, filename) {
15+
require.extensions['.ts'] = function (m, filename) {
1616
// If we're in node module, either call the old hook or simply compile the
1717
// file without transpilation. We do not touch node_modules/**.
1818
// We do touch `Angular CLI` files anywhere though.
@@ -52,6 +52,9 @@ if (!__dirname.match(new RegExp(`\\${path.sep}node_modules\\${path.sep}`))) {
5252
const Module = require('module');
5353
const oldLoad = Module._load;
5454
Module._load = function (request, parent) {
55+
if (request.match(/ts-node/) && parent && parent.id && parent.id.match(/karma/)) {
56+
throw new Error();
57+
}
5558
if (request in packages) {
5659
return oldLoad.call(this, packages[request].main, parent);
5760
} else if (request.startsWith('@angular/cli/')) {

0 commit comments

Comments
 (0)