vite-plugin-istanbul
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -1,2 +0,2 @@ | ||
## [2.2.1](https://github.com/ifaxity/vite-plugin-istanbul/compare/v2.2.0...v2.2.1) (2021-10-06) | ||
## [2.2.2](https://github.com/ifaxity/vite-plugin-istanbul/compare/v2.2.1...v2.2.2) (2021-10-20) | ||
@@ -6,2 +6,2 @@ | ||
* don't run if env is false ([98bf77d](https://github.com/ifaxity/vite-plugin-istanbul/commit/98bf77dbaa29ee8acfee426ae8177d8a2804a482)) | ||
* Added variable for turning off NODE_ENV check ([fdbfbc5](https://github.com/ifaxity/vite-plugin-istanbul/commit/fdbfbc5f98828dd61b28a6680ce607ed1576cdaf)) |
@@ -8,2 +8,3 @@ import type { Plugin } from 'vite'; | ||
cypress?: boolean; | ||
checkProd?: boolean; | ||
} | ||
@@ -10,0 +11,0 @@ declare global { |
@@ -67,10 +67,12 @@ "use strict"; | ||
function istanbulPlugin(opts = {}) { | ||
var _a; | ||
var _a, _b, _c; | ||
// Only instrument when we want to, as we only want instrumentation in test | ||
// By default the plugin is always on | ||
const env = opts.cypress ? process.env.CYPRESS_COVERAGE : process.env.VITE_COVERAGE; | ||
const requireEnv = (_a = opts.requireEnv) !== null && _a !== void 0 ? _a : false; | ||
if (process.env.NODE_ENV == 'production' || | ||
(env === null || env === void 0 ? void 0 : env.toLowerCase()) === 'false' || | ||
(requireEnv && (env === null || env === void 0 ? void 0 : env.toLowerCase()) !== 'true')) { | ||
const env = (opts.cypress ? process.env.CYPRESS_COVERAGE : process.env.VITE_COVERAGE); | ||
const envValue = env === null || env === void 0 ? void 0 : env.toLowerCase(); | ||
const requireEnv = (_a = opts === null || opts === void 0 ? void 0 : opts.requireEnv) !== null && _a !== void 0 ? _a : false; | ||
const prodCheck = (_b = opts === null || opts === void 0 ? void 0 : opts.checkProd) !== null && _b !== void 0 ? _b : true; | ||
if ((prodCheck && ((_c = process.env.NODE_ENV) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === 'production') || | ||
(!requireEnv && envValue === 'false') || | ||
(requireEnv && envValue !== 'true')) { | ||
return { name: PLUGIN_NAME }; | ||
@@ -77,0 +79,0 @@ } |
{ | ||
"name": "vite-plugin-istanbul", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"author": "iFaxity (christian@faxity.se)", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -43,2 +43,3 @@ vite-plugin-istanbul | ||
* `opts.cypress {boolean}` - Optional boolean to change the env to CYPRESS_COVERAGE instead of VITE_COVERAGE. For ease of use with @cypress/code-coverage | ||
* `opts.checkProd {boolean}` - Optional boolean to enforce the plugin to skip instrumentation for production environments, checks NODE_ENV for "production" (case insensitive). Defaults to true` | ||
@@ -45,0 +46,0 @@ Examples |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12785
103
72