Skip to content

Commit

Permalink
feat: add option to hook vm.runInContext (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
pangrr authored and bcoe committed Oct 23, 2017
1 parent cdfdff3 commit f04b7a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions index.js
Expand Up @@ -79,6 +79,7 @@ function NYC (config) {
}.bind(this), {})

this.hookRunInContext = config.hookRunInContext
this.hookRunInThisContext = config.hookRunInThisContext
this.fakeRequire = null

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

NYC.prototype._addOtherHooks = function () {
if (this.hookRunInContext) {
this._addHook('RunInContext')
}
if (this.hookRunInThisContext) {
this._addHook('RunInThisContext')
}
}
Expand Down
6 changes: 6 additions & 0 deletions lib/config-util.js
Expand Up @@ -173,6 +173,12 @@ Config.buildYargs = function (cwd) {
global: false
})
.option('hook-run-in-context', {
default: true,
type: 'boolean',
description: 'should nyc wrap vm.runInContext?',
global: false
})
.option('hook-run-in-this-context', {
default: true,
type: 'boolean',
description: 'should nyc wrap vm.runInThisContext?',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -84,7 +84,7 @@
"foreground-child": "^1.5.3",
"glob": "^7.0.6",
"istanbul-lib-coverage": "^1.1.1",
"istanbul-lib-hook": "^1.0.7",
"istanbul-lib-hook": "^1.1.0",
"istanbul-lib-instrument": "^1.8.0",
"istanbul-lib-report": "^1.1.1",
"istanbul-lib-source-maps": "^1.2.1",
Expand Down

0 comments on commit f04b7a9

Please sign in to comment.