Socket
Socket
Sign inDemoInstall

istanbul-lib-instrument

Package Overview
Dependencies
Maintainers
3
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

istanbul-lib-instrument - npm Package Compare versions

Comparing version 4.0.0-alpha.1 to 4.0.0-alpha.2

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [4.0.0-alpha.2](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-instrument@4.0.0-alpha.1...istanbul-lib-instrument@4.0.0-alpha.2) (2019-11-01)
### Bug Fixes
* Produce properly merged source-maps when inputSourceMap is provided ([#487](https://github.com/istanbuljs/istanbuljs/issues/487)) ([8f8c88e](https://github.com/istanbuljs/istanbuljs/commit/8f8c88e3a2add4c08729e41e356aa7981dc69d4d))
# [4.0.0-alpha.1](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-instrument@4.0.0-alpha.0...istanbul-lib-instrument@4.0.0-alpha.1) (2019-10-06)

@@ -8,0 +19,0 @@

88

dist/instrumenter.js

@@ -8,10 +8,4 @@ "use strict";

var parser = _interopRequireWildcard(require("@babel/parser"));
var _core = require("@babel/core");
var t = _interopRequireWildcard(require("@babel/types"));
var _traverse = _interopRequireDefault(require("@babel/traverse"));
var _generator = _interopRequireDefault(require("@babel/generator"));
var _schema = require("@istanbuljs/schema");

@@ -25,6 +19,2 @@

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/*

@@ -82,44 +72,56 @@ Copyright 2012-2015, Yahoo Inc.

filename = filename || String(new Date().getTime()) + '.js';
const opts = this.opts;
const ast = parser.parse(code, {
allowReturnOutsideFunction: opts.autoWrap,
sourceType: opts.esModules ? 'module' : 'script',
plugins: opts.parserPlugins
});
const ee = (0, _visitor.default)(t, filename, {
coverageVariable: opts.coverageVariable,
coverageGlobalScope: opts.coverageGlobalScope,
coverageGlobalScopeFunc: opts.coverageGlobalScopeFunc,
ignoreClassMethods: opts.ignoreClassMethods,
inputSourceMap
});
const {
opts
} = this;
let output = {};
const visitor = {
Program: {
enter: ee.enter,
const babelOpts = {
configFile: false,
babelrc: false,
ast: true,
filename: filename || String(new Date().getTime()) + '.js',
inputSourceMap,
sourceMaps: opts.produceSourceMap,
compact: opts.compact,
comments: opts.preserveComments,
parserOpts: {
allowReturnOutsideFunction: opts.autoWrap,
sourceType: opts.esModules ? 'module' : 'script',
plugins: opts.parserPlugins
},
plugins: [[({
types
}) => {
const ee = (0, _visitor.default)(types, filename, {
coverageVariable: opts.coverageVariable,
coverageGlobalScope: opts.coverageGlobalScope,
coverageGlobalScopeFunc: opts.coverageGlobalScopeFunc,
ignoreClassMethods: opts.ignoreClassMethods,
inputSourceMap
});
return {
visitor: {
Program: {
enter: ee.enter,
exit(path) {
output = ee.exit(path);
}
exit(path) {
output = ee.exit(path);
}
}
}
}
};
}]]
};
(0, _traverse.default)(ast, visitor);
const generateOptions = {
compact: opts.compact,
comments: opts.preserveComments,
sourceMaps: opts.produceSourceMap,
sourceFileName: filename
};
const codeMap = (0, _generator.default)(ast, generateOptions, code);
const codeMap = (0, _core.transformSync)(code, babelOpts);
if (output && output.fileCoverage) {
this.fileCoverage = output.fileCoverage;
} else {
const initialCoverage = (0, _readCoverage.default)(ast) ||
if (!output || !output.fileCoverage) {
const initialCoverage = (0, _readCoverage.default)(codeMap.ast) ||
/* istanbul ignore next: paranoid check */
{};
this.fileCoverage = initialCoverage.coverageData;
this.sourceMap = inputSourceMap;
return code;
}
this.fileCoverage = output.fileCoverage;
this.sourceMap = codeMap.map;

@@ -126,0 +128,0 @@ const cb = this.opts.sourceMapUrlCallback;

@@ -12,4 +12,2 @@ "use strict";

var t = _interopRequireWildcard(require("@babel/types"));
var _schema = require("@istanbuljs/schema");

@@ -19,6 +17,2 @@

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -55,3 +49,3 @@

if (!node.computed && t.isIdentifier(node.key) && node.key.name === _constants.MAGIC_KEY) {
if (!node.computed && path.get('key').isIdentifier() && node.key.name === _constants.MAGIC_KEY) {
const magicValue = path.get('value').evaluate();

@@ -58,0 +52,0 @@

{
"name": "istanbul-lib-instrument",
"version": "4.0.0-alpha.1",
"version": "4.0.0-alpha.2",
"description": "Core istanbul API for JS code coverage",

@@ -16,7 +16,6 @@ "author": "Krishnan Anantheswaran <kananthmail-github@yahoo.com>",

"dependencies": {
"@babel/generator": "^7.6.2",
"@babel/core": "^7.6.2",
"@babel/parser": "^7.6.2",
"@babel/template": "^7.6.0",
"@babel/traverse": "^7.6.2",
"@babel/types": "^7.6.1",
"@istanbuljs/schema": "^0.1.0",

@@ -28,3 +27,2 @@ "istanbul-lib-coverage": "^3.0.0-alpha.1",

"@babel/cli": "^7.6.2",
"@babel/core": "^7.6.2",
"@babel/plugin-transform-modules-commonjs": "^7.6.0",

@@ -60,3 +58,3 @@ "@babel/register": "^7.6.2",

},
"gitHead": "4d5e777a9bc4847d178ad31f379307124cdd1e4f"
"gitHead": "7c1367b5786fd6378aa0f3920386672a15edac71"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc