vite-plugin-istanbul
Advanced tools
Comparing version 2.7.3 to 2.8.0
@@ -1,6 +0,6 @@ | ||
## [2.7.3](https://github.com/ifaxity/vite-plugin-istanbul/compare/v2.7.2...v2.7.3) (2022-05-05) | ||
# [2.8.0](https://github.com/ifaxity/vite-plugin-istanbul/compare/v2.7.3...v2.8.0) (2022-06-10) | ||
### Bug Fixes | ||
### Features | ||
* sourcesContent not being escaped ([99ce9c0](https://github.com/ifaxity/vite-plugin-istanbul/commit/99ce9c0aca2f4cd62e23041b92291ac04e2c6407)) | ||
* Added support for envPrefix ([dd45164](https://github.com/ifaxity/vite-plugin-istanbul/commit/dd451649ac4de4f15ea7e816e151b6ccfaa2364d)) |
@@ -21,2 +21,12 @@ "use strict"; | ||
} | ||
function getEnvVariable(key, prefix, env) { | ||
if (Array.isArray(prefix)) { | ||
const envPrefix = prefix.find(pre => { | ||
const prefixedName = `${pre}${key}`; | ||
return env[prefixedName] != null; | ||
}); | ||
prefix = envPrefix !== null && envPrefix !== void 0 ? envPrefix : ''; | ||
} | ||
return env[`${prefix}${key}`]; | ||
} | ||
module.exports = function istanbulPlugin(opts = {}) { | ||
@@ -67,12 +77,15 @@ var _a, _b, _c, _d, _e; | ||
configResolved(config) { | ||
var _a; | ||
var _a, _b; | ||
// We need to check if the plugin should enable after all configuration is resolved | ||
// As config can be modified by other plugins and from .env variables | ||
const { isProduction } = config; | ||
const { isProduction, env } = config; | ||
const { CYPRESS_COVERAGE } = process.env; | ||
const { VITE_COVERAGE } = config.env; | ||
const env = (_a = (opts.cypress ? CYPRESS_COVERAGE : VITE_COVERAGE)) === null || _a === void 0 ? void 0 : _a.toLowerCase(); | ||
const envPrefix = (_a = config.envPrefix) !== null && _a !== void 0 ? _a : 'VITE_'; | ||
const envCoverage = opts.cypress | ||
? CYPRESS_COVERAGE | ||
: getEnvVariable('COVERAGE', envPrefix, env); | ||
const envVar = (_b = envCoverage === null || envCoverage === void 0 ? void 0 : envCoverage.toLowerCase()) !== null && _b !== void 0 ? _b : ''; | ||
if ((checkProd && isProduction && !forceBuildInstrument) || | ||
(!requireEnv && env === 'false') || | ||
(requireEnv && env !== 'true')) { | ||
(!requireEnv && envVar === 'false') || | ||
(requireEnv && envVar !== 'true')) { | ||
enabled = false; | ||
@@ -79,0 +92,0 @@ } |
{ | ||
"name": "vite-plugin-istanbul", | ||
"version": "2.7.3", | ||
"version": "2.8.0", | ||
"author": "iFaxity (christian@faxity.se)", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
17939
147