Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: istanbuljs/nyc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v13.2.0
Choose a base ref
...
head repository: istanbuljs/nyc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v13.3.0
Choose a head ref
  • 4 commits
  • 7 files changed
  • 2 contributors

Commits on Feb 3, 2019

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    dd48410 View commit details

Commits on Feb 5, 2019

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8a5e222 View commit details

Commits on Feb 14, 2019

  1. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    e8cc59b View commit details
  2. chore(release): 13.3.0

    coreyfarrell committed Feb 14, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    747a6c1 View commit details
Showing with 677 additions and 2,201 deletions.
  1. +15 −0 CHANGELOG.md
  2. +40 −0 lib/commands/report.js
  3. +6 −12 lib/instrumenters/istanbul.js
  4. +5 −5 lib/instrumenters/noop.js
  5. +576 −2,181 package-lock.json
  6. +3 −3 package.json
  7. +32 −0 test/nyc-bin.js
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,21 @@

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.

<a name="13.3.0"></a>
# [13.3.0](https://github.com/istanbuljs/nyc/compare/v13.2.0...v13.3.0) (2019-02-14)


### Bug Fixes

* update dependendencies due to vulnerabilities ([#992](https://github.com/istanbuljs/nyc/issues/992)) ([e8cc59b](https://github.com/istanbuljs/nyc/commit/e8cc59b)), closes [#991](https://github.com/istanbuljs/nyc/issues/991)


### Features

* Support nyc report --check-coverage ([#984](https://github.com/istanbuljs/nyc/issues/984)) ([dd48410](https://github.com/istanbuljs/nyc/commit/dd48410))



<a name="13.2.0"></a>
# [13.2.0](https://github.com/istanbuljs/nyc/compare/v13.1.0...v13.2.0) (2019-01-27)

40 changes: 40 additions & 0 deletions lib/commands/report.js
Original file line number Diff line number Diff line change
@@ -39,11 +39,51 @@ exports.builder = function (yargs) {
type: 'boolean',
global: false
})
.option('check-coverage', {
type: 'boolean',
default: false,
describe: 'check whether coverage is within thresholds provided',
global: false
})
.option('branches', {
default: 0,
description: 'what % of branches must be covered?',
global: false
})
.option('functions', {
default: 0,
description: 'what % of functions must be covered?',
global: false
})
.option('lines', {
default: 90,
description: 'what % of lines must be covered?',
global: false
})
.option('statements', {
default: 0,
description: 'what % of statements must be covered?',
global: false
})
.option('per-file', {
default: false,
type: 'boolean',
description: 'check thresholds per file',
global: false
})
.example('$0 report --reporter=lcov', 'output an HTML lcov report to ./coverage')
}

exports.handler = function (argv) {
process.env.NYC_CWD = process.cwd()
var nyc = new NYC(argv)
nyc.report()
if (argv.checkCoverage) {
nyc.checkCoverage({
lines: argv.lines,
functions: argv.functions,
branches: argv.branches,
statements: argv.statements
}, argv['per-file'])
}
}
18 changes: 6 additions & 12 deletions lib/instrumenters/istanbul.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict'

var convertSourceMap = require('convert-source-map')
var mergeSourceMap = require('merge-source-map')
const { createInstrumenter } = require('istanbul-lib-instrument')
const convertSourceMap = require('convert-source-map')
const mergeSourceMap = require('merge-source-map')

function InstrumenterIstanbul (cwd, options) {
const plugins = options.plugins
const configPlugins = plugins ? { plugins } : {}

var istanbul = InstrumenterIstanbul.istanbul()
var instrumenter = istanbul.createInstrumenter(Object.assign({
const instrumenter = createInstrumenter(Object.assign({
autoWrap: true,
coverageVariable: '__coverage__',
embedSource: true,
@@ -20,7 +20,7 @@ function InstrumenterIstanbul (cwd, options) {
}, configPlugins))

return {
instrumentSync: function (code, filename, sourceMap) {
instrumentSync (code, filename, sourceMap) {
var instrumented = instrumenter.instrumentSync(code, filename)
// the instrumenter can optionally produce source maps,
// this is useful for features like remapping stack-traces.
@@ -39,16 +39,10 @@ function InstrumenterIstanbul (cwd, options) {
}
return instrumented
},
lastFileCoverage: function () {
lastFileCoverage () {
return instrumenter.lastFileCoverage()
}
}
}

InstrumenterIstanbul.istanbul = function () {
InstrumenterIstanbul._istanbul || (InstrumenterIstanbul._istanbul = require('istanbul-lib-instrument'))

return InstrumenterIstanbul._istanbul || (InstrumenterIstanbul._istanbul = require('istanbul'))
}

module.exports = InstrumenterIstanbul
10 changes: 5 additions & 5 deletions lib/instrumenters/noop.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
var FileCoverage = require('istanbul-lib-coverage').classes.FileCoverage
var readInitialCoverage = require('istanbul-lib-instrument').readInitialCoverage
const { FileCoverage } = require('istanbul-lib-coverage').classes
const { readInitialCoverage } = require('istanbul-lib-instrument')

function NOOP () {
return {
instrumentSync: function (code, filename) {
var extracted = readInitialCoverage(code)
instrumentSync (code, filename) {
const extracted = readInitialCoverage(code)
if (extracted) {
this.fileCoverage = new FileCoverage(extracted.coverageData)
} else {
this.fileCoverage = null
}
return code
},
lastFileCoverage: function () {
lastFileCoverage () {
return this.fileCoverage
}
}
Loading