How to use the nyc/lib/config-util.loadConfig function in nyc

To help you get started, we’ve selected a few nyc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github atom / github / test / runner.js View on Github external
global.assert = chai.assert;

// Give tests that rely on filesystem event delivery lots of breathing room.
until.setDefaultTimeout(parseInt(process.env.UNTIL_TIMEOUT || '3000', 10));

if (process.env.ATOM_GITHUB_BABEL_ENV === 'coverage' && !process.env.NYC_CONFIG) {
  // Set up Istanbul in this process.
  // This mimics the argument parsing and setup performed in:
  //   https://github.com/istanbuljs/nyc/blob/v13.0.0/bin/nyc.js
  // And the process-under-test wrapping done by:
  //   https://github.com/istanbuljs/nyc/blob/v13.0.0/bin/wrap.js

  const configUtil = require('nyc/lib/config-util');

  const yargs = configUtil.buildYargs();
  const config = configUtil.loadConfig({}, path.join(__dirname, '..'));
  configUtil.addCommandsAndHelp(yargs);
  const argv = yargs.config(config).parse([]);

  argv.instrumenter = require.resolve('nyc/lib/instrumenters/noop');
  argv.reporter = 'lcovonly';
  argv.cwd = path.join(__dirname, '..');
  argv.tempDirectory = path.join(__dirname, '..', '.nyc_output');

  global._nyc = new NYC(argv);

  if (argv.clean) {
    global._nyc.reset();
  } else {
    global._nyc.createTempDirectory();
  }
  if (argv.all) {