diff --git a/lib/commands/check-coverage.js b/lib/commands/check-coverage.js index 6b12341b7..62dfb9081 100644 --- a/lib/commands/check-coverage.js +++ b/lib/commands/check-coverage.js @@ -7,6 +7,7 @@ exports.describe = 'check whether coverage is within thresholds provided' exports.builder = function (yargs) { yargs + .demandCommand(0, 0) .option('exclude', { alias: 'x', default: testExclude.defaultExclude, diff --git a/lib/commands/instrument.js b/lib/commands/instrument.js index f744faef6..701dcb6f7 100644 --- a/lib/commands/instrument.js +++ b/lib/commands/instrument.js @@ -9,6 +9,15 @@ exports.describe = 'instruments a file or a directory tree and writes the instru exports.builder = function (yargs) { return yargs + .demandCommand(0, 0) + .positional('input', { + describe: 'file or directory to instrument', + type: 'text' + }) + .positional('output', { + describe: 'directory to output instrumented files', + type: 'text' + }) .option('require', { alias: 'i', default: [], diff --git a/lib/commands/merge.js b/lib/commands/merge.js index 072cfc450..98c6ff2d0 100644 --- a/lib/commands/merge.js +++ b/lib/commands/merge.js @@ -11,6 +11,7 @@ exports.describe = 'merge istanbul format coverage output in a given folder' exports.builder = function (yargs) { return yargs + .demandCommand(0, 0) .positional('input-directory', { describe: 'directory containing multiple istanbul coverage files', type: 'text', diff --git a/lib/commands/report.js b/lib/commands/report.js index 739ff30dc..345983d23 100644 --- a/lib/commands/report.js +++ b/lib/commands/report.js @@ -7,6 +7,7 @@ exports.describe = 'run coverage report for .nyc_output' exports.builder = function (yargs) { return yargs + .demandCommand(0, 0) .option('reporter', { alias: 'r', describe: 'coverage reporter(s) to use', diff --git a/tap-snapshots/test-nyc-integration.js-TAP.test.js b/tap-snapshots/test-nyc-integration.js-TAP.test.js index ea6d27b5e..937a3e807 100644 --- a/tap-snapshots/test-nyc-integration.js-TAP.test.js +++ b/tap-snapshots/test-nyc-integration.js-TAP.test.js @@ -20,25 +20,6 @@ All files | 33.33 | 0 | 100 | 33.33 | ` -exports[`test/nyc-integration.js TAP --check-coverage fails when check-coverage command is used rather than flag > stderr 1`] = ` -ERROR: Coverage for lines (50%) does not meet global threshold (51%) - -` - -exports[`test/nyc-integration.js TAP --check-coverage fails when check-coverage command is used rather than flag > stdout 1`] = ` ------------------|----------|----------|----------|----------|-------------------| -File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ------------------|----------|----------|----------|----------|-------------------| -All files | 50 | 50 | 100 | 50 | | - half-covered.js | 50 | 50 | 100 | 50 | 6,7,8 | ------------------|----------|----------|----------|----------|-------------------| - -` - -exports[`test/nyc-integration.js TAP --check-coverage fails when check-coverage command is used rather than flag > stdout 2`] = ` - -` - exports[`test/nyc-integration.js TAP --check-coverage fails when the expected coverage is below a threshold > stderr 1`] = ` ERROR: Coverage for lines (50%) does not meet global threshold (51%) @@ -310,6 +291,25 @@ end_of_record ` +exports[`test/nyc-integration.js TAP check-coverage command is equivalent to the flag > stderr 1`] = ` +ERROR: Coverage for lines (50%) does not meet global threshold (51%) + +` + +exports[`test/nyc-integration.js TAP check-coverage command is equivalent to the flag > stdout 1`] = ` +-----------------|----------|----------|----------|----------|-------------------| +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | +-----------------|----------|----------|----------|----------|-------------------| +All files | 50 | 50 | 100 | 50 | | + half-covered.js | 50 | 50 | 100 | 50 | 6,7,8 | +-----------------|----------|----------|----------|----------|-------------------| + +` + +exports[`test/nyc-integration.js TAP check-coverage command is equivalent to the flag > stdout 2`] = ` + +` + exports[`test/nyc-integration.js TAP does not interpret args intended for instrumented bin > undefined 1`] = ` [ '--help', '--version' ] ` diff --git a/test/nyc-integration.js b/test/nyc-integration.js index 86937e7aa..c4e0d9064 100644 --- a/test/nyc-integration.js +++ b/test/nyc-integration.js @@ -45,11 +45,11 @@ t.test('--check-coverage fails when the expected coverage is below a threshold', })) // https://github.com/istanbuljs/nyc/issues/384 -t.test('--check-coverage fails when check-coverage command is used rather than flag', t => { +t.test('check-coverage command is equivalent to the flag', t => { return testSuccess(t, { args: [process.execPath, './half-covered.js'] }).then(() => testFailure(t, { - args: ['check-coverage', '--lines', '51', process.execPath, './half-covered.js'] + args: ['check-coverage', '--lines', '51'] })) })