Skip to content

Commit f04b7a9

Browse files
pangrrbcoe
authored andcommitted
feat: add option to hook vm.runInContext (#680)
1 parent cdfdff3 commit f04b7a9

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ function NYC (config) {
7979
}.bind(this), {})
8080

8181
this.hookRunInContext = config.hookRunInContext
82+
this.hookRunInThisContext = config.hookRunInThisContext
8283
this.fakeRequire = null
8384

8485
this.processInfo = new ProcessInfo(config && config._processInfo)
@@ -311,6 +312,9 @@ NYC.prototype._wrapRequire = function () {
311312

312313
NYC.prototype._addOtherHooks = function () {
313314
if (this.hookRunInContext) {
315+
this._addHook('RunInContext')
316+
}
317+
if (this.hookRunInThisContext) {
314318
this._addHook('RunInThisContext')
315319
}
316320
}

lib/config-util.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ Config.buildYargs = function (cwd) {
173173
global: false
174174
})
175175
.option('hook-run-in-context', {
176+
default: true,
177+
type: 'boolean',
178+
description: 'should nyc wrap vm.runInContext?',
179+
global: false
180+
})
181+
.option('hook-run-in-this-context', {
176182
default: true,
177183
type: 'boolean',
178184
description: 'should nyc wrap vm.runInThisContext?',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"foreground-child": "^1.5.3",
8585
"glob": "^7.0.6",
8686
"istanbul-lib-coverage": "^1.1.1",
87-
"istanbul-lib-hook": "^1.0.7",
87+
"istanbul-lib-hook": "^1.1.0",
8888
"istanbul-lib-instrument": "^1.8.0",
8989
"istanbul-lib-report": "^1.1.1",
9090
"istanbul-lib-source-maps": "^1.2.1",

0 commit comments

Comments
 (0)