Skip to content

Commit 0f4eb6a

Browse files
author
benholloway
committed
moved stream functions for consistency
1 parent dac6a38 commit 0f4eb6a

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

lib/test/karma.js

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ function getKarmaReporterPluginPath(reporterName) {
7070
/**
7171
* Determine the registered reporter name.
7272
*
73-
* @param {string} reporterName Either the registered reporter name,
74-
* *OR* an absolute path, for a karma reporter.
75-
* @return {string} The registered reporter name for use in
76-
* the `reporters` section of the karma config file.
73+
* @param {string} reporterName Either the registered reporter name, or an absolute path for a karma reporter.
74+
* @return {string} The registered reporter name for use in the `reporters` section of the karma config file.
7775
*/
7876
function getKarmaReporterName(reporterName) {
7977
if (typeof reporterName !== 'string') {
@@ -159,44 +157,39 @@ function karmaCreateConfig(reporters, configFileName) {
159157
* No output. Ends when the Karma process ends.
160158
* Runs karma in a child process, to avoid `process.exit()` called by karma.
161159
*
162-
* @param {Array.<string>} [reporters] The name of the karma reporter to use
163160
* @returns {stream.Through} A through stream intended to have a gulp stream piped through it
164161
*/
165-
function karmaRun(reporters) {
162+
function karmaRun() {
166163
var options = {
167-
configFile: undefined
164+
configFile: undefined // populated from the input stream
168165
};
169-
if (reporters.constructor !== Array || reporters.length === 0) {
170-
throw new Error('No reporters specified');
171-
}
172-
173-
return through.obj(function transformFn(file, encoding, done) {
166+
function transformFn(file, encoding, done) {
174167
options.configFile = file.path;
175168
done();
176-
},
177-
function streamFn(done) {
169+
}
170+
function flushFn(done) {
178171
var appPath = path.join(__dirname, 'karma-background.js');
179172
var data = querystring.escape(JSON.stringify(options));
180173

181-
var karmaBackground = childProcess.spawn('node', [appPath, data], {
182-
cwd: process.cwd(),
183-
stdio: [process.stdin, process.stdout, process.stderr],
184-
env: lodashMerge(process.env, {
174+
childProcess.spawn('node', [appPath, data], {
175+
cwd : process.cwd(),
176+
stdio: 'inherit',
177+
env : lodashMerge(process.env, {
185178
//NOTE this workaround is necessary, see issue:
186179
//https://github.com/sindresorhus/supports-color/issues/13
187180
//TODO @bguiz remove workaround when issue has been resolved
188181
SUPPORTS_COLOR: true
189182
})
190-
});
191-
karmaBackground.on('close', function() {
192-
done();
193-
return;
194-
});
195-
});
183+
})
184+
.on('close', function() {
185+
done();
186+
});
187+
}
188+
return through.obj(transformFn, flushFn);
196189
}
197190

198191
var yargsOptionDefinition = {
199-
key: 'karma-reporter',
192+
key : 'karma-reporter',
200193
value: {
201194
describe: 'Specify a custom Karma reporter to use. Either a locally npm installed module, or an asolute path to ' +
202195
'one.',

0 commit comments

Comments
 (0)