MCPcopy Create free account
hub / github.com/bcoe/c8 / buildYargs

Function buildYargs

lib/parse-args.js:10–200  ·  view source on GitHub ↗
(withCommands = false)

Source from the content-addressed store, hash-verified

8const { resolve } = require('path')
9
10function buildYargs (withCommands = false) {
11 const yargs = Yargs([])
12 .usage('$0 [opts] [script] [opts]')
13 .options('config', {
14 alias: 'c',
15 config: true,
16 describe: 'path to JSON configuration file',
17 configParser: (path) => {
18 const config = JSON.parse(readFileSync(path))
19 return applyExtends(config, process.cwd(), true)
20 },
21 default: () => findUp.sync(['.c8rc', '.c8rc.json', '.nycrc', '.nycrc.json'])
22 })
23 .option('reporter', {
24 alias: 'r',
25 group: 'Reporting options',
26 describe: 'coverage reporter(s) to use',
27 default: 'text'
28 })
29 .option('reports-dir', {
30 alias: ['o', 'report-dir'],
31 group: 'Reporting options',
32 describe: 'directory where coverage reports will be output to',
33 default: './coverage'
34 })
35 .options('all', {
36 default: false,
37 type: 'boolean',
38 group: 'Reporting options',
39 describe: 'supplying --all will cause c8 to consider all src files in the current working directory ' +
40 'when the determining coverage. Respects include/exclude.'
41 })
42 .options('src', {
43 default: undefined,
44 type: 'string',
45 group: 'Reporting options',
46 describe: 'supplying --src will override cwd as the default location where --all looks for src files. --src can be ' +
47 'supplied multiple times and each directory will be included. This allows for workspaces spanning multiple projects'
48 })
49 .option('exclude-node-modules', {
50 default: true,
51 type: 'boolean',
52 describe: 'whether or not to exclude all node_module folders (i.e. **/node_modules/**) by default'
53 })
54 .option('include', {
55 alias: 'n',
56 default: [],
57 group: 'Reporting options',
58 describe: 'a list of specific files that should be covered (glob patterns are supported)'
59 })
60 .option('exclude', {
61 alias: 'x',
62 default: defaultExclude,
63 group: 'Reporting options',
64 describe: 'a list of specific files and directories that should be excluded from coverage (glob patterns are supported)'
65 })
66 .option('extension', {
67 alias: 'e',

Callers 3

parse-args.jsFile · 0.85
c8.jsFile · 0.85
runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected