Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
const yargs = require('yargs')
const exclude = require('test-exclude')
const sw = require('spawn-wrap')
const foreground = require('foreground-child')
const mkdirp = require('mkdirp')
const rimraf = require('rimraf')
const path = require('path')
yargs // eslint-disable-line
.usage('$0 [opts]
1,
nodePath,
...ext === 'mjs' ? [
'--experimental-modules',
'--es-module-specifier-resolution=node',
'--no-warnings'
] : [],
entryPath
);
}
return [
nodePath,
[
c8BinPath,
...require('test-exclude').defaultExclude.map(pattern => `--exclude="${
pattern
// Remove this when https://github.com/istanbuljs/istanbuljs/pull/381 is merged
.replace(/(?<=\.)(?=js$)/ui, '{,c,m}')
// Remove this when https://github.com/istanbuljs/istanbuljs/pull/419 is merged
.replace(/(?<=test)(?=\/)/ui, '{,s}')
}"`),
'--exclude="**/*.json"',
...reporter === undefined ? [
'--reporter=text',
`--reporter=${willUploadLcov ? 'lcovonly' : 'html'}`
] : [],
...optionArgs
]
];
})();
type: 'boolean',
},
nyc: {
description: 'nyc instruments passthrough',
type: 'string',
default: '--temp-directory ./node_modules/.nyc_output -r text-summary -r json-summary -r json -r lcov',
},
};
// you can add ignore dirs here
this[EXCLUDES] = new Set([
'example/',
'examples/',
'mocks**/',
'docs/',
].concat(testExclude.defaultExclude));
}
return function shouldSkip (file, nycConfig) {
if (!exclude || (exclude.cwd !== nycConfig.cwd)) {
exclude = new TestExclude({
cwd: nycConfig.cwd,
include: nycConfig.include,
exclude: nycConfig.exclude,
extension: nycConfig.extension,
// Make sure this is true unless explicitly set to `false`. `undefined` is still `true`.
excludeNodeModules: nycConfig.excludeNodeModules !== false
})
}
return !exclude.shouldInstrument(file)
}
}
})
.option('report-dir', {
describe: 'directory to output coverage reports in',
default: 'coverage'
})
.option('temp-dir', {
alias: 't',
describe: 'directory to read raw coverage information from',
default: './.nyc_output'
})
.option('temp-directory', {
hidden: true
})
.option('exclude', {
alias: 'x',
default: testExclude.defaultExclude,
describe: 'a list of specific files and directories that should be excluded from coverage, glob patterns are supported, node_modules is always excluded',
global: false
})
.option('exclude-node-modules', {
default: true,
type: 'boolean',
describe: 'whether or not to exclude all node_module folders (i.e. **/node_modules/**) by default',
global: false
})
.option('exclude-after-remap', {
default: true,
type: 'boolean',
description: 'should exclude logic be performed after the source-map remaps filenames?',
global: false
})
.option('include', {