Updating NPM dependencies
This commit is contained in:
107
node_modules/istanbul-lib-instrument/CHANGELOG.md
generated
vendored
107
node_modules/istanbul-lib-instrument/CHANGELOG.md
generated
vendored
@@ -3,6 +3,113 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [4.0.3](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-instrument@4.0.2...istanbul-lib-instrument@4.0.3) (2020-05-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Prevent readInitialCoverage from reading babel config ([#562](https://github.com/istanbuljs/istanbuljs/issues/562)) ([49b4745](https://github.com/istanbuljs/istanbuljs/commit/49b474525c15e703642916011bd86f663aca0c3d))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [4.0.2](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-instrument@4.0.1...istanbul-lib-instrument@4.0.2) (2020-05-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Add ts-ignore to reassignment of generated function ([#557](https://github.com/istanbuljs/istanbuljs/issues/557)) ([817efb0](https://github.com/istanbuljs/istanbuljs/commit/817efb04fc161efae426b2231a0221606b09f559))
|
||||
* Use @babel/core for all babel imports. ([#555](https://github.com/istanbuljs/istanbuljs/issues/555)) ([a99a13e](https://github.com/istanbuljs/istanbuljs/commit/a99a13ee6931fc124a2a723c3f511cdbcb0aa81d))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [4.0.1](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-instrument@4.0.0...istanbul-lib-instrument@4.0.1) (2020-02-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Always call coverage initialization function ([#524](https://github.com/istanbuljs/istanbuljs/issues/524)) ([c6536c1](https://github.com/istanbuljs/istanbuljs/commit/c6536c14bf0663ca7e0493dd40ea132b05352594))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [4.0.0](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-instrument@4.0.0-alpha.3...istanbul-lib-instrument@4.0.0) (2019-12-20)
|
||||
|
||||
**Note:** Version bump only for package istanbul-lib-instrument
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [4.0.0-alpha.3](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-instrument@4.0.0-alpha.2...istanbul-lib-instrument@4.0.0-alpha.3) (2019-12-07)
|
||||
|
||||
**Note:** Version bump only for package istanbul-lib-instrument
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [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)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Eliminate babel hoisting of the coverage variable ([#481](https://github.com/istanbuljs/istanbuljs/issues/481)) ([8dfbcba](https://github.com/istanbuljs/istanbuljs/commit/8dfbcba)), closes [#92](https://github.com/istanbuljs/istanbuljs/issues/92)
|
||||
* Honor ignore hints in chained if statements ([#469](https://github.com/istanbuljs/istanbuljs/issues/469)) ([a629770](https://github.com/istanbuljs/istanbuljs/commit/a629770)), closes [#468](https://github.com/istanbuljs/istanbuljs/issues/468)
|
||||
* Populate lastFileCoverage for already instrumented files ([#470](https://github.com/istanbuljs/istanbuljs/issues/470)) ([ea6d779](https://github.com/istanbuljs/istanbuljs/commit/ea6d779)), closes [istanbuljs/nyc#594](https://github.com/istanbuljs/nyc/issues/594)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Use @istanbuljs/schema to pull defaults ([#485](https://github.com/istanbuljs/istanbuljs/issues/485)) ([87e27f3](https://github.com/istanbuljs/istanbuljs/commit/87e27f3)), closes [#460](https://github.com/istanbuljs/istanbuljs/issues/460)
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* The defaults for `autoWrap`, `preserveComments`,
|
||||
`esModules` and `produceSourceMap` are now true. This applies only to
|
||||
the stand-alone instrumenter, the visitor does not use these options.
|
||||
* The `flow` and `jsx` parser plugins are no longer
|
||||
enabled by default. This applies only to the stand-alone instrumenter,
|
||||
the visitor does not use this option.
|
||||
* The `plugins` option of the stand-alone instrumenter
|
||||
has been renamed to `parserPlugins` to match nyc.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [4.0.0-alpha.0](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-instrument@3.3.0...istanbul-lib-instrument@4.0.0-alpha.0) (2019-06-19)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Update dependencies, require Node.js 8 ([#401](https://github.com/istanbuljs/istanbuljs/issues/401)) ([bf3a539](https://github.com/istanbuljs/istanbuljs/commit/bf3a539))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* Node.js 8 is now required
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [3.3.0](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-instrument@3.2.0...istanbul-lib-instrument@3.3.0) (2019-04-24)
|
||||
|
||||
|
||||
|
||||
22
node_modules/istanbul-lib-instrument/dist/index.js
generated
vendored
22
node_modules/istanbul-lib-instrument/dist/index.js
generated
vendored
@@ -4,26 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createInstrumenter = createInstrumenter;
|
||||
Object.defineProperty(exports, "defaultOpts", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _instrumenter.defaultOpts;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "programVisitor", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
get: function () {
|
||||
return _visitor.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "readInitialCoverage", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
get: function () {
|
||||
return _readCoverage.default;
|
||||
}
|
||||
});
|
||||
exports.defaultOpts = void 0;
|
||||
|
||||
var _instrumenter = _interopRequireWildcard(require("./instrumenter"));
|
||||
var _schema = require("@istanbuljs/schema");
|
||||
|
||||
var _instrumenter = _interopRequireDefault(require("./instrumenter"));
|
||||
|
||||
var _visitor = _interopRequireDefault(require("./visitor"));
|
||||
|
||||
@@ -31,8 +28,6 @@ var _readCoverage = _interopRequireDefault(require("./read-coverage"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||
|
||||
/**
|
||||
* createInstrumenter creates a new instrumenter with the
|
||||
* supplied options.
|
||||
@@ -41,4 +36,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
||||
*/
|
||||
function createInstrumenter(opts) {
|
||||
return new _instrumenter.default(opts);
|
||||
}
|
||||
}
|
||||
|
||||
const defaultOpts = _schema.defaults.instrumenter;
|
||||
exports.defaultOpts = defaultOpts;
|
||||
138
node_modules/istanbul-lib-instrument/dist/instrumenter.js
generated
vendored
138
node_modules/istanbul-lib-instrument/dist/instrumenter.js
generated
vendored
@@ -3,46 +3,23 @@
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.defaultOpts = defaultOpts;
|
||||
exports.default = void 0;
|
||||
|
||||
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");
|
||||
|
||||
var _visitor = _interopRequireDefault(require("./visitor"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
var _readCoverage = _interopRequireDefault(require("./read-coverage"));
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
Copyright 2012-2015, Yahoo Inc.
|
||||
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
||||
*/
|
||||
function defaultOpts() {
|
||||
return {
|
||||
coverageVariable: '__coverage__',
|
||||
coverageGlobalScope: 'this',
|
||||
coverageGlobalScopeFunc: true,
|
||||
preserveComments: false,
|
||||
compact: true,
|
||||
esModules: false,
|
||||
autoWrap: false,
|
||||
produceSourceMap: false,
|
||||
ignoreClassMethods: [],
|
||||
sourceMapUrlCallback: null,
|
||||
debug: false,
|
||||
|
||||
/* babel parser plugins are to be enabled when the feature is stage 3 and
|
||||
* implemented in a released version of node.js */
|
||||
plugins: ['asyncGenerators', 'bigInt', 'classProperties', 'classPrivateProperties', 'dynamicImport', 'importMeta', 'objectRestSpread', 'optionalCatchBinding', 'flow', 'jsx']
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Instrumenter is the public API for the instrument library.
|
||||
* It is typically used for ES5 code. For ES6 code that you
|
||||
@@ -59,36 +36,16 @@ function defaultOpts() {
|
||||
* @param {Function} [opts.sourceMapUrlCallback=null] a callback function that is called when a source map URL
|
||||
* is found in the original code. This function is called with the source file name and the source map URL.
|
||||
* @param {boolean} [opts.debug=false] - turn debugging on
|
||||
* @param {array} [opts.plugins=['asyncGenerators','dynamicImport','objectRestSpread','optionalCatchBinding','flow','jsx']] - set plugins
|
||||
* @param {array} [opts.parserPlugins] - set babel parser plugins, see @istanbuljs/schema for defaults.
|
||||
*/
|
||||
|
||||
|
||||
class Instrumenter {
|
||||
constructor(opts = defaultOpts()) {
|
||||
this.opts = this.normalizeOpts(opts);
|
||||
constructor(opts = {}) {
|
||||
this.opts = { ..._schema.defaults.instrumenter,
|
||||
...opts
|
||||
};
|
||||
this.fileCoverage = null;
|
||||
this.sourceMap = null;
|
||||
}
|
||||
/**
|
||||
* normalize options passed in and assign defaults.
|
||||
* @param opts
|
||||
* @private
|
||||
*/
|
||||
|
||||
|
||||
normalizeOpts(opts) {
|
||||
const normalize = (name, defaultValue) => {
|
||||
if (!opts.hasOwnProperty(name)) {
|
||||
opts[name] = defaultValue;
|
||||
}
|
||||
};
|
||||
|
||||
const defOpts = defaultOpts();
|
||||
Object.keys(defOpts).forEach(k => {
|
||||
normalize(k, defOpts[k]);
|
||||
});
|
||||
return opts;
|
||||
}
|
||||
/**
|
||||
* instrument the supplied code and track coverage against the supplied
|
||||
* filename. It throws if invalid code is passed to it. ES5 and ES6 syntax
|
||||
@@ -110,38 +67,59 @@ class Instrumenter {
|
||||
}
|
||||
|
||||
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.plugins
|
||||
});
|
||||
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,
|
||||
|
||||
exit(path) {
|
||||
output = ee.exit(path);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
(0, _traverse.default)(ast, visitor);
|
||||
const generateOptions = {
|
||||
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,
|
||||
sourceMaps: opts.produceSourceMap,
|
||||
sourceFileName: filename
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
}]]
|
||||
};
|
||||
const codeMap = (0, _generator.default)(ast, generateOptions, code);
|
||||
const codeMap = (0, _core.transformSync)(code, babelOpts);
|
||||
|
||||
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;
|
||||
const cb = this.opts.sourceMapUrlCallback;
|
||||
|
||||
53
node_modules/istanbul-lib-instrument/dist/read-coverage.js
generated
vendored
53
node_modules/istanbul-lib-instrument/dist/read-coverage.js
generated
vendored
@@ -5,39 +5,46 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.default = readInitialCoverage;
|
||||
|
||||
var _parser = require("@babel/parser");
|
||||
var _core = require("@babel/core");
|
||||
|
||||
var _traverse = _interopRequireDefault(require("@babel/traverse"));
|
||||
|
||||
var t = _interopRequireWildcard(require("@babel/types"));
|
||||
var _schema = require("@istanbuljs/schema");
|
||||
|
||||
var _constants = require("./constants");
|
||||
|
||||
var _instrumenter = require("./instrumenter");
|
||||
function getAst(code) {
|
||||
if (typeof code === 'object' && typeof code.type === 'string') {
|
||||
// Assume code is already a babel ast.
|
||||
return code;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function readInitialCoverage(code) {
|
||||
if (typeof code !== 'string') {
|
||||
throw new Error('Code must be a string');
|
||||
} // Parse as leniently as possible
|
||||
|
||||
|
||||
const ast = (0, _parser.parse)(code, {
|
||||
allowImportExportEverywhere: true,
|
||||
allowReturnOutsideFunction: true,
|
||||
allowSuperOutsideMethod: true,
|
||||
sourceType: 'script',
|
||||
plugins: (0, _instrumenter.defaultOpts)().plugins
|
||||
return (0, _core.parseSync)(code, {
|
||||
babelrc: false,
|
||||
configFile: false,
|
||||
parserOpts: {
|
||||
allowImportExportEverywhere: true,
|
||||
allowReturnOutsideFunction: true,
|
||||
allowSuperOutsideMethod: true,
|
||||
sourceType: 'script',
|
||||
plugins: _schema.defaults.instrumenter.parserPlugins
|
||||
}
|
||||
});
|
||||
let covScope;
|
||||
(0, _traverse.default)(ast, {
|
||||
ObjectProperty(path) {
|
||||
const node = path.node;
|
||||
}
|
||||
|
||||
if (!node.computed && t.isIdentifier(node.key) && node.key.name === _constants.MAGIC_KEY) {
|
||||
function readInitialCoverage(code) {
|
||||
const ast = getAst(code);
|
||||
let covScope;
|
||||
(0, _core.traverse)(ast, {
|
||||
ObjectProperty(path) {
|
||||
const {
|
||||
node
|
||||
} = path;
|
||||
|
||||
if (!node.computed && path.get('key').isIdentifier() && node.key.name === _constants.MAGIC_KEY) {
|
||||
const magicValue = path.get('value').evaluate();
|
||||
|
||||
if (!magicValue.confident || magicValue.value !== _constants.MAGIC_VALUE) {
|
||||
@@ -57,8 +64,7 @@ function readInitialCoverage(code) {
|
||||
|
||||
const result = {};
|
||||
|
||||
for (var _i = 0, _arr = ['path', 'hash', 'gcv', 'coverageData']; _i < _arr.length; _i++) {
|
||||
const key = _arr[_i];
|
||||
for (const key of ['path', 'hash', 'gcv', 'coverageData']) {
|
||||
const binding = covScope.getOwnBinding(key);
|
||||
|
||||
if (!binding) {
|
||||
@@ -76,5 +82,6 @@ function readInitialCoverage(code) {
|
||||
}
|
||||
|
||||
delete result.coverageData[_constants.MAGIC_KEY];
|
||||
delete result.coverageData.hash;
|
||||
return result;
|
||||
}
|
||||
66
node_modules/istanbul-lib-instrument/dist/visitor.js
generated
vendored
66
node_modules/istanbul-lib-instrument/dist/visitor.js
generated
vendored
@@ -7,16 +7,14 @@ exports.default = void 0;
|
||||
|
||||
var _crypto = require("crypto");
|
||||
|
||||
var _template = _interopRequireDefault(require("@babel/template"));
|
||||
var _core = require("@babel/core");
|
||||
|
||||
var _schema = require("@istanbuljs/schema");
|
||||
|
||||
var _sourceCoverage = require("./source-coverage");
|
||||
|
||||
var _constants = require("./constants");
|
||||
|
||||
var _instrumenter = require("./instrumenter");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// pattern for istanbul to ignore a section
|
||||
const COMMENT_RE = /^\s*istanbul\s+ignore\s+(if|else|next)(?=\W|$)/; // pattern for istanbul to ignore the whole file
|
||||
|
||||
@@ -171,7 +169,7 @@ class VisitState {
|
||||
const T = this.types;
|
||||
const wrap = index !== null ? // If `index` present, turn `x` into `x[index]`.
|
||||
x => T.memberExpression(x, T.numericLiteral(index), true) : x => x;
|
||||
return T.updateExpression('++', wrap(T.memberExpression(T.memberExpression(T.identifier(this.varName), T.identifier(type)), T.numericLiteral(id), true)));
|
||||
return T.updateExpression('++', wrap(T.memberExpression(T.memberExpression(T.callExpression(T.identifier(this.varName), []), T.identifier(type)), T.numericLiteral(id), true)));
|
||||
}
|
||||
|
||||
insertCounter(path, increment) {
|
||||
@@ -308,7 +306,7 @@ class VisitState {
|
||||
|
||||
function entries(...enter) {
|
||||
// the enter function
|
||||
const wrappedEntry = function wrappedEntry(path, node) {
|
||||
const wrappedEntry = function (path, node) {
|
||||
this.onEnter(path);
|
||||
|
||||
if (this.shouldIgnore(path)) {
|
||||
@@ -320,7 +318,7 @@ function entries(...enter) {
|
||||
});
|
||||
};
|
||||
|
||||
const exit = function exit(path, node) {
|
||||
const exit = function (path, node) {
|
||||
this.onExit(path, node);
|
||||
};
|
||||
|
||||
@@ -364,6 +362,8 @@ function makeBlock(path) {
|
||||
if (!path.isBlockStatement()) {
|
||||
path.replaceWith(T.blockStatement([path.node]));
|
||||
path.node.loc = path.node.body[0].loc;
|
||||
path.node.body[0].leadingComments = path.node.leadingComments;
|
||||
path.node.leadingComments = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -528,31 +528,42 @@ const codeVisitor = {
|
||||
ConditionalExpression: entries(coverTernary),
|
||||
LogicalExpression: entries(coverLogicalExpression)
|
||||
};
|
||||
const globalTemplateAlteredFunction = (0, _template.default)(`
|
||||
const globalTemplateAlteredFunction = (0, _core.template)(`
|
||||
var Function = (function(){}).constructor;
|
||||
var global = (new Function(GLOBAL_COVERAGE_SCOPE))();
|
||||
`);
|
||||
const globalTemplateFunction = (0, _template.default)(`
|
||||
const globalTemplateFunction = (0, _core.template)(`
|
||||
var global = (new Function(GLOBAL_COVERAGE_SCOPE))();
|
||||
`);
|
||||
const globalTemplateVariable = (0, _template.default)(`
|
||||
const globalTemplateVariable = (0, _core.template)(`
|
||||
var global = GLOBAL_COVERAGE_SCOPE;
|
||||
`); // the template to insert at the top of the program.
|
||||
|
||||
const coverageTemplate = (0, _template.default)(`
|
||||
var COVERAGE_VAR = (function () {
|
||||
const coverageTemplate = (0, _core.template)(`
|
||||
function COVERAGE_FUNCTION () {
|
||||
var path = PATH;
|
||||
var hash = HASH;
|
||||
GLOBAL_COVERAGE_TEMPLATE
|
||||
var gcv = GLOBAL_COVERAGE_VAR;
|
||||
var coverageData = INITIAL;
|
||||
var coverage = global[gcv] || (global[gcv] = {});
|
||||
if (coverage[path] && coverage[path].hash === hash) {
|
||||
return coverage[path];
|
||||
if (!coverage[path] || coverage[path].hash !== hash) {
|
||||
coverage[path] = coverageData;
|
||||
}
|
||||
return coverage[path] = coverageData;
|
||||
})();
|
||||
`); // the rewire plugin (and potentially other babel middleware)
|
||||
|
||||
var actualCoverage = coverage[path];
|
||||
{
|
||||
// @ts-ignore
|
||||
COVERAGE_FUNCTION = function () {
|
||||
return actualCoverage;
|
||||
}
|
||||
}
|
||||
|
||||
return actualCoverage;
|
||||
}
|
||||
`, {
|
||||
preserveComments: true
|
||||
}); // 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
|
||||
// we should only instrument code for coverage the first time
|
||||
@@ -565,10 +576,6 @@ function alreadyInstrumented(path, visitState) {
|
||||
function shouldIgnoreFile(programNode) {
|
||||
return programNode.parent && programNode.parent.comments.some(c => COMMENT_FILE_RE.test(c.value));
|
||||
}
|
||||
|
||||
const defaultProgramVisitorOpts = {
|
||||
inputSourceMap: undefined
|
||||
};
|
||||
/**
|
||||
* programVisitor is a `babel` adaptor for instrumentation.
|
||||
* It returns an object with two methods `enter` and `exit`.
|
||||
@@ -593,10 +600,12 @@ const defaultProgramVisitorOpts = {
|
||||
* original code.
|
||||
*/
|
||||
|
||||
function programVisitor(types, sourceFilePath = 'unknown.js', opts = defaultProgramVisitorOpts) {
|
||||
const T = types; // This sets some unused options but ensures all required options are initialized
|
||||
|
||||
opts = Object.assign({}, (0, _instrumenter.defaultOpts)(), defaultProgramVisitorOpts, opts);
|
||||
function programVisitor(types, sourceFilePath = 'unknown.js', opts = {}) {
|
||||
const T = types;
|
||||
opts = { ..._schema.defaults.instrumentVisitor,
|
||||
...opts
|
||||
};
|
||||
const visitState = new VisitState(types, sourceFilePath, opts.inputSourceMap, opts.ignoreClassMethods);
|
||||
return {
|
||||
enter(path) {
|
||||
@@ -653,12 +662,13 @@ function programVisitor(types, sourceFilePath = 'unknown.js', opts = defaultProg
|
||||
const cv = coverageTemplate({
|
||||
GLOBAL_COVERAGE_VAR: T.stringLiteral(opts.coverageVariable),
|
||||
GLOBAL_COVERAGE_TEMPLATE: gvTemplate,
|
||||
COVERAGE_VAR: T.identifier(visitState.varName),
|
||||
COVERAGE_FUNCTION: T.identifier(visitState.varName),
|
||||
PATH: T.stringLiteral(sourceFilePath),
|
||||
INITIAL: coverageNode,
|
||||
HASH: T.stringLiteral(hash)
|
||||
});
|
||||
cv._blockHoist = 5;
|
||||
}); // explicitly call this.varName to ensure coverage is always initialized
|
||||
|
||||
path.node.body.unshift(T.expressionStatement(T.callExpression(T.identifier(visitState.varName), [])));
|
||||
path.node.body.unshift(cv);
|
||||
return {
|
||||
fileCoverage: coverageData,
|
||||
|
||||
65
node_modules/istanbul-lib-instrument/package.json
generated
vendored
65
node_modules/istanbul-lib-instrument/package.json
generated
vendored
@@ -1,34 +1,28 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"istanbul-lib-instrument@3.3.0",
|
||||
"/Users/drew.heavner/Documents/Github/upload-google-play"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "istanbul-lib-instrument@3.3.0",
|
||||
"_id": "istanbul-lib-instrument@3.3.0",
|
||||
"_from": "istanbul-lib-instrument@^4.0.3",
|
||||
"_id": "istanbul-lib-instrument@4.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-5nnIN4vo5xQZHdXno/YDXJ0G+I3dAm4XgzfSVTPLQpj/zAV2dV6Juy0yaf10/zrJOJeHoN3fraFe+XRq2bFVZA==",
|
||||
"_integrity": "sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==",
|
||||
"_location": "/istanbul-lib-instrument",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "istanbul-lib-instrument@3.3.0",
|
||||
"raw": "istanbul-lib-instrument@^4.0.3",
|
||||
"name": "istanbul-lib-instrument",
|
||||
"escapedName": "istanbul-lib-instrument",
|
||||
"rawSpec": "3.3.0",
|
||||
"rawSpec": "^4.0.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "3.3.0"
|
||||
"fetchSpec": "^4.0.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@jest/reporters",
|
||||
"/babel-plugin-istanbul"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-3.3.0.tgz",
|
||||
"_spec": "3.3.0",
|
||||
"_where": "/Users/drew.heavner/Documents/Github/upload-google-play",
|
||||
"_resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz",
|
||||
"_shasum": "873c6fff897450118222774696a3f28902d77c1d",
|
||||
"_spec": "istanbul-lib-instrument@^4.0.3",
|
||||
"_where": "/home/codespace/workspace/upload-google-play/node_modules/@jest/reporters",
|
||||
"author": {
|
||||
"name": "Krishnan Anantheswaran",
|
||||
"email": "kananthmail-github@yahoo.com"
|
||||
@@ -36,23 +30,35 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/istanbuljs/istanbuljs/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@babel/generator": "^7.4.0",
|
||||
"@babel/parser": "^7.4.3",
|
||||
"@babel/template": "^7.4.0",
|
||||
"@babel/traverse": "^7.4.3",
|
||||
"@babel/types": "^7.4.0",
|
||||
"istanbul-lib-coverage": "^2.0.5",
|
||||
"semver": "^6.0.0"
|
||||
"@babel/core": "^7.7.5",
|
||||
"@istanbuljs/schema": "^0.1.2",
|
||||
"istanbul-lib-coverage": "^3.0.0",
|
||||
"semver": "^6.3.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Core istanbul API for JS code coverage",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.7.5",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.7.5",
|
||||
"@babel/register": "^7.7.4",
|
||||
"chai": "^4.2.0",
|
||||
"clone": "^2.1.2",
|
||||
"debug": "^4.1.1",
|
||||
"documentation": "^12.1.4",
|
||||
"js-yaml": "^3.13.1",
|
||||
"mocha": "^6.2.2",
|
||||
"nopt": "^4.0.1",
|
||||
"nyc": "^15.0.0-beta.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
"node": ">=8"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"gitHead": "90e60cc47833bb780680f916488ca24f0be36ca2",
|
||||
"gitHead": "2c6f0e24680d050503d404de0ebff53467fefbff",
|
||||
"homepage": "https://istanbul.js.org/",
|
||||
"keywords": [
|
||||
"coverage",
|
||||
@@ -65,12 +71,13 @@
|
||||
"name": "istanbul-lib-instrument",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/istanbuljs/istanbuljs.git"
|
||||
"url": "git+ssh://git@github.com/istanbuljs/istanbuljs.git",
|
||||
"directory": "packages/istanbul-lib-instrument"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "npm run release",
|
||||
"release": "babel src --out-dir dist && documentation build -f md -o api.md src",
|
||||
"test": "mocha --require=@babel/register"
|
||||
"test": "nyc --nycrc-path=../../monorepo-per-package-nycrc.json --require=@babel/register --include=src mocha"
|
||||
},
|
||||
"version": "3.3.0"
|
||||
"version": "4.0.3"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user