babel-plugin-istanbul
Advanced tools
Comparing version 5.2.0 to 6.0.0-beta.0
@@ -5,2 +5,14 @@ # Changelog | ||
## [6.0.0-beta.0](https://github.com/istanbuljs/babel-plugin-istanbul/compare/v5.2.0...v6.0.0-beta.0) (2019-10-09) | ||
### ⚠ 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/fe08f5b)), 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/93db21a)), 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) | ||
@@ -7,0 +19,0 @@ |
131
lib/index.js
@@ -8,5 +8,7 @@ "use strict"; | ||
var _path = _interopRequireDefault(require("path")); | ||
var _fs = require("fs"); | ||
var _path = require("path"); | ||
var _child_process = require("child_process"); | ||
@@ -17,10 +19,15 @@ var _helperPluginUtils = require("@babel/helper-plugin-utils"); | ||
const testExclude = require('test-exclude'); | ||
var _testExclude = _interopRequireDefault(require("test-exclude")); | ||
const findUp = require('find-up'); | ||
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) || n; | ||
return (0, _fs.realpathSync)(n) || | ||
/* istanbul ignore next */ | ||
n; | ||
} catch (e) { | ||
/* istanbul ignore next */ | ||
return n; | ||
@@ -30,35 +37,73 @@ } | ||
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, opts) { | ||
if (!exclude || exclude.cwd !== opts.cwd) { | ||
const cwd = getRealpath(process.env.NYC_CWD || process.cwd()); | ||
const nycConfig = process.env.NYC_CONFIG ? JSON.parse(process.env.NYC_CONFIG) : {}; | ||
let config = {}; | ||
if (Object.keys(opts).length > 0) { | ||
// explicitly configuring options in babel | ||
// takes precedence. | ||
config = opts; | ||
} else if (nycConfig.include || nycConfig.exclude) { | ||
// nyc was configured in a parent process (keep these settings). | ||
config = { | ||
include: nycConfig.include, | ||
exclude: nycConfig.exclude, | ||
// Make sure this is true unless explicitly set to `false`. `undefined` is still `true`. | ||
excludeNodeModules: nycConfig.excludeNodeModules !== false | ||
}; | ||
} else { | ||
// fallback to loading config from key in package.json. | ||
config = { | ||
configKey: 'nyc', | ||
configPath: (0, _path.dirname)(findUp.sync('package.json', { | ||
cwd | ||
})) | ||
}; | ||
} | ||
exclude = testExclude(Object.assign({ | ||
cwd | ||
}, config)); | ||
return function shouldSkip(file, nycConfig) { | ||
if (!exclude || exclude.cwd !== nycConfig.cwd) { | ||
exclude = (0, _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 | ||
}); | ||
} | ||
@@ -72,4 +117,4 @@ | ||
api.assertVersion(7); | ||
const shouldSkip = makeShouldSkip(); | ||
const t = api.types; | ||
const shouldSkip = makeShouldSkip(); | ||
return { | ||
@@ -80,5 +125,6 @@ visitor: { | ||
this.__dv__ = null; | ||
this.nycConfig = findConfig(this.opts); | ||
const realPath = getRealpath(this.file.opts.filename); | ||
if (shouldSkip(realPath, this.opts)) { | ||
if (shouldSkip(realPath, this.nycConfig)) { | ||
return; | ||
@@ -97,4 +143,11 @@ } | ||
this.__dv__ = (0, _istanbulLibInstrument.programVisitor)(t, realPath, { | ||
coverageVariable: '__coverage__', | ||
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 | ||
@@ -101,0 +154,0 @@ }); |
{ | ||
"name": "babel-plugin-istanbul", | ||
"version": "5.2.0", | ||
"version": "6.0.0-beta.0", | ||
"author": "Thai Pangsakulyanont @dtinth", | ||
@@ -13,19 +13,20 @@ "license": "BSD-3-Clause", | ||
"@babel/helper-plugin-utils": "^7.0.0", | ||
"find-up": "^3.0.0", | ||
"istanbul-lib-instrument": "^3.3.0", | ||
"test-exclude": "^5.2.3" | ||
"@istanbuljs/load-nyc-config": "^1.0.0-alpha.1", | ||
"@istanbuljs/schema": "^0.1.1", | ||
"istanbul-lib-instrument": "^4.0.0-alpha.1", | ||
"test-exclude": "^6.0.0-alpha.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.4.3", | ||
"@babel/core": "^7.4.3", | ||
"@babel/plugin-transform-modules-commonjs": "^7.4.3", | ||
"@babel/register": "^7.4.0", | ||
"@babel/cli": "^7.6.2", | ||
"@babel/core": "^7.6.2", | ||
"@babel/plugin-transform-modules-commonjs": "^7.6.0", | ||
"@babel/register": "^7.6.2", | ||
"chai": "^4.2.0", | ||
"coveralls": "^3.0.3", | ||
"cross-env": "^5.2.0", | ||
"mocha": "^6.1.4", | ||
"nyc": "^14.1.0", | ||
"coveralls": "^3.0.6", | ||
"cross-env": "^6.0.3", | ||
"mocha": "^6.2.1", | ||
"nyc": "^15.0.0-alpha.0", | ||
"pmock": "^0.2.3", | ||
"standard": "^12.0.1", | ||
"standard-version": "^6.0.1" | ||
"standard": "^14.3.1", | ||
"standard-version": "^7.0.0" | ||
}, | ||
@@ -36,3 +37,3 @@ "scripts": { | ||
"pretest": "standard && npm run release", | ||
"test": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha test/*.js", | ||
"test": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha --timeout 5000 test/*.js", | ||
"prepublish": "npm test && npm run release", | ||
@@ -43,3 +44,3 @@ "version": "standard-version" | ||
"ignore": [ | ||
"fixtures/has-inline-source-map.js" | ||
"fixtures/*.js" | ||
] | ||
@@ -73,4 +74,4 @@ }, | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=8" | ||
} | ||
} |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
24777
6
149
5
1
1
+ Added@istanbuljs/schema@^0.1.1
+ Added@ampproject/remapping@2.3.0(transitive)
+ Added@babel/compat-data@7.25.4(transitive)
+ Added@babel/core@7.25.2(transitive)
+ Added@babel/helper-compilation-targets@7.25.2(transitive)
+ Added@babel/helper-module-imports@7.24.7(transitive)
+ Added@babel/helper-module-transforms@7.25.2(transitive)
+ Added@babel/helper-simple-access@7.24.7(transitive)
+ Added@babel/helper-validator-option@7.24.8(transitive)
+ Added@babel/helpers@7.25.6(transitive)
+ Added@istanbuljs/load-nyc-config@1.1.0(transitive)
+ Added@istanbuljs/schema@0.1.3(transitive)
+ Addedargparse@1.0.10(transitive)
+ Addedbrowserslist@4.23.3(transitive)
+ Addedcamelcase@5.3.1(transitive)
+ Addedcaniuse-lite@1.0.30001662(transitive)
+ Addedconvert-source-map@2.0.0(transitive)
+ Addedelectron-to-chromium@1.5.25(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedfind-up@4.1.0(transitive)
+ Addedgensync@1.0.0-beta.2(transitive)
+ Addedget-package-type@0.1.0(transitive)
+ Addedistanbul-lib-coverage@3.2.2(transitive)
+ Addedistanbul-lib-instrument@4.0.3(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedjson5@2.2.3(transitive)
+ Addedlocate-path@5.0.0(transitive)
+ Addedlru-cache@5.1.1(transitive)
+ Addednode-releases@2.0.18(transitive)
+ Addedp-locate@4.1.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedresolve-from@5.0.0(transitive)
+ Addedsprintf-js@1.0.3(transitive)
+ Addedtest-exclude@6.0.0(transitive)
+ Addedupdate-browserslist-db@1.1.0(transitive)
+ Addedyallist@3.1.1(transitive)
- Removedfind-up@^3.0.0
- Removederror-ex@1.3.2(transitive)
- Removedfind-up@3.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedistanbul-lib-coverage@2.0.5(transitive)
- Removedistanbul-lib-instrument@3.3.0(transitive)
- Removedjson-parse-better-errors@1.0.2(transitive)
- Removedload-json-file@4.0.0(transitive)
- Removedlocate-path@3.0.0(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removedp-locate@3.0.0(transitive)
- Removedparse-json@4.0.0(transitive)
- Removedpath-exists@3.0.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@3.0.0(transitive)
- Removedpify@3.0.0(transitive)
- Removedread-pkg@3.0.0(transitive)
- Removedread-pkg-up@4.0.0(transitive)
- Removedrequire-main-filename@2.0.0(transitive)
- Removedresolve@1.22.8(transitive)
- Removedsemver@5.7.2(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.20(transitive)
- Removedstrip-bom@3.0.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtest-exclude@5.2.3(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
Updatedtest-exclude@^6.0.0-alpha.1