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.1.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.2.0
Choose a head ref
  • 17 commits
  • 16 files changed
  • 10 contributors

Commits on Oct 14, 2018

  1. docs: Reference @babel/preset-env instead of @babel/env (#925)

    Using the full module name may help avoid potential confusion as `npm install @babel/env` is not valid.
    revelt authored and coreyfarrell committed Oct 14, 2018

    Verified

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

Commits on Nov 19, 2018

  1. chore: Update dependencies. (#926)

    This causes an update to mem to resolve a potential DoS vulnerability in
    command-line processing.
    
    The vulnerable version of mem is still included by development
    dependencies.
    
    Fixes #918
    coreyfarrell authored and JaKXz committed Nov 19, 2018

    Verified

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

Commits on Jan 5, 2019

  1. chore: enable probot-stale

    JaKXz authored Jan 5, 2019

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    2dbb82d View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ba22a26 View commit details
  3. fix: nyc processing files not covered by include when all is enable…

    …d. (#914)
    
    Fixes #913.
    Fixes #782.
    AGrzes authored and JaKXz committed Jan 5, 2019

    Verified

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

Commits on Jan 6, 2019

  1. fix: missing command temp-directory (#928)

    * Fix missing command temp-directory
    
    After changing tempDirectory to tempDir, with a fallback for tempDirectory, the default values set in the 'temp-dir' yargs option were being used rather than falling back to tempDirectory and then the default temp dir.
    This change removes the yargs default value for the option 'temp-dir'.
    This means the statement that assigns '_tempDirectory' in 'index.js' attempts to use temp-dir, then temp-directory, then the default value.  
    This is now under test with some new test cases that show:
      - tempDir is preferred to tempDirectory
      - tempDirectory is used if tempDir isn't set
      - that we fall back to the '.nyc_output' dir if neither tempDir or tempDirectory are set.
    
    * Alternate implementation
    
    Maintains notice of default temp-dir in help output.
    Removed tests as I'm not confident with these right now, will take another look when I get some time.
    
    Fixes #927.
    AndrewFinlay authored and JaKXz committed Jan 6, 2019

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    28b6d09 View commit details
  2. Verified

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

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

Commits on Jan 8, 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
    d566efe View commit details

Commits on Jan 12, 2019

  1. tests: coverage for temp-dir changes (#964)

    Covers default value, legacy temp-directory option and new temp-dir option
    AndrewFinlay authored and JaKXz committed Jan 12, 2019

    Verified

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

Commits on Jan 13, 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
    35710b1 View commit details

Commits on Jan 15, 2019

  1. feat: avoid hardcoded HOME for spawn-wrap working dir (#957)

    By default, spawn-wrap writes temporary files to HOME.
    It used to be /tmp, but it changed that to HOME to support
    environments that have 'noexec' flags set on their tmpfs mount.
    Ref istanbuljs/spawn-wrap#3.
    
    The problem with this is that nyc now no longer works in environments
    without a (writable) home directory (e.g. the 'nobody' user on
    Linux).
    
    While it is fine to fallback to HOME, it should write elsewhere
    if that is unavailable, and ideally in a way that doesn't require
    every sysadmin or end-user to hardcode some environment variable
    in their package.json specifically for nyc or spawn-wrap.
    
    A common way to communicate this intent is with the XDG_CACHE_HOME
    environment variable.
    
    Fixes #951.
    Krinkle authored and coreyfarrell committed Jan 15, 2019

    Verified

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

Commits on Jan 19, 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
    35cd49a View commit details

Commits on Jan 26, 2019

  1. feat: Option Plugins (#948)

    wzalazar authored and coreyfarrell committed Jan 26, 2019

    Verified

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

Commits on Jan 27, 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
    921d386 View commit details
  2. chore: Update dependencies. (#978)

    * Update dependencies.
    * Replace legacy debug-log ponyfill with util.debuglog.
    coreyfarrell authored Jan 27, 2019
    Copy the full SHA
    e95856c View commit details
  3. chore(release): 13.2.0

    coreyfarrell committed Jan 27, 2019
    Copy the full SHA
    29e6f5e View commit details
Showing with 1,107 additions and 979 deletions.
  1. +6 −0 .github/stale.yml
  2. +15 −4 .travis.yml
  3. +19 −0 CHANGELOG.md
  4. +3 −6 README.md
  5. +0 −23 appveyor.yml
  6. +3 −0 bin/nyc.js
  7. +19 −16 index.js
  8. +3 −0 lib/commands/merge.js
  9. +6 −2 lib/config-util.js
  10. +5 −2 lib/instrumenters/istanbul.js
  11. +883 −881 package-lock.json
  12. +19 −22 package.json
  13. +4 −0 test/fixtures/transpile-hook.js
  14. +76 −5 test/nyc-bin.js
  15. +1 −1 test/nyc.js
  16. +45 −17 test/src/nyc-tap.js
6 changes: 6 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
exemptLabels:
- "Great First Contribution"
- pinned
- security

staleLabel: stale
19 changes: 15 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
sudo: false
language: node_js
os:
- windows
- linux
- osx
node_js:
- "node"
- 10
- 8
- 6
- "stable"
matrix:
## An ENOMEM error occurs with 11.6.0 under Travis-CI for Windows.
## Disable until we can determine the cause.
# include:
# - os: windows
# node_js: "latest"
exclude:
- os: windows
node_js: "node"
git:
depth:
1
env:
secure: "SVg7NpV0Sru296kdp+eFl07RFjtJy242fWQ1KDCUdk/1EtZEOzBoSKP7Tn3zX/VLBieexL0T31EwYvRztnL97Sr8VgpYU0z95vCPO8FrixElJR6NH3dqrKeNzC3xOYdV0fy2b4UMlPJOI0aYDT1KHm1aWtkb2J8zqII+XbMtlDaelfHCDxa2+RBII9nYYDP62z+0chQFS6MGPSNwve3G2emYHZpYP5iTFmOzaFUCAjLskKvnnsY0jyx5XssqAo17747WKZl5SDgN8YHZIwhE5tB9m9j3MGjJhwdsR3kmq2om0GD1tQFFAXzWhWad3zNBUE4fLqswgASi39o5NIEzvSRzpw77ttOkkIFGem0l421Zi25W8x5n6GZvP06Y47ddmjNBlniwIzG4fb3dbIByCy/g5SjUYmfnke7stXXBKsPv0eEadlLGFWnG5RIfnyGjvUgQ//QXSAnBBzYF9IK+KUdU8c9kHF6kPybsGEzjQoX+4EJL6kZ4sNX9qxjHERUr4Jb6rAMOnKI9VtCBNqwcCC3nV5DDWHS86hKwbuTbBFkszP7majOi0kUQJTO/tZGwVVcphSDwhL5QkmMepLOqXyRICdUcB2ffXHYhZLiZPofYdom8csaDolqFkotJEBj3GM3gwHvUC3i1vxshxtjF6NHjanhpiIpHLRCs6R1RESE="

after_script:
- "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls"
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,25 @@

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.2.0"></a>
# [13.2.0](https://github.com/istanbuljs/nyc/compare/v13.1.0...v13.2.0) (2019-01-27)


### Bug Fixes

* Create directory for merge destination. ([#979](https://github.com/istanbuljs/nyc/issues/979)) ([921d386](https://github.com/istanbuljs/nyc/commit/921d386)), closes [#976](https://github.com/istanbuljs/nyc/issues/976)
* missing command temp-directory ([#928](https://github.com/istanbuljs/nyc/issues/928)) ([28b6d09](https://github.com/istanbuljs/nyc/commit/28b6d09)), closes [#927](https://github.com/istanbuljs/nyc/issues/927)
* nyc processing files not covered by include when `all` is enabled. ([#914](https://github.com/istanbuljs/nyc/issues/914)) ([40afc5f](https://github.com/istanbuljs/nyc/commit/40afc5f)), closes [#913](https://github.com/istanbuljs/nyc/issues/913) [#782](https://github.com/istanbuljs/nyc/issues/782)


### Features

* avoid hardcoded HOME for spawn-wrap working dir ([#957](https://github.com/istanbuljs/nyc/issues/957)) ([ff834aa](https://github.com/istanbuljs/nyc/commit/ff834aa)), closes [#951](https://github.com/istanbuljs/nyc/issues/951)
* document the fact that cacheDir is configurable ([#968](https://github.com/istanbuljs/nyc/issues/968)) ([35cd49a](https://github.com/istanbuljs/nyc/commit/35cd49a))
* Option Plugins ([#948](https://github.com/istanbuljs/nyc/issues/948)) ([df2730d](https://github.com/istanbuljs/nyc/commit/df2730d))



<a name="13.1.0"></a>
# [13.1.0](https://github.com/istanbuljs/nyc/compare/v13.0.1...v13.1.0) (2018-09-06)

9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
[![Build Status](https://travis-ci.org/istanbuljs/nyc.svg?branch=master)](https://travis-ci.org/istanbuljs/nyc)
[![Coverage Status](https://coveralls.io/repos/bcoe/nyc/badge.svg?branch=)](https://coveralls.io/r/bcoe/nyc?branch=master)
[![NPM version](https://img.shields.io/npm/v/nyc.svg)](https://www.npmjs.com/package/nyc)
[![Windows Tests](https://img.shields.io/appveyor/ci/bcoe/nyc-ilw23/master.svg?label=Windows%20Tests)](https://ci.appveyor.com/project/bcoe/nyc-ilw23)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![community slack](http://devtoolscommunity.herokuapp.com/badge.svg)](http://devtoolscommunity.herokuapp.com)

@@ -90,7 +89,7 @@ We recommend using [`babel-plugin-istanbul`] if your project uses the babel tool
```json
{
"babel": {
"presets": ["@babel/env"],
"presets": ["@babel/preset-env"],
"env": {
"test": {
"plugins": ["istanbul"]
@@ -252,13 +251,11 @@ modules should be required in the subprocess collecting coverage:

## Caching

You can run `nyc` with the optional `--cache` flag, to prevent it from
instrumenting the same files multiple times. This can significantly
improve runtime performance.
`nyc`'s default behavior is to cache instrumented files to disk to prevent instrumenting source files multiple times, and speed `nyc` execution times. You can disable this behavior by running `nyc` with the `--cache false` flag. You can also change the default cache directory from `./node_modules/.cache/nyc` by setting the `--cache-dir` flag.

## Configuring `nyc`

Any configuration options that can be set via the command line can also be specified in the `nyc` stanza of your package.json, or within a `.nycrc` file:
Any configuration options that can be set via the command line can also be specified in the `nyc` stanza of your package.json, or within a `.nycrc` (or `.nycrc.json`) file:

**package.json:**

23 changes: 0 additions & 23 deletions appveyor.yml

This file was deleted.

3 changes: 3 additions & 0 deletions bin/nyc.js
Original file line number Diff line number Diff line change
@@ -42,6 +42,9 @@ if ([
if (argv.all) nyc.addAllFiles()

var env = {
// Support running nyc as a user without HOME (e.g. linux 'nobody'),
// https://github.com/istanbuljs/nyc/issues/951
SPAWN_WRAP_SHIM_ROOT: process.env.SPAWN_WRAP_SHIM_ROOT || process.env.XDG_CACHE_HOME || require('os').homedir(),
NYC_CONFIG: JSON.stringify(argv),
NYC_CWD: process.cwd(),
NYC_ROOT_ID: nyc.rootId,
35 changes: 19 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

const arrify = require('arrify')
const cachingTransform = require('caching-transform')
const debugLog = require('debug-log')('nyc')
const util = require('util')
const findCacheDir = require('find-cache-dir')
const fs = require('fs')
const glob = require('glob')
@@ -23,6 +23,8 @@ const SourceMaps = require('./lib/source-maps')
const testExclude = require('test-exclude')
const uuid = require('uuid/v4')

const debugLog = util.debuglog('nyc')

var ProcessInfo
try {
ProcessInfo = require('./lib/process.covered.js')
@@ -41,7 +43,7 @@ function NYC (config) {
this.config = config

this.subprocessBin = config.subprocessBin || path.resolve(__dirname, './bin/nyc.js')
this._tempDirectory = config.tempDir || config.tempDirectory || './.nyc_output'
this._tempDirectory = config.tempDirectory || config.tempDir || './.nyc_output'
this._instrumenterLib = require(config.instrumenter || './lib/instrumenters/istanbul')
this._reportDir = config.reportDir || 'coverage'
this._sourceMap = typeof config.sourceMap === 'boolean' ? config.sourceMap : true
@@ -50,7 +52,7 @@ function NYC (config) {
this.cwd = config.cwd || process.cwd()
this.reporter = arrify(config.reporter || 'text')

this.cacheDirectory = (config.cacheDir && path.resolve(config.cacheDir)) || findCacheDir({name: 'nyc', cwd: this.cwd})
this.cacheDirectory = (config.cacheDir && path.resolve(config.cacheDir)) || findCacheDir({ name: 'nyc', cwd: this.cwd })
this.cache = Boolean(this.cacheDirectory && config.cache)

this.exclude = testExclude({
@@ -140,7 +142,8 @@ NYC.prototype._createInstrumenter = function () {
produceSourceMap: this.config.produceSourceMap,
compact: this.config.compact,
preserveComments: this.config.preserveComments,
esModules: this.config.esModules
esModules: this.config.esModules,
plugins: this.config.plugins
})
}

@@ -178,14 +181,14 @@ NYC.prototype.addAllFiles = function () {
this.fakeRequire = true
this.walkAllFiles(this.cwd, function (filename) {
filename = path.resolve(_this.cwd, filename)
_this.addFile(filename)
var coverage = coverageFinder()
var lastCoverage = _this.instrumenter().lastFileCoverage()
if (lastCoverage) {
filename = lastCoverage.path
}
if (lastCoverage && _this.exclude.shouldInstrument(filename)) {
coverage[filename] = lastCoverage
if (_this.exclude.shouldInstrument(filename)) {
_this.addFile(filename)
var coverage = coverageFinder()
var lastCoverage = _this.instrumenter().lastFileCoverage()
if (lastCoverage) {
filename = lastCoverage.path
coverage[filename] = lastCoverage
}
}
})
this.fakeRequire = false
@@ -210,7 +213,7 @@ NYC.prototype.instrumentAllFiles = function (input, output, cb) {
}

if (transform) {
code = transform(code, {filename: filename, relFile: inFile})
code = transform(code, { filename: filename, relFile: inFile })
}

if (!output) {
@@ -246,7 +249,7 @@ NYC.prototype.walkAllFiles = function (dir, visitor) {
pattern = '**/*{' + this.extensions.join() + '}'
}

glob.sync(pattern, {cwd: dir, nodir: true, ignore: this.exclude.exclude}).forEach(function (filename) {
glob.sync(pattern, { cwd: dir, nodir: true, ignore: this.exclude.exclude }).forEach(function (filename) {
visitor(filename)
})
}
@@ -265,7 +268,7 @@ NYC.prototype._maybeInstrumentSource = function (code, filename, relFile) {
}
}

return transform ? transform(code, {filename: filename, relFile: relFile}) : null
return transform ? transform(code, { filename: filename, relFile: relFile }) : null
}

NYC.prototype._transformFactory = function (cacheDir) {
@@ -355,7 +358,7 @@ NYC.prototype._wrapExit = function () {
// regardless of how the process exits.
onExit(function () {
_this.writeCoverageFile()
}, {alwaysLast: true})
}, { alwaysLast: true })
}

NYC.prototype.wrap = function (bin) {
3 changes: 3 additions & 0 deletions lib/commands/merge.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict'
const fs = require('fs')
const path = require('path')
const makeDir = require('make-dir')

var NYC
try {
@@ -49,6 +51,7 @@ exports.handler = function (argv) {
console.error(`failed access input directory ${argv.inputDirectory} with error:\n\n${err.message}`)
process.exit(1)
}
makeDir.sync(path.dirname(argv.outputFile))
const map = nyc.getCoverageMapFromAllCoverageFiles(argv.inputDirectory)
fs.writeFileSync(argv.outputFile, JSON.stringify(map, null, 2), 'utf8')
console.info(`coverage files in ${argv.inputDirectory} merged into ${argv.outputFile}`)
8 changes: 6 additions & 2 deletions lib/config-util.js
Original file line number Diff line number Diff line change
@@ -11,15 +11,15 @@ var Config = {}

function guessCWD (cwd) {
cwd = cwd || process.env.NYC_CWD || process.cwd()
const pkgPath = findUp.sync('package.json', {cwd: cwd})
const pkgPath = findUp.sync('package.json', { cwd: cwd })
if (pkgPath) {
cwd = path.dirname(pkgPath)
}
return cwd
}

Config.loadConfig = function (argv, cwd) {
const rcPath = findUp.sync([argv.nycrcPath || '.nycrc', '.nycrc.json'], {cwd: guessCWD(cwd)})
const rcPath = findUp.sync([argv.nycrcPath || '.nycrc', '.nycrc.json'], { cwd: guessCWD(cwd) })
let config = {}

if (rcPath) {
@@ -109,6 +109,10 @@ Config.buildYargs = function (cwd) {
describe: 'cache instrumentation results for improved performance',
global: false
})
.option('cache-dir', {
describe: 'explicitly set location for instrumentation cache',
global: false
})
.option('babel-cache', {
default: false,
type: 'boolean',
7 changes: 5 additions & 2 deletions lib/instrumenters/istanbul.js
Original file line number Diff line number Diff line change
@@ -4,8 +4,11 @@ var convertSourceMap = require('convert-source-map')
var 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({
var instrumenter = istanbul.createInstrumenter(Object.assign({
autoWrap: true,
coverageVariable: '__coverage__',
embedSource: true,
@@ -14,7 +17,7 @@ function InstrumenterIstanbul (cwd, options) {
produceSourceMap: options.produceSourceMap,
ignoreClassMethods: options.ignoreClassMethods,
esModules: options.esModules
})
}, configPlugins))

return {
instrumentSync: function (code, filename, sourceMap) {
Loading