From 95cc09af6bb0839469e6a047b432fd8906809bd6 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Mon, 27 Mar 2017 21:40:23 -0700 Subject: [PATCH] feat: upgrade to version of yargs with extend support (#541) --- lib/config-util.js | 63 +++++++++++++++++++++++++++++--------------- package.json | 18 ++++++------- test/src/nyc-bin.js | 4 +-- test/src/nyc-test.js | 14 +++++----- 4 files changed, 60 insertions(+), 39 deletions(-) diff --git a/lib/config-util.js b/lib/config-util.js index 2607702a8..245b1c323 100644 --- a/lib/config-util.js +++ b/lib/config-util.js @@ -98,105 +98,126 @@ Config.buildYargs = function (cwd) { .option('reporter', { alias: 'r', describe: 'coverage reporter(s) to use', - default: 'text' + default: 'text', + globa: false }) .option('report-dir', { describe: 'directory to output coverage reports in', - default: 'coverage' + default: 'coverage', + global: false }) .option('silent', { alias: 's', default: false, type: 'boolean', - describe: "don't output a report after tests finish running" + describe: "don't output a report after tests finish running", + global: false }) .option('all', { alias: 'a', default: false, type: 'boolean', - describe: 'whether or not to instrument all files of the project (not just the ones touched by your test suite)' + describe: 'whether or not to instrument all files of the project (not just the ones touched by your test suite)', + global: false }) .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' + 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('include', { alias: 'n', default: [], - describe: 'a list of specific files that should be covered, glob patterns are supported' + describe: 'a list of specific files that should be covered, glob patterns are supported', + global: false }) .option('require', { alias: 'i', default: [], - describe: 'a list of additional modules that nyc should attempt to require in its subprocess, e.g., babel-register, babel-polyfill.' + describe: 'a list of additional modules that nyc should attempt to require in its subprocess, e.g., babel-register, babel-polyfill.', + global: false }) .option('eager', { default: false, type: 'boolean', - describe: 'instantiate the instrumenter at startup (see https://git.io/vMKZ9)' + describe: 'instantiate the instrumenter at startup (see https://git.io/vMKZ9)', + global: false }) .option('cache', { alias: 'c', default: true, type: 'boolean', - describe: 'cache instrumentation results for improved performance' + describe: 'cache instrumentation results for improved performance', + global: false }) .option('babel-cache', { default: false, type: 'boolean', - describe: 'cache babel transpilation results for improved performance' + describe: 'cache babel transpilation results for improved performance', + global: false }) .option('extension', { alias: 'e', default: [], - describe: 'a list of extensions that nyc should handle in addition to .js' + describe: 'a list of extensions that nyc should handle in addition to .js', + global: false }) .option('check-coverage', { type: 'boolean', default: false, - describe: 'check whether coverage is within thresholds provided' + describe: 'check whether coverage is within thresholds provided', + global: false }) .option('branches', { default: 0, - description: 'what % of branches must be covered?' + description: 'what % of branches must be covered?', + global: false }) .option('functions', { default: 0, - description: 'what % of functions must be covered?' + description: 'what % of functions must be covered?', + global: false }) .option('lines', { default: 90, - description: 'what % of lines must be covered?' + description: 'what % of lines must be covered?', + global: false }) .option('statements', { default: 0, - description: 'what % of statements must be covered?' + description: 'what % of statements must be covered?', + global: false }) .option('source-map', { default: true, type: 'boolean', - description: 'should nyc detect and handle source maps?' + description: 'should nyc detect and handle source maps?', + global: false }) .option('produce-source-map', { default: false, type: 'boolean', - description: "should nyc's instrumenter produce source maps?" + description: "should nyc's instrumenter produce source maps?", + global: false }) .option('instrument', { default: true, type: 'boolean', - description: 'should nyc handle instrumentation?' + description: 'should nyc handle instrumentation?', + global: false }) .option('hook-run-in-context', { default: true, type: 'boolean', - description: 'should nyc wrap vm.runInThisContext?' + description: 'should nyc wrap vm.runInThisContext?', + global: false }) .option('show-process-tree', { describe: 'display the tree of spawned processes', default: false, - type: 'boolean' + type: 'boolean', + global: false }) .pkgConf('nyc', cwd || process.cwd()) .example('$0 npm test', 'instrument your tests with coverage') diff --git a/package.json b/package.json index 0a58e873f..7c101f796 100644 --- a/package.json +++ b/package.json @@ -82,12 +82,12 @@ "find-up": "^1.1.2", "foreground-child": "^1.5.3", "glob": "^7.0.6", - "istanbul-lib-coverage": "^1.0.1", - "istanbul-lib-hook": "^1.0.4", - "istanbul-lib-instrument": "^1.6.1", - "istanbul-lib-report": "^1.0.0-alpha.3", - "istanbul-lib-source-maps": "^1.1.0", - "istanbul-reports": "^1.0.1", + "istanbul-lib-coverage": "^1.0.2", + "istanbul-lib-hook": "^1.0.5", + "istanbul-lib-instrument": "^1.7.0", + "istanbul-lib-report": "^1.0.0", + "istanbul-lib-source-maps": "^1.1.1", + "istanbul-reports": "^1.0.2", "md5-hex": "^1.2.0", "merge-source-map": "^1.0.2", "micromatch": "^2.3.11", @@ -97,7 +97,7 @@ "signal-exit": "^3.0.1", "spawn-wrap": "1.2.4", "test-exclude": "^4.0.0", - "yargs": "^6.6.0", + "yargs": "^7.0.2", "yargs-parser": "^4.0.2" }, "devDependencies": { @@ -112,10 +112,10 @@ "newline-regex": "^0.2.1", "requirejs": "^2.3.0", "sanitize-filename": "^1.5.3", - "sinon": "^1.15.3", + "sinon": "^2.1.0", "source-map-support": "^0.4.6", "split-lines": "^1.0.0", - "standard": "^8.0.0", + "standard": "^9.0.2", "standard-version": "^4.0.0", "tap": "^10.0.0", "which": "^1.2.11", diff --git a/test/src/nyc-bin.js b/test/src/nyc-bin.js index b440a47c0..564c1030c 100644 --- a/test/src/nyc-bin.js +++ b/test/src/nyc-bin.js @@ -718,9 +718,9 @@ describe('the nyc cli', function () { proc.on('close', function (code) { code.should.equal(0) // 50% line coverage is below our low watermark (so it's red). - stdout.should.match(/\[91m\W+50\W+/) + stdout.should.match(/\[31;1m\W+50\W+/) // 50% statement coverage is above our high-watermark (so it's green). - stdout.should.match(/\[92m\W+50\W+/) + stdout.should.match(/\[32;1m\W+50\W+/) done() }) }) diff --git a/test/src/nyc-test.js b/test/src/nyc-test.js index 9ef998b7c..7f123fec3 100644 --- a/test/src/nyc-test.js +++ b/test/src/nyc-test.js @@ -175,7 +175,7 @@ describe('nyc', function () { nyc.wrap() var check = require('../fixtures/check-instrumented') - check().should.be.true + check().should.equal(true) }) describe('custom require hooks are installed', function () { @@ -195,7 +195,7 @@ describe('nyc', function () { require.extensions['.js'] = hook var check = require('../fixtures/check-instrumented') - check().should.be.true + check().should.equal(true) // and the hook should have been called hook.callCount.should.equal(1) @@ -232,11 +232,11 @@ describe('nyc', function () { nyc.reset() nyc.wrap() - require.extensions['.es6'].should.be.a.function - require.extensions['.foo.bar'].should.be.a.function + require.extensions['.es6'].should.be.a.function // eslint-disable-line + require.extensions['.foo.bar'].should.be.a.function // eslint-disable-line // default should still exist - require.extensions['.js'].should.be.a.function + require.extensions['.js'].should.be.a.function // eslint-disable-line }) it('calls the `_handleJs` function for custom file extensions', function () { @@ -254,8 +254,8 @@ describe('nyc', function () { var check1 = require('../fixtures/conf-multiple-extensions/check-instrumented.es6') var check2 = require('../fixtures/conf-multiple-extensions/check-instrumented.foo.bar') - check1().should.be.true - check2().should.be.true + check1().should.equal(true) + check2().should.equal(true) nyc._handleJs.callCount.should.equal(2) }) })