diff options
Diffstat (limited to 'node_modules/babel-plugin-istanbul')
-rw-r--r-- | node_modules/babel-plugin-istanbul/CHANGELOG.md | 320 | ||||
-rw-r--r-- | node_modules/babel-plugin-istanbul/LICENSE | 27 | ||||
-rw-r--r-- | node_modules/babel-plugin-istanbul/README.md | 135 | ||||
-rw-r--r-- | node_modules/babel-plugin-istanbul/lib/index.js | 170 | ||||
-rw-r--r-- | node_modules/babel-plugin-istanbul/lib/load-nyc-config-sync.js | 20 | ||||
-rw-r--r-- | node_modules/babel-plugin-istanbul/package.json | 71 |
6 files changed, 743 insertions, 0 deletions
diff --git a/node_modules/babel-plugin-istanbul/CHANGELOG.md b/node_modules/babel-plugin-istanbul/CHANGELOG.md new file mode 100644 index 0000000..aa57d4f --- /dev/null +++ b/node_modules/babel-plugin-istanbul/CHANGELOG.md @@ -0,0 +1,320 @@ +# Changelog + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +### [6.1.1](https://www.github.com/istanbuljs/babel-plugin-istanbul/compare/v6.1.0...v6.1.1) (2021-10-16) + + +### Bug Fixes + +* **build:** first automated publication ([9a1b893](https://www.github.com/istanbuljs/babel-plugin-istanbul/commit/9a1b89342565d1127a011e31262520b057120531)) + +## [6.1.0](https://www.github.com/istanbuljs/babel-plugin-istanbul/compare/v6.0.0...v6.1.0) (2021-10-16) + + +### Features + +* **instrumenter:** instrumenter with fixes for branchMap instrumentation ([#265](https://www.github.com/istanbuljs/babel-plugin-istanbul/issues/265)) ([1e9ec62](https://www.github.com/istanbuljs/babel-plugin-istanbul/commit/1e9ec62b50c9d2224e7bb0ccb071fd10b80e018f)) + +## [6.0.0](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v5.2.0...v6.0.0) (2019-12-20) + + +### ⚠ BREAKING CHANGES + +* Drop node.js 6 (#226) + +### Features + +* Add support for instrumenter options ([#227](https://github.com/istanbuljs/babel-plugin-istanbul/issues/227)) ([fe08f5b](https://github.com/istanbuljs/babel-plugin-istanbul/commit/fe08f5b8282136c7ed9375fa32148586bd6a7e28)), closes [#208](https://github.com/istanbuljs/babel-plugin-istanbul/issues/208) [#212](https://github.com/istanbuljs/babel-plugin-istanbul/issues/212) +* Drop node.js 6 ([#226](https://github.com/istanbuljs/babel-plugin-istanbul/issues/226)) ([93db21a](https://github.com/istanbuljs/babel-plugin-istanbul/commit/93db21aa2bbdbb06fb784f52c24a7847fad6be92)), closes [#209](https://github.com/istanbuljs/babel-plugin-istanbul/issues/209) + +## [5.2.0](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v5.1.4...v5.2.0) (2019-07-18) + + +### Bug Fixes + +* Print explicit error if use with babel 6 is attempted ([#207](https://github.com/istanbuljs/babel-plugin-istanbul/issues/207)) ([a12cf16](https://github.com/istanbuljs/babel-plugin-istanbul/commit/a12cf16)) + + +### Features + +* Support turning off node_modules default exclude via flag ([#172](https://github.com/istanbuljs/babel-plugin-istanbul/issues/172)) ([a314f06](https://github.com/istanbuljs/babel-plugin-istanbul/commit/a314f06)) + + + +## [5.1.4](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v5.1.3...v5.1.4) (2019-04-25) + + + +## [5.1.3](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v5.1.2...v5.1.3) (2019-04-23) + + +### Bug Fixes + +* Revert [#192](https://github.com/istanbuljs/babel-plugin-istanbul/issues/192) ([201a933](https://github.com/istanbuljs/babel-plugin-istanbul/commit/201a933)) due to regression detailed at [#201](https://github.com/istanbuljs/babel-plugin-istanbul/issues/201) + + + +## [5.1.2](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v5.1.1...v5.1.2) (2019-04-10) + + +### Bug Fixes + +* Ensure correct scope references after traversal ([#192](https://github.com/istanbuljs/babel-plugin-istanbul/issues/192)) ([201a933](https://github.com/istanbuljs/babel-plugin-istanbul/commit/201a933)) + + + +<a name="5.1.1"></a> +## [5.1.1](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v5.1.0...v5.1.1) (2019-01-11) + + +### Bug Fixes + +* respect changes of cwd in options ([#171](https://github.com/istanbuljs/babel-plugin-istanbul/issues/171)) ([adec723](https://github.com/istanbuljs/babel-plugin-istanbul/commit/adec723)) + + + +<a name="5.1.0"></a> +# [5.1.0](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v5.0.1...v5.1.0) (2018-09-07) + + +### Features + +* Bump dependencies. ([b509649](https://github.com/istanbuljs/babel-plugin-istanbul/commit/b509649)) + + + +<a name="5.0.1"></a> +## [5.0.1](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v5.0.0...v5.0.1) (2018-07-24) + + + +<a name="5.0.0"></a> +# [5.0.0](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v4.1.6...v5.0.0) (2018-06-27) + + +### Features + +* upgrade to babel 7 and newest istanbul libraries ([#158](https://github.com/istanbuljs/babel-plugin-istanbul/issues/158)) ([a9e1564](https://github.com/istanbuljs/babel-plugin-istanbul/commit/a9e1564)) + + +### BREAKING CHANGES + +* Drop node 4 support, upgrade to babel 7, stop shipping @babel/plugin-syntax-object-rest-spread + + + +<a name="4.1.6"></a> +## <small>4.1.6 (2018-03-09)</small> + +* chore: explicit update of istanbul dependencies (#149) ([77b6eb7](https://github.com/istanbuljs/babel-plugin-istanbul/commit/77b6eb7)), closes [#149](https://github.com/istanbuljs/babel-plugin-istanbul/issues/149) +* chore(package): update coveralls to version 3.0.0 (#133) ([7045a03](https://github.com/istanbuljs/babel-plugin-istanbul/commit/7045a03)), closes [#133](https://github.com/istanbuljs/babel-plugin-istanbul/issues/133) +* chore(package): update mocha to version 4.0.0 (#134) ([38176ba](https://github.com/istanbuljs/babel-plugin-istanbul/commit/38176ba)), closes [#134](https://github.com/istanbuljs/babel-plugin-istanbul/issues/134) +* fix: babel-preset-es2015 => babel-preset-env (#138) ([18fe954](https://github.com/istanbuljs/babel-plugin-istanbul/commit/18fe954)), closes [#138](https://github.com/istanbuljs/babel-plugin-istanbul/issues/138) +* fix: include object-spread-syntax plugin (#141) ([428a952](https://github.com/istanbuljs/babel-plugin-istanbul/commit/428a952)), closes [#141](https://github.com/istanbuljs/babel-plugin-istanbul/issues/141) + + + +<a name="4.1.5"></a> +## [4.1.5](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v4.1.2...v4.1.5) (2017-08-23) + + + +<a name="4.1.4"></a> +## [4.1.4](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v4.1.3...v4.1.4) (2017-05-27) + + + +<a name="4.1.3"></a> +## [4.1.3](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v4.1.1...v4.1.3) (2017-04-29) + + + +<a name="4.1.2"></a> +## [4.1.2](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v4.1.1...v4.1.2) (2017-03-27) + + + +<a name="4.1.1"></a> +## [4.1.1](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v4.1.0...v4.1.1) (2017-03-22) + + +### Bug Fixes + +* explicit upgrade to patched version of istanbul-lib-instrument ([db8ecbe](https://github.com/istanbuljs/babel-plugin-istanbul/commit/db8ecbe)) + + + +<a name="4.1.0"></a> +# [4.1.0](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v4.0.0...v4.1.0) (2017-03-21) + + +### Features + +* add includeUntested option to expose coverage of all instrumented files ([#80](https://github.com/istanbuljs/babel-plugin-istanbul/issues/80)) ([b078bbd](https://github.com/istanbuljs/babel-plugin-istanbul/commit/b078bbd)) + + + +<a name="4.0.0"></a> +# [4.0.0](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v3.1.2...v4.0.0) (2017-02-07) + + +### Bug Fixes + +* load configuration from process.env.NYC_CONFIG if present ([#93](https://github.com/istanbuljs/babel-plugin-istanbul/issues/93)) ([e902924](https://github.com/istanbuljs/babel-plugin-istanbul/commit/e902924)) + + +### Features + +* drop Node 0.10 and 0.12 support, upgrade dependencies to reflect this ([#88](https://github.com/istanbuljs/babel-plugin-istanbul/issues/88)) ([594c03a](https://github.com/istanbuljs/babel-plugin-istanbul/commit/594c03a)) +* we can now use the language feature Object.assign ([#92](https://github.com/istanbuljs/babel-plugin-istanbul/issues/92)) ([f77db2a](https://github.com/istanbuljs/babel-plugin-istanbul/commit/f77db2a)) + + +### BREAKING CHANGES + +* I've updated dependencies and dropped Node 0.10 and Node 0.12 support. + + + +<a name="3.1.2"></a> +## [3.1.2](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v3.1.1...v3.1.2) (2017-01-04) + + +### Bug Fixes + +* address regression related to export const foo = () => {} ([#79](https://github.com/istanbuljs/babel-plugin-istanbul/issues/79)) ([f870a8f](https://github.com/istanbuljs/babel-plugin-istanbul/commit/f870a8f)) + + + +<a name="3.1.1"></a> +## [3.1.1](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v3.1.0...v3.1.1) (2017-01-02) + + + +<a name="3.1.0"></a> +# [3.1.0](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v3.0.0...v3.1.0) (2016-12-27) + + +### Bug Fixes + +* upgrade a bunch of core dependencies ([#77](https://github.com/istanbuljs/babel-plugin-istanbul/issues/77)) ([e764330](https://github.com/istanbuljs/babel-plugin-istanbul/commit/e764330)) + + +### Features + +* accept source map input for the visitor ([#75](https://github.com/istanbuljs/babel-plugin-istanbul/issues/75)) ([437e90b](https://github.com/istanbuljs/babel-plugin-istanbul/commit/437e90b)) + + + +<a name="3.0.0"></a> +# [3.0.0](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v2.0.3...v3.0.0) (2016-11-14) + + +### Chores + +* **package:** update test-exclude to version 3.0.0 ([#68](https://github.com/istanbuljs/babel-plugin-istanbul/issues/68)) ([0396385](https://github.com/istanbuljs/babel-plugin-istanbul/commit/0396385)) + + +### BREAKING CHANGES + +* package: test-exclude now adds `**/node_modules/**` as exclude rule by default. + + + +<a name="2.0.3"></a> +## [2.0.3](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v2.0.2...v2.0.3) (2016-10-17) + + +### Bug Fixes + +* force istanbul-lib-instrument with variable hoisting fix ([#64](https://github.com/istanbuljs/babel-plugin-istanbul/issues/64)) ([209a0cf](https://github.com/istanbuljs/babel-plugin-istanbul/commit/209a0cf)) +* switch deprecated lodash.assign for object-assign ([#58](https://github.com/istanbuljs/babel-plugin-istanbul/issues/58)) ([6e051fc](https://github.com/istanbuljs/babel-plugin-istanbul/commit/6e051fc)) + + + +<a name="2.0.2"></a> +## [2.0.2](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v2.0.1...v2.0.2) (2016-09-08) + + +### Bug Fixes + +* take realpath of cwd, whether or not set in env ([#37](https://github.com/istanbuljs/babel-plugin-istanbul/issues/37)) ([6274d83](https://github.com/istanbuljs/babel-plugin-istanbul/commit/6274d83)) + + + +<a name="2.0.1"></a> +## [2.0.1](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v2.0.0...v2.0.1) (2016-09-02) + + +### Bug Fixes + +* update istanbul-lib-instrument ([573e0d4](https://github.com/istanbuljs/babel-plugin-istanbul/commit/573e0d4)) + + + +<a name="2.0.0"></a> +# [2.0.0](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v1.1.0...v2.0.0) (2016-08-14) + + +### Chores + +* upgrade to version of test-exclude with new exclude rules ([#35](https://github.com/istanbuljs/babel-plugin-istanbul/issues/35)) ([220ce2b](https://github.com/istanbuljs/babel-plugin-istanbul/commit/220ce2b)) + + +### BREAKING CHANGES + +* see https://github.com/istanbuljs/test-exclude/blob/master/CHANGELOG.md#breaking-changes + + + +<a name="1.1.0"></a> +# [1.1.0](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v1.0.3...v1.1.0) (2016-07-21) + + +### Bug Fixes + +* upgrade to istanbul-lib-instrument with faster babel-generator ([#18](https://github.com/istanbuljs/babel-plugin-istanbul/issues/18)) ([d33263c](https://github.com/istanbuljs/babel-plugin-istanbul/commit/d33263c)) + + +### Features + +* allow exclude/include options to be passed as Babel plugin config ([#16](https://github.com/istanbuljs/babel-plugin-istanbul/issues/16)) ([cf68421](https://github.com/istanbuljs/babel-plugin-istanbul/commit/cf68421)) + + + +<a name="1.0.3"></a> +## [1.0.3](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v1.0.2...v1.0.3) (2016-07-09) + + +### Bug Fixes + +* keep using NYC_CWD if available ([#10](https://github.com/istanbuljs/babel-plugin-istanbul/issues/10)) ([db0352b](https://github.com/istanbuljs/babel-plugin-istanbul/commit/db0352b)) + + + +<a name="1.0.2"></a> +## [1.0.2](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v1.0.1...v1.0.2) (2016-07-03) + + +### Bug Fixes + +* take realpath of process.cwd(), fixes [#7](https://github.com/istanbuljs/babel-plugin-istanbul/issues/7) ([#8](https://github.com/istanbuljs/babel-plugin-istanbul/issues/8)) ([e8d3785](https://github.com/istanbuljs/babel-plugin-istanbul/commit/e8d3785)), closes [#7](https://github.com/istanbuljs/babel-plugin-istanbul/issues/7) [#8](https://github.com/istanbuljs/babel-plugin-istanbul/issues/8) + + + +<a name="1.0.1"></a> +## [1.0.1](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v1.0.0...v1.0.1) (2016-06-30) + + +### Bug Fixes + +* upgrade to version of istanbul-lib-instrument that fixes some out of bounds issues ([#6](https://github.com/istanbuljs/babel-plugin-istanbul/issues/6)) ([a949065](https://github.com/istanbuljs/babel-plugin-istanbul/commit/a949065)), closes [#6](https://github.com/istanbuljs/babel-plugin-istanbul/issues/6) + + +<a name="1.0.0"></a> +# 1.0.0 (2016-06-26) + + +### Features + +* port functionality from __coverage__, get ready for first release ([#2](https://github.com/istanbuljs/babel-plugin-istanbul/issues/2)) ([2a8ee44](https://github.com/istanbuljs/babel-plugin-istanbul/commit/2a8ee44)) diff --git a/node_modules/babel-plugin-istanbul/LICENSE b/node_modules/babel-plugin-istanbul/LICENSE new file mode 100644 index 0000000..22f21ab --- /dev/null +++ b/node_modules/babel-plugin-istanbul/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2016, Istanbul Code Coverage +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of babel-plugin-istanbul nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/babel-plugin-istanbul/README.md b/node_modules/babel-plugin-istanbul/README.md new file mode 100644 index 0000000..a027e9b --- /dev/null +++ b/node_modules/babel-plugin-istanbul/README.md @@ -0,0 +1,135 @@ +# babel-plugin-istanbul + +[![Coverage Status](https://coveralls.io/repos/github/istanbuljs/babel-plugin-istanbul/badge.svg?branch=master)](https://coveralls.io/github/istanbuljs/babel-plugin-istanbul?branch=master) +[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) +[![community slack](http://devtoolscommunity.herokuapp.com/badge.svg)](http://devtoolscommunity.herokuapp.com) + +_Having problems? want to contribute? join our [community slack](http://devtoolscommunity.herokuapp.com)_. + +A Babel plugin that instruments your code with Istanbul coverage. +It can instantly be used with [karma-coverage](https://github.com/karma-runner/karma-coverage) and mocha on Node.js (through [nyc](https://github.com/bcoe/nyc)). + +__Note:__ This plugin does not generate any report or save any data to any file; +it only adds instrumenting code to your JavaScript source code. +To integrate with testing tools, please see the [Integrations](#integrations) section. + +## Usage + +Install it: + +``` +npm install --save-dev babel-plugin-istanbul +``` + +Add it to `.babelrc` in test mode: + +```js +{ + "env": { + "test": { + "plugins": [ "istanbul" ] + } + } +} +``` + +Optionally, use [cross-env](https://www.npmjs.com/package/cross-env) to set +`NODE_ENV=test`: + +```json +{ + "scripts": { + "test": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha test/*.js" + } +} +``` + +## Integrations + +### karma + +It _just works_ with Karma. First, make sure that the code is already transpiled by Babel (either using `karma-babel-preprocessor`, `karma-webpack`, or `karma-browserify`). Then, simply set up [karma-coverage](https://github.com/karma-runner/karma-coverage) according to the docs, but __don’t add the `coverage` preprocessor.__ This plugin has already instrumented your code, and Karma should pick it up automatically. + +It has been tested with [bemusic/bemuse](https://codecov.io/github/bemusic/bemuse) project, which contains ~2400 statements. + +### mocha on node.js (through nyc) + +Configure Mocha to transpile JavaScript code using Babel, then you can run your tests with [`nyc`](https://github.com/bcoe/nyc), which will collect all the coverage report. + +babel-plugin-istanbul respects the `include`/`exclude` configuration options from nyc, +but you also need to __configure NYC not to instrument your code__ by adding these settings in your `package.json`: + +```js + "nyc": { + "sourceMap": false, + "instrument": false + }, +``` + +## Ignoring files + +You don't want to cover your test files as this will skew your coverage results. You can configure this by providing plugin options matching nyc's [`exclude`/`include` rules](https://github.com/bcoe/nyc#excluding-files): + +```json +{ + "env": { + "test": { + "plugins": [ + ["istanbul", { + "exclude": [ + "**/*.spec.js" + ] + }] + ] + } + } +} +``` + +If you don't provide options in your Babel config, the plugin will look for `exclude`/`include` config under an `"nyc"` key in `package.json`. + +You can also use [istanbul's ignore hints](https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes) to specify specific lines of code to skip instrumenting. + +## Source Maps + +By default, this plugin will pick up inline source maps and attach them to the instrumented code such that code coverage can be remapped back to the original source, even for multi-step build processes. This can be memory intensive. Set `useInlineSourceMaps` to prevent this behavior. + +```json +{ + "env": { + "test": { + "plugins": [ + ["istanbul", { + "useInlineSourceMaps": false + }] + ] + } + } +} +``` + +If you're instrumenting code programatically, you can pass a source map explicitly. +```js +import babelPluginIstanbul from 'babel-plugin-istanbul'; + +function instrument(sourceCode, sourceMap, fileName) { + return babel.transform(sourceCode, { + filename, + plugins: [ + [babelPluginIstanbul, { + inputSourceMap: sourceMap + }] + ] + }) +} +``` + +## Credit where credit is due + +The approach used in `babel-plugin-istanbul` was inspired by [Thai Pangsakulyanont](https://github.com/dtinth)'s original library [`babel-plugin-__coverage__`](https://github.com/dtinth/babel-plugin-__coverage__). + +## `babel-plugin-istanbul` for enterprise + +Available as part of the Tidelift Subscription. + +The maintainers of `babel-plugin-istanbul` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-babel-plugin-istanbul?utm_source=npm-babel-plugin-istanbul&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) diff --git a/node_modules/babel-plugin-istanbul/lib/index.js b/node_modules/babel-plugin-istanbul/lib/index.js new file mode 100644 index 0000000..8cf7433 --- /dev/null +++ b/node_modules/babel-plugin-istanbul/lib/index.js @@ -0,0 +1,170 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _path = _interopRequireDefault(require("path")); + +var _fs = require("fs"); + +var _child_process = require("child_process"); + +var _helperPluginUtils = require("@babel/helper-plugin-utils"); + +var _istanbulLibInstrument = require("istanbul-lib-instrument"); + +var _testExclude = _interopRequireDefault(require("test-exclude")); + +var _schema = _interopRequireDefault(require("@istanbuljs/schema")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function getRealpath(n) { + try { + return (0, _fs.realpathSync)(n) || + /* istanbul ignore next */ + n; + } catch (e) { + /* istanbul ignore next */ + return n; + } +} + +const memoize = new Map(); +/* istanbul ignore next */ + +const memosep = _path.default.sep === '/' ? ':' : ';'; + +function loadNycConfig(cwd, opts) { + let memokey = cwd; + const args = [_path.default.resolve(__dirname, 'load-nyc-config-sync.js'), cwd]; + + if ('nycrcPath' in opts) { + args.push(opts.nycrcPath); + memokey += memosep + opts.nycrcPath; + } + /* execFileSync is expensive, avoid it if possible! */ + + + if (memoize.has(memokey)) { + return memoize.get(memokey); + } + + const result = JSON.parse((0, _child_process.execFileSync)(process.execPath, args)); + const error = result['load-nyc-config-sync-error']; + + if (error) { + throw new Error(error); + } + + const config = { ..._schema.default.defaults.babelPluginIstanbul, + cwd, + ...result + }; + memoize.set(memokey, config); + return config; +} + +function findConfig(opts) { + const cwd = getRealpath(opts.cwd || process.env.NYC_CWD || + /* istanbul ignore next */ + process.cwd()); + const keys = Object.keys(opts); + const ignored = Object.keys(opts).filter(s => s === 'nycrcPath' || s === 'cwd'); + + if (keys.length > ignored.length) { + // explicitly configuring options in babel + // takes precedence. + return { ..._schema.default.defaults.babelPluginIstanbul, + cwd, + ...opts + }; + } + + if (ignored.length === 0 && process.env.NYC_CONFIG) { + // defaults were already applied by nyc + return JSON.parse(process.env.NYC_CONFIG); + } + + return loadNycConfig(cwd, opts); +} + +function makeShouldSkip() { + let exclude; + return function shouldSkip(file, nycConfig) { + if (!exclude || exclude.cwd !== nycConfig.cwd) { + exclude = new _testExclude.default({ + cwd: nycConfig.cwd, + include: nycConfig.include, + exclude: nycConfig.exclude, + extension: nycConfig.extension, + // Make sure this is true unless explicitly set to `false`. `undefined` is still `true`. + excludeNodeModules: nycConfig.excludeNodeModules !== false + }); + } + + return !exclude.shouldInstrument(file); + }; +} + +var _default = (0, _helperPluginUtils.declare)(api => { + api.assertVersion(7); + const shouldSkip = makeShouldSkip(); + const t = api.types; + return { + visitor: { + Program: { + enter(path) { + this.__dv__ = null; + this.nycConfig = findConfig(this.opts); + const realPath = getRealpath(this.file.opts.filename); + + if (shouldSkip(realPath, this.nycConfig)) { + return; + } + + let { + inputSourceMap + } = this.opts; + + if (this.opts.useInlineSourceMaps !== false) { + if (!inputSourceMap && this.file.inputMap) { + inputSourceMap = this.file.inputMap.sourcemap; + } + } + + const visitorOptions = {}; + Object.entries(_schema.default.defaults.instrumentVisitor).forEach(([name, defaultValue]) => { + if (name in this.nycConfig) { + visitorOptions[name] = this.nycConfig[name]; + } else { + visitorOptions[name] = _schema.default.defaults.instrumentVisitor[name]; + } + }); + this.__dv__ = (0, _istanbulLibInstrument.programVisitor)(t, realPath, { ...visitorOptions, + inputSourceMap + }); + + this.__dv__.enter(path); + }, + + exit(path) { + if (!this.__dv__) { + return; + } + + const result = this.__dv__.exit(path); + + if (this.opts.onCover) { + this.opts.onCover(getRealpath(this.file.opts.filename), result.fileCoverage); + } + } + + } + } + }; +}); + +exports.default = _default;
\ No newline at end of file diff --git a/node_modules/babel-plugin-istanbul/lib/load-nyc-config-sync.js b/node_modules/babel-plugin-istanbul/lib/load-nyc-config-sync.js new file mode 100644 index 0000000..7906793 --- /dev/null +++ b/node_modules/babel-plugin-istanbul/lib/load-nyc-config-sync.js @@ -0,0 +1,20 @@ +#!/usr/bin/env node +'use strict'; + +const { + loadNycConfig +} = require('@istanbuljs/load-nyc-config'); + +async function main() { + const [cwd, nycrcPath] = process.argv.slice(2); + console.log(JSON.stringify(await loadNycConfig({ + cwd, + nycrcPath + }))); +} + +main().catch(error => { + console.log(JSON.stringify({ + 'load-nyc-config-sync-error': error.message + })); +});
\ No newline at end of file diff --git a/node_modules/babel-plugin-istanbul/package.json b/node_modules/babel-plugin-istanbul/package.json new file mode 100644 index 0000000..2b58513 --- /dev/null +++ b/node_modules/babel-plugin-istanbul/package.json @@ -0,0 +1,71 @@ +{ + "name": "babel-plugin-istanbul", + "version": "6.1.1", + "author": "Thai Pangsakulyanont @dtinth", + "license": "BSD-3-Clause", + "description": "A babel plugin that adds istanbul instrumentation to ES6 code", + "main": "lib/index.js", + "files": [ + "lib" + ], + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^5.0.4", + "test-exclude": "^6.0.0" + }, + "devDependencies": { + "@babel/cli": "^7.7.5", + "@babel/core": "^7.7.5", + "@babel/plugin-transform-modules-commonjs": "^7.7.5", + "@babel/register": "^7.7.4", + "chai": "^4.2.0", + "coveralls": "^3.0.9", + "cross-env": "^6.0.3", + "mocha": "^6.2.2", + "nyc": "^15.0.0", + "pmock": "^0.2.3", + "standard": "^14.3.1" + }, + "scripts": { + "coverage": "nyc report --reporter=text-lcov | coveralls", + "release": "babel src --out-dir lib", + "pretest": "standard && npm run release", + "test": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha --timeout 5000 test/*.js", + "prepublish": "npm test && npm run release" + }, + "standard": { + "ignore": [ + "fixtures/*.js" + ] + }, + "repository": { + "type": "git", + "url": "git+https://github.com/istanbuljs/babel-plugin-istanbul.git" + }, + "keywords": [ + "istanbul", + "babel", + "plugin", + "instrumentation" + ], + "nyc": { + "include": [ + "src/*.js", + "fixtures/should-cover.js" + ], + "require": [ + "@babel/register" + ], + "sourceMap": false, + "instrument": false + }, + "bugs": { + "url": "https://github.com/istanbuljs/babel-plugin-istanbul/issues" + }, + "homepage": "https://github.com/istanbuljs/babel-plugin-istanbul#readme", + "engines": { + "node": ">=8" + } +} |