diff options
Diffstat (limited to 'node_modules/istanbul-lib-instrument/dist')
3 files changed, 8 insertions, 5 deletions
diff --git a/node_modules/istanbul-lib-instrument/dist/instrumenter.js b/node_modules/istanbul-lib-instrument/dist/instrumenter.js index 313647ccf..cbd74af65 100644 --- a/node_modules/istanbul-lib-instrument/dist/instrumenter.js +++ b/node_modules/istanbul-lib-instrument/dist/instrumenter.js @@ -140,6 +140,7 @@ var Instrumenter = function () { var generateOptions = { compact: opts.compact, + comments: opts.preserveComments, sourceMaps: opts.produceSourceMap, sourceFileName: filename }; diff --git a/node_modules/istanbul-lib-instrument/dist/read-coverage.js b/node_modules/istanbul-lib-instrument/dist/read-coverage.js index 73e74291a..e2460c43c 100644 --- a/node_modules/istanbul-lib-instrument/dist/read-coverage.js +++ b/node_modules/istanbul-lib-instrument/dist/read-coverage.js @@ -45,7 +45,7 @@ function readInitialCoverage(code) { if (!magicValue.confident || magicValue.value !== _constants.MAGIC_VALUE) { return; } - covScope = path.scope.getFunctionParent(); + covScope = path.scope.getFunctionParent() || path.scope.getProgramParent(); path.stop(); } } 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, |
