vite-plugin-istanbul
Advanced tools
Comparing version 2.8.0 to 2.9.0
@@ -1,6 +0,11 @@ | ||
# [2.8.0](https://github.com/ifaxity/vite-plugin-istanbul/compare/v2.7.3...v2.8.0) (2022-06-10) | ||
# [2.9.0](https://github.com/ifaxity/vite-plugin-istanbul/compare/v2.8.0...v2.9.0) (2022-07-16) | ||
### Bug Fixes | ||
* Updated lockfile ([f1e8048](https://github.com/ifaxity/vite-plugin-istanbul/commit/f1e80483419c304d59ec4e5b71ad54daf8b2f086)) | ||
### Features | ||
* Added support for envPrefix ([dd45164](https://github.com/ifaxity/vite-plugin-istanbul/commit/dd451649ac4de4f15ea7e816e151b6ccfaa2364d)) | ||
* Reading config from nyc config files ([a8a7c95](https://github.com/ifaxity/vite-plugin-istanbul/commit/a8a7c95b848cc1b0f1718a35a3a1c5e4ee9c281b)) |
@@ -12,4 +12,5 @@ import { Plugin } from 'vite'; | ||
checkProd?: boolean; | ||
forceBuildInstrument?: boolean; | ||
cwd?: string; | ||
forceBuildInstrument?: boolean; | ||
nycrcPath?: string; | ||
} | ||
@@ -16,0 +17,0 @@ declare const _default: (opts?: IstanbulPluginOptions) => Plugin; |
@@ -8,2 +8,3 @@ "use strict"; | ||
const test_exclude_1 = __importDefault(require("test-exclude")); | ||
const load_nyc_config_1 = require("@istanbuljs/load-nyc-config"); | ||
const picocolors_1 = require("picocolors"); | ||
@@ -32,6 +33,22 @@ // Custom extensions to include .vue files | ||
} | ||
module.exports = function istanbulPlugin(opts = {}) { | ||
var _a, _b, _c, _d, _e; | ||
function createTestExclude(opts) { | ||
var _a, _b; | ||
const { nycrcPath, include, exclude, extension } = opts; | ||
const cwd = (_a = opts.cwd) !== null && _a !== void 0 ? _a : process.cwd(); | ||
const nycConfig = (0, load_nyc_config_1.loadNycConfig)({ | ||
cwd, | ||
nycrcPath, | ||
}); | ||
// Only instrument when we want to, as we only want instrumentation in test | ||
// By default the plugin is always on | ||
return new test_exclude_1.default({ | ||
cwd, | ||
include: include !== null && include !== void 0 ? include : nycConfig.include, | ||
exclude: exclude !== null && exclude !== void 0 ? exclude : nycConfig.exclude, | ||
extension: (_b = extension !== null && extension !== void 0 ? extension : nycConfig.extension) !== null && _b !== void 0 ? _b : DEFAULT_EXTENSION, | ||
excludeNodeModules: true, | ||
}); | ||
} | ||
module.exports = function istanbulPlugin(opts = {}) { | ||
var _a, _b, _c; | ||
const requireEnv = (_a = opts === null || opts === void 0 ? void 0 : opts.requireEnv) !== null && _a !== void 0 ? _a : false; | ||
@@ -41,9 +58,3 @@ const checkProd = (_b = opts === null || opts === void 0 ? void 0 : opts.checkProd) !== null && _b !== void 0 ? _b : true; | ||
const logger = (0, vite_1.createLogger)('warn', { prefix: 'vite-plugin-istanbul' }); | ||
const exclude = new test_exclude_1.default({ | ||
cwd: (_d = opts.cwd) !== null && _d !== void 0 ? _d : process.cwd(), | ||
include: opts.include, | ||
exclude: opts.exclude, | ||
extension: (_e = opts.extension) !== null && _e !== void 0 ? _e : DEFAULT_EXTENSION, | ||
excludeNodeModules: true, | ||
}); | ||
const testExclude = createTestExclude(opts); | ||
const instrumenter = (0, istanbul_lib_instrument_1.createInstrumenter)({ | ||
@@ -125,3 +136,3 @@ coverageGlobalScopeFunc: false, | ||
} | ||
if (exclude.shouldInstrument(id)) { | ||
if (testExclude.shouldInstrument(id)) { | ||
const sourceMap = sanitizeSourceMap(this.getCombinedSourcemap()); | ||
@@ -128,0 +139,0 @@ const code = instrumenter.instrumentSync(srcCode, id, sourceMap); |
{ | ||
"name": "vite-plugin-istanbul", | ||
"version": "2.8.0", | ||
"version": "2.9.0", | ||
"author": "iFaxity (christian@faxity.se)", | ||
@@ -32,2 +32,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@istanbuljs/load-nyc-config": "^1.1.0", | ||
"istanbul-lib-instrument": "^5.1.0", | ||
@@ -34,0 +35,0 @@ "picocolors": "^1.0.0", |
@@ -35,11 +35,12 @@ vite-plugin-istanbul | ||
#### Parameters | ||
* `opts {IstanbulPluginOptions}` - Object of optional options to pass to the plugin. | ||
* `opts.cwd {string}` - Optional string of the current working directory, used for the include/exclude patterns. Defaults to `process.cwd()`. | ||
* `opts.include {string|string[]}` - Optional string or array of strings of glob patterns to include. | ||
* `opts.exclude {string|string[]}` - Optional string or array of strings of glob patterns to exclude. | ||
* `opts.extension {string|string[]}` - Optional string or array of strings of extensions to include (dot prefixed like .js or .ts). By default this is set to `['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx', '.vue']`. | ||
* `opts.requireEnv {boolean}` - Optional boolean to require the environment variable (defaults to **VITE_COVERAGE**) to equal `true` in order to instrument the code. Otherwise it will instrument even if env variable is not set. However if `requireEnv` is not set the instrumentation will stop if the environment variable is equal to `false`. | ||
* `opts.cypress {boolean}` - Optional boolean to change the environment variable 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. Looks at Vite's **isProduction** key from the `ResolvedConfig`. | ||
* `opts.forceBuildInstrument {boolean}` - Optional boolean to enforce the plugin to add instrumentation in build mode. Defaults to false. | ||
* `opts {IstanbulPluginOptions}` - Object of optional options to pass to the plugin. | ||
* `opts.cwd {string}` - Optional string of the current working directory, used for the include/exclude patterns. Defaults to `process.cwd()`. | ||
* `opts.include {string|string[]}` - Optional string or array of strings of glob patterns to include. | ||
* `opts.exclude {string|string[]}` - Optional string or array of strings of glob patterns to exclude. | ||
* `opts.extension {string|string[]}` - Optional string or array of strings of extensions to include (dot prefixed like .js or .ts). By default this is set to `['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx', '.vue']`. | ||
* `opts.requireEnv {boolean}` - Optional boolean to require the environment variable (defaults to **VITE_COVERAGE**) to equal `true` in order to instrument the code. Otherwise it will instrument even if env variable is not set. However if `requireEnv` is not set the instrumentation will stop if the environment variable is equal to `false`. | ||
* `opts.cypress {boolean}` - Optional boolean to change the environment variable 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. Looks at Vite's **isProduction** key from the `ResolvedConfig`. | ||
* `opts.forceBuildInstrument {boolean}` - Optional boolean to enforce the plugin to add instrumentation in build mode. Defaults to false. | ||
* `opts.nycrcPath {string}` - Path to specific nyc config to use instead of automatically searching for a nycconfig. This parameter is just passed down to `@istanbuljs/load-nyc-config`. | ||
@@ -46,0 +47,0 @@ Notes |
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
19222
159
82
4
+ Added@istanbuljs/load-nyc-config@1.1.0(transitive)
+ Addedargparse@1.0.10(transitive)
+ Addedcamelcase@5.3.1(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedfind-up@4.1.0(transitive)
+ Addedget-package-type@0.1.0(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedlocate-path@5.0.0(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@4.1.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedresolve-from@5.0.0(transitive)
+ Addedsprintf-js@1.0.3(transitive)