aboutsummaryrefslogtreecommitdiff
path: root/node_modules/istanbul-lib-instrument/dist/visitor.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/istanbul-lib-instrument/dist/visitor.js
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
update packages
Diffstat (limited to 'node_modules/istanbul-lib-instrument/dist/visitor.js')
-rw-r--r--node_modules/istanbul-lib-instrument/dist/visitor.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/node_modules/istanbul-lib-instrument/dist/visitor.js b/node_modules/istanbul-lib-instrument/dist/visitor.js
index 79744abf2..bd8f9e3ff 100644
--- a/node_modules/istanbul-lib-instrument/dist/visitor.js
+++ b/node_modules/istanbul-lib-instrument/dist/visitor.js
@@ -394,9 +394,11 @@ function parenthesizedExpressionProp(prop) {
function convertArrowExpression(path) {
var n = path.node;
var T = this.types;
- if (n.expression) {
+ if (!T.isBlockStatement(n.body)) {
var bloc = n.body.loc;
- n.expression = false;
+ if (n.expression === true) {
+ n.expression = false;
+ }
n.body = T.blockStatement([T.returnStatement(n.body)]);
// restore body location
n.body.loc = bloc;
@@ -508,7 +510,7 @@ var codeVisitor = {
LogicalExpression: entries(coverLogicalExpression)
};
// the template to insert at the top of the program.
-var coverageTemplate = (0, _babelTemplate2.default)('\n var COVERAGE_VAR = (function () {\n var path = PATH,\n hash = HASH,\n global = (new Function(\'return this\'))(),\n gcv = GLOBAL_COVERAGE_VAR,\n coverageData = INITIAL,\n coverage = global[gcv] || (global[gcv] = {});\n if (coverage[path] && coverage[path].hash === hash) {\n return coverage[path];\n }\n coverageData.hash = hash;\n return coverage[path] = coverageData;\n })();\n');
+var coverageTemplate = (0, _babelTemplate2.default)('\n var COVERAGE_VAR = (function () {\n var path = PATH,\n hash = HASH,\n Function = (function(){}).constructor,\n global = (new Function(\'return this\'))(),\n gcv = GLOBAL_COVERAGE_VAR,\n coverageData = INITIAL,\n coverage = global[gcv] || (global[gcv] = {});\n if (coverage[path] && coverage[path].hash === hash) {\n return coverage[path];\n }\n coverageData.hash = hash;\n return coverage[path] = coverageData;\n })();\n');
// the rewire plugin (and potentially other babel middleware)
// may cause files to be instrumented twice, see:
// https://github.com/istanbuljs/babel-plugin-istanbul/issues/94
@@ -582,7 +584,7 @@ function programVisitor(types) {
INITIAL: coverageNode,
HASH: T.stringLiteral(hash)
});
- cv._blockHoist = 3;
+ cv._blockHoist = 5;
path.node.body.unshift(cv);
return {
fileCoverage: coverageData,