From 3213e61ddf92337521b570f94caafbbed2258064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micae=CC=88l?= Date: Tue, 26 Apr 2016 14:32:42 +0200 Subject: [PATCH 1/4] Use glob.sync to loadFiles with angular2 Workaround for https://github.com/karma-runner/karma/issues/1979 --- generators/app/conf.js | 20 +++++++++++++------- generators/app/index.js | 7 +++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/generators/app/conf.js b/generators/app/conf.js index a372075..8518a92 100644 --- a/generators/app/conf.js +++ b/generators/app/conf.js @@ -1,3 +1,5 @@ +'use strict'; + const lit = require('fountain-generator').lit; module.exports = function karmaConf(props) { @@ -102,20 +104,24 @@ module.exports = function karmaConf(props) { config: 'jspm.config.js', browser: 'jspm.test.js' }; - + let files; if (props.js === 'typescript') { if (props.framework === 'react') { - conf.jspm.loadFiles.push(lit`conf.path.src('app/**/*.tsx')`); + files = lit`conf.path.src('app/**/*.tsx')`; } else { - conf.jspm.loadFiles.push(lit`conf.path.src('app/**/*.ts')`); + files = lit`conf.path.src('app/**/*.ts')`; } } else { - conf.jspm.loadFiles.push(lit`conf.path.src('app/**/*.js')`); + files = lit`conf.path.src('app/**/*.js')`; } - - // if (props.framework !== 'react') { - if (props.framework === 'angular1') { + if (props.framework === 'angular2') { + // http://stackoverflow.com/questions/35873437/enfile-file-table-overflow-with-karma + conf.jspm.loadFiles = lit`glob.sync(${files})`; + } else if (props.framework === 'angular1') { + conf.jspm.loadFiles.push(files); conf.jspm.loadFiles.push(lit`conf.path.src('**/*.html')`); + } else { + conf.jspm.loadFiles.push(files); } } diff --git a/generators/app/index.js b/generators/app/index.js index 3e4ef10..c935ac7 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -53,6 +53,13 @@ module.exports = fountain.Base.extend({ 'karma-chrome-launcher': '^0.2.3' } }); + if (this.props.modules === 'systemjs') { + _.merge(pkg, { + devDependencies: { + glob: '^7.0.3' + } + }); + } } else { _.merge(pkg, { devDependencies: { From 7201579e9f6882a78c4eb7e75971a2c50975dd83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micae=CC=88l?= Date: Tue, 26 Apr 2016 14:55:10 +0200 Subject: [PATCH 2/4] Add missing file extensions --- generators/app/templates/src/index.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/app/templates/src/index.spec.js b/generators/app/templates/src/index.spec.js index 0655c48..5b7dd74 100644 --- a/generators/app/templates/src/index.spec.js +++ b/generators/app/templates/src/index.spec.js @@ -4,6 +4,6 @@ require('reflect-metadata'); <% if (js === 'js') { -%> var context = require.context('./app', true, /\.js$/); <% } else { -%> -const context = require.context('./app', true, /\.js$/); +const context = require.context('./app', true, /\.(js|ts|tsx)$/); <% } -%> context.keys().forEach(context); From b334ab8438eced2af5d916fe59404c9e8fdb04ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micae=CC=88l?= Date: Tue, 26 Apr 2016 16:36:48 +0200 Subject: [PATCH 3/4] Use new lit function --- generators/app/conf.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/generators/app/conf.js b/generators/app/conf.js index 8518a92..ceb1e62 100644 --- a/generators/app/conf.js +++ b/generators/app/conf.js @@ -107,21 +107,21 @@ module.exports = function karmaConf(props) { let files; if (props.js === 'typescript') { if (props.framework === 'react') { - files = lit`conf.path.src('app/**/*.tsx')`; + files = `conf.path.src('app/**/*.tsx')`; } else { - files = lit`conf.path.src('app/**/*.ts')`; + files = `conf.path.src('app/**/*.ts')`; } } else { - files = lit`conf.path.src('app/**/*.js')`; + files = `conf.path.src('app/**/*.js')`; } if (props.framework === 'angular2') { // http://stackoverflow.com/questions/35873437/enfile-file-table-overflow-with-karma conf.jspm.loadFiles = lit`glob.sync(${files})`; } else if (props.framework === 'angular1') { - conf.jspm.loadFiles.push(files); + conf.jspm.loadFiles.push(lit`${files}`); conf.jspm.loadFiles.push(lit`conf.path.src('**/*.html')`); } else { - conf.jspm.loadFiles.push(files); + conf.jspm.loadFiles.push(lit`${files}`); } } From f3da62242facb688e70c344fc4a63f10d739058c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micae=CC=88l?= Date: Wed, 27 Apr 2016 10:51:21 +0200 Subject: [PATCH 4/4] Import glob --- generators/app/templates/conf/karma.conf.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generators/app/templates/conf/karma.conf.js b/generators/app/templates/conf/karma.conf.js index d184c00..a01e6a2 100644 --- a/generators/app/templates/conf/karma.conf.js +++ b/generators/app/templates/conf/karma.conf.js @@ -4,6 +4,9 @@ const conf = require('./gulp.conf'); <% if (modules === 'inject') { -%> const listFiles = require('./karma-files.conf'); <% } -%> +<% if (modules === 'systemjs' && framework === 'angular2') { -%> +const glob = require('glob'); +<% } -%> module.exports = function (config) { const configuration = <%- json(karmaConf, 2) %>;