Skip to content

Commit 95cc09a

Browse files
authored
feat: upgrade to version of yargs with extend support (#541)
1 parent 43535f9 commit 95cc09a

File tree

4 files changed

+60
-39
lines changed

4 files changed

+60
-39
lines changed

lib/config-util.js

+42-21
Original file line numberDiff line numberDiff line change
@@ -98,105 +98,126 @@ Config.buildYargs = function (cwd) {
9898
.option('reporter', {
9999
alias: 'r',
100100
describe: 'coverage reporter(s) to use',
101-
default: 'text'
101+
default: 'text',
102+
globa: false
102103
})
103104
.option('report-dir', {
104105
describe: 'directory to output coverage reports in',
105-
default: 'coverage'
106+
default: 'coverage',
107+
global: false
106108
})
107109
.option('silent', {
108110
alias: 's',
109111
default: false,
110112
type: 'boolean',
111-
describe: "don't output a report after tests finish running"
113+
describe: "don't output a report after tests finish running",
114+
global: false
112115
})
113116
.option('all', {
114117
alias: 'a',
115118
default: false,
116119
type: 'boolean',
117-
describe: 'whether or not to instrument all files of the project (not just the ones touched by your test suite)'
120+
describe: 'whether or not to instrument all files of the project (not just the ones touched by your test suite)',
121+
global: false
118122
})
119123
.option('exclude', {
120124
alias: 'x',
121125
default: testExclude.defaultExclude,
122-
describe: 'a list of specific files and directories that should be excluded from coverage, glob patterns are supported, node_modules is always excluded'
126+
describe: 'a list of specific files and directories that should be excluded from coverage, glob patterns are supported, node_modules is always excluded',
127+
global: false
123128
})
124129
.option('include', {
125130
alias: 'n',
126131
default: [],
127-
describe: 'a list of specific files that should be covered, glob patterns are supported'
132+
describe: 'a list of specific files that should be covered, glob patterns are supported',
133+
global: false
128134
})
129135
.option('require', {
130136
alias: 'i',
131137
default: [],
132-
describe: 'a list of additional modules that nyc should attempt to require in its subprocess, e.g., babel-register, babel-polyfill.'
138+
describe: 'a list of additional modules that nyc should attempt to require in its subprocess, e.g., babel-register, babel-polyfill.',
139+
global: false
133140
})
134141
.option('eager', {
135142
default: false,
136143
type: 'boolean',
137-
describe: 'instantiate the instrumenter at startup (see https://git.io/vMKZ9)'
144+
describe: 'instantiate the instrumenter at startup (see https://git.io/vMKZ9)',
145+
global: false
138146
})
139147
.option('cache', {
140148
alias: 'c',
141149
default: true,
142150
type: 'boolean',
143-
describe: 'cache instrumentation results for improved performance'
151+
describe: 'cache instrumentation results for improved performance',
152+
global: false
144153
})
145154
.option('babel-cache', {
146155
default: false,
147156
type: 'boolean',
148-
describe: 'cache babel transpilation results for improved performance'
157+
describe: 'cache babel transpilation results for improved performance',
158+
global: false
149159
})
150160
.option('extension', {
151161
alias: 'e',
152162
default: [],
153-
describe: 'a list of extensions that nyc should handle in addition to .js'
163+
describe: 'a list of extensions that nyc should handle in addition to .js',
164+
global: false
154165
})
155166
.option('check-coverage', {
156167
type: 'boolean',
157168
default: false,
158-
describe: 'check whether coverage is within thresholds provided'
169+
describe: 'check whether coverage is within thresholds provided',
170+
global: false
159171
})
160172
.option('branches', {
161173
default: 0,
162-
description: 'what % of branches must be covered?'
174+
description: 'what % of branches must be covered?',
175+
global: false
163176
})
164177
.option('functions', {
165178
default: 0,
166-
description: 'what % of functions must be covered?'
179+
description: 'what % of functions must be covered?',
180+
global: false
167181
})
168182
.option('lines', {
169183
default: 90,
170-
description: 'what % of lines must be covered?'
184+
description: 'what % of lines must be covered?',
185+
global: false
171186
})
172187
.option('statements', {
173188
default: 0,
174-
description: 'what % of statements must be covered?'
189+
description: 'what % of statements must be covered?',
190+
global: false
175191
})
176192
.option('source-map', {
177193
default: true,
178194
type: 'boolean',
179-
description: 'should nyc detect and handle source maps?'
195+
description: 'should nyc detect and handle source maps?',
196+
global: false
180197
})
181198
.option('produce-source-map', {
182199
default: false,
183200
type: 'boolean',
184-
description: "should nyc's instrumenter produce source maps?"
201+
description: "should nyc's instrumenter produce source maps?",
202+
global: false
185203
})
186204
.option('instrument', {
187205
default: true,
188206
type: 'boolean',
189-
description: 'should nyc handle instrumentation?'
207+
description: 'should nyc handle instrumentation?',
208+
global: false
190209
})
191210
.option('hook-run-in-context', {
192211
default: true,
193212
type: 'boolean',
194-
description: 'should nyc wrap vm.runInThisContext?'
213+
description: 'should nyc wrap vm.runInThisContext?',
214+
global: false
195215
})
196216
.option('show-process-tree', {
197217
describe: 'display the tree of spawned processes',
198218
default: false,
199-
type: 'boolean'
219+
type: 'boolean',
220+
global: false
200221
})
201222
.pkgConf('nyc', cwd || process.cwd())
202223
.example('$0 npm test', 'instrument your tests with coverage')

package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@
8282
"find-up": "^1.1.2",
8383
"foreground-child": "^1.5.3",
8484
"glob": "^7.0.6",
85-
"istanbul-lib-coverage": "^1.0.1",
86-
"istanbul-lib-hook": "^1.0.4",
87-
"istanbul-lib-instrument": "^1.6.1",
88-
"istanbul-lib-report": "^1.0.0-alpha.3",
89-
"istanbul-lib-source-maps": "^1.1.0",
90-
"istanbul-reports": "^1.0.1",
85+
"istanbul-lib-coverage": "^1.0.2",
86+
"istanbul-lib-hook": "^1.0.5",
87+
"istanbul-lib-instrument": "^1.7.0",
88+
"istanbul-lib-report": "^1.0.0",
89+
"istanbul-lib-source-maps": "^1.1.1",
90+
"istanbul-reports": "^1.0.2",
9191
"md5-hex": "^1.2.0",
9292
"merge-source-map": "^1.0.2",
9393
"micromatch": "^2.3.11",
@@ -97,7 +97,7 @@
9797
"signal-exit": "^3.0.1",
9898
"spawn-wrap": "1.2.4",
9999
"test-exclude": "^4.0.0",
100-
"yargs": "^6.6.0",
100+
"yargs": "^7.0.2",
101101
"yargs-parser": "^4.0.2"
102102
},
103103
"devDependencies": {
@@ -112,10 +112,10 @@
112112
"newline-regex": "^0.2.1",
113113
"requirejs": "^2.3.0",
114114
"sanitize-filename": "^1.5.3",
115-
"sinon": "^1.15.3",
115+
"sinon": "^2.1.0",
116116
"source-map-support": "^0.4.6",
117117
"split-lines": "^1.0.0",
118-
"standard": "^8.0.0",
118+
"standard": "^9.0.2",
119119
"standard-version": "^4.0.0",
120120
"tap": "^10.0.0",
121121
"which": "^1.2.11",

test/src/nyc-bin.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,9 @@ describe('the nyc cli', function () {
718718
proc.on('close', function (code) {
719719
code.should.equal(0)
720720
// 50% line coverage is below our low watermark (so it's red).
721-
stdout.should.match(/\[91m\W+50\W+/)
721+
stdout.should.match(/\[31;1m\W+50\W+/)
722722
// 50% statement coverage is above our high-watermark (so it's green).
723-
stdout.should.match(/\[92m\W+50\W+/)
723+
stdout.should.match(/\[32;1m\W+50\W+/)
724724
done()
725725
})
726726
})

test/src/nyc-test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ describe('nyc', function () {
175175
nyc.wrap()
176176

177177
var check = require('../fixtures/check-instrumented')
178-
check().should.be.true
178+
check().should.equal(true)
179179
})
180180

181181
describe('custom require hooks are installed', function () {
@@ -195,7 +195,7 @@ describe('nyc', function () {
195195
require.extensions['.js'] = hook
196196

197197
var check = require('../fixtures/check-instrumented')
198-
check().should.be.true
198+
check().should.equal(true)
199199

200200
// and the hook should have been called
201201
hook.callCount.should.equal(1)
@@ -232,11 +232,11 @@ describe('nyc', function () {
232232
nyc.reset()
233233
nyc.wrap()
234234

235-
require.extensions['.es6'].should.be.a.function
236-
require.extensions['.foo.bar'].should.be.a.function
235+
require.extensions['.es6'].should.be.a.function // eslint-disable-line
236+
require.extensions['.foo.bar'].should.be.a.function // eslint-disable-line
237237

238238
// default should still exist
239-
require.extensions['.js'].should.be.a.function
239+
require.extensions['.js'].should.be.a.function // eslint-disable-line
240240
})
241241

242242
it('calls the `_handleJs` function for custom file extensions', function () {
@@ -254,8 +254,8 @@ describe('nyc', function () {
254254

255255
var check1 = require('../fixtures/conf-multiple-extensions/check-instrumented.es6')
256256
var check2 = require('../fixtures/conf-multiple-extensions/check-instrumented.foo.bar')
257-
check1().should.be.true
258-
check2().should.be.true
257+
check1().should.equal(true)
258+
check2().should.equal(true)
259259
nyc._handleJs.callCount.should.equal(2)
260260
})
261261
})

0 commit comments

Comments
 (0)