1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | function _getOption(optToGet, options, isBool, defaultValue) {
|
17 | const envVar = `MOCHAWESOME_${optToGet.toUpperCase()}`;
|
18 | if (options && typeof options[optToGet] !== 'undefined') {
|
19 | return (isBool && typeof options[optToGet] === 'string')
|
20 | ? options[optToGet] === 'true'
|
21 | : options[optToGet];
|
22 | }
|
23 | if (typeof process.env[envVar] !== 'undefined') {
|
24 | return isBool
|
25 | ? process.env[envVar] === 'true'
|
26 | : process.env[envVar];
|
27 | }
|
28 | return defaultValue;
|
29 | }
|
30 |
|
31 | module.exports = function (opts) {
|
32 | const reporterOpts = (opts && opts.reporterOptions) || {};
|
33 | const code = _getOption('code', reporterOpts, true, true);
|
34 | const noCode = _getOption('no-code', reporterOpts, true, false);
|
35 |
|
36 | return {
|
37 | quiet: _getOption('quiet', reporterOpts, true, false),
|
38 | reportFilename: _getOption('reportFilename', reporterOpts, false, 'mochawesome'),
|
39 | saveHtml: _getOption('html', reporterOpts, true, true),
|
40 | saveJson: _getOption('json', reporterOpts, true, true),
|
41 | consoleReporter: _getOption('consoleReporter', reporterOpts, false, 'spec'),
|
42 | useInlineDiffs: !!opts.useInlineDiffs,
|
43 | code: noCode ? false : code
|
44 | };
|
45 | };
|