Skip to content

Commit

Permalink
feat: upgrade to version of yargs with extend support (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Mar 28, 2017
1 parent 43535f9 commit 95cc09a
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 39 deletions.
63 changes: 42 additions & 21 deletions lib/config-util.js
Expand Up @@ -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')
Expand Down
18 changes: 9 additions & 9 deletions package.json
Expand Up @@ -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",
Expand All @@ -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": {
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions test/src/nyc-bin.js
Expand Up @@ -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()
})
})
Expand Down
14 changes: 7 additions & 7 deletions test/src/nyc-test.js
Expand Up @@ -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 () {
Expand All @@ -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)
Expand Down Expand Up @@ -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 () {
Expand All @@ -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)
})
})
Expand Down

0 comments on commit 95cc09a

Please sign in to comment.