Skip to content
This repository has been archived by the owner on Feb 27, 2019. It is now read-only.

Fix ENFILE: file table overflow with Karma #23

Merged
merged 4 commits into from
Apr 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions generators/app/conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

const lit = require('fountain-generator').lit;

module.exports = function karmaConf(props) {
Expand Down Expand Up @@ -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 = `conf.path.src('app/**/*.tsx')`;
} else {
conf.jspm.loadFiles.push(lit`conf.path.src('app/**/*.ts')`);
files = `conf.path.src('app/**/*.ts')`;
}
} else {
conf.jspm.loadFiles.push(lit`conf.path.src('app/**/*.js')`);
files = `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(lit`${files}`);
conf.jspm.loadFiles.push(lit`conf.path.src('**/*.html')`);
} else {
conf.jspm.loadFiles.push(lit`${files}`);
}
}

Expand Down
7 changes: 7 additions & 0 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
3 changes: 3 additions & 0 deletions generators/app/templates/conf/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) %>;
Expand Down
2 changes: 1 addition & 1 deletion generators/app/templates/src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);