-
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use istanbul-lib-hook to wrap require and support vm hooks (#308)
- Loading branch information
1 parent
60843a4
commit 2b64cf8
Showing
10 changed files
with
104 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
"build": "node ./build-tests", | ||
"instrument": "node ./build-self-coverage.js", | ||
"run-tests": "tap -t120 --no-cov -b ./test/build/*.js ./test/src/nyc-bin.js", | ||
"report": "istanbul report --include=./.self_coverage/*.json lcov text", | ||
"report": "node ./bin/nyc --temp-directory ./.self_coverage/ -r text -r lcov report", | ||
"cover": "npm run clean && npm run build && npm run instrument && npm run run-tests && npm run report", | ||
"dev": "npm run clean && npm run build && npm run run-tests", | ||
"version": "standard-version" | ||
|
@@ -72,7 +72,6 @@ | |
"author": "Ben Coe <[email protected]>", | ||
"license": "ISC", | ||
"dependencies": { | ||
"append-transform": "^0.4.0", | ||
"arrify": "^1.0.1", | ||
"caching-transform": "^1.0.0", | ||
"convert-source-map": "^1.1.2", | ||
|
@@ -82,6 +81,7 @@ | |
"foreground-child": "^1.5.3", | ||
"glob": "^7.0.3", | ||
"istanbul-lib-coverage": "^1.0.0-alpha.4", | ||
"istanbul-lib-hook": "^1.0.0-alpha.4", | ||
"istanbul-lib-instrument": "^1.1.0-alpha.1", | ||
"istanbul-lib-report": "^1.0.0-alpha.3", | ||
"istanbul-lib-source-maps": "^1.0.0-alpha.10", | ||
|
@@ -105,9 +105,9 @@ | |
"exists-sync": "0.0.3", | ||
"forking-tap": "^0.1.1", | ||
"is-windows": "^0.2.0", | ||
"istanbul": "^0.4.4", | ||
"lodash": "^4.12.0", | ||
"newline-regex": "^0.2.1", | ||
"requirejs": "^2.2.0", | ||
"sanitize-filename": "^1.5.3", | ||
"sinon": "^1.15.3", | ||
"source-map-support": "^0.4.1", | ||
|
@@ -134,6 +134,7 @@ | |
"glob", | ||
"istanbul-lib-coverage", | ||
"istanbul-lib-instrument", | ||
"istanbul-lib-hook", | ||
"istanbul-lib-report", | ||
"istanbul-lib-source-maps", | ||
"istanbul-reports", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// RequireJS uses `vm.runInThisContext` | ||
// make sure we add hooks for it as well | ||
|
||
var rjs = require('requirejs'), | ||
assert = require('assert'); | ||
|
||
rjs.config({ | ||
baseUrl : __dirname, | ||
nodeRequire : require | ||
}); | ||
|
||
rjs(['./lib/lorem'], function(lorem){ | ||
var result = lorem(1, 2, 3); | ||
assert.equal(9, result); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
define(function(){ | ||
|
||
function sum(a, b) { | ||
return a + b; | ||
} | ||
|
||
return { | ||
sum : sum | ||
}; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
define(['./ipsum'], function (ipsum) { | ||
|
||
return function exec(a, b, c){ | ||
return ipsum.sum(a, b) * c; | ||
}; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "hooktest", | ||
"version": "1.1.1", | ||
"description": "AMD/ requirejs test project", | ||
"main": "index.js", | ||
"dependencies": { | ||
"requirejs": "^2.2.0" | ||
}, | ||
"private": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This comment has been minimized.
Sorry, something went wrong.
wizzfileAug 19, 2016