Skip to content

Commit

Permalink
fix(@angular/cli): ignore ts-node when attempting to run karma with a…
Browse files Browse the repository at this point in the history
… linked cli (#4997)

fixes #4568, #4177
  • Loading branch information
delasteve authored and filipesilva committed Feb 25, 2017
1 parent 469e692 commit 7b8f692
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/bootstrap-local.js
Expand Up @@ -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.
Expand Down Expand Up @@ -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/')) {
Expand Down

0 comments on commit 7b8f692

Please sign in to comment.