diff options
Diffstat (limited to 'node_modules/istanbul-lib-instrument/dist/visitor.js')
-rw-r--r-- | node_modules/istanbul-lib-instrument/dist/visitor.js | 10 |
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, |