Welcome to mirror list, hosted at ThFree Co, Russian Federation.

options.js « bin « mocha-3.1.0 « lib « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9d1a18a23e6875ceaee409704c698deccc618a96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
 * Dependencies.
 */

var fs = require('fs');

/**
 * Export `getOptions`.
 */

module.exports = getOptions;

/**
 * Get options.
 */

function getOptions() {
  var optsPath = process.argv.indexOf('--opts') !== -1
        ? process.argv[process.argv.indexOf('--opts') + 1]
        : 'test/mocha.opts';

  try {
    var opts = fs.readFileSync(optsPath, 'utf8')
      .replace(/\\\s/g, '%20')
      .split(/\s/)
      .filter(Boolean)
      .map(function(value) {
        return value.replace(/%20/g, ' ');
      });

    process.argv = process.argv
      .slice(0, 2)
      .concat(opts.concat(process.argv.slice(2)));
  } catch (err) {
    // ignore
  }

  process.env.LOADED_MOCHA_OPTS = true;
}