From b0d6daeb1c04a71fe4af03a177d094aa2de74ab3 Mon Sep 17 00:00:00 2001 From: jl Date: Mon, 22 Jan 2018 13:53:16 +0800 Subject: [PATCH] fix: coverage reportDir should respect `--cwd` (#764) when invoked with `nyc --cwd sub-directory`, coverage reports were saved in `./coverage`, shouldn't it be `./sub-directory/coverage`? --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 812fd4593..7afbded8f 100755 --- a/index.js +++ b/index.js @@ -444,7 +444,7 @@ NYC.prototype.report = function () { var tree var map = this._getCoverageMapFromAllCoverageFiles() var context = libReport.createContext({ - dir: this._reportDir, + dir: this.reportDirectory(), watermarks: this.config.watermarks }) @@ -537,6 +537,10 @@ NYC.prototype.tempDirectory = function () { return path.resolve(this.cwd, this._tempDirectory) } +NYC.prototype.reportDirectory = function () { + return path.resolve(this.cwd, this._reportDir) +} + NYC.prototype.processInfoDirectory = function () { return path.resolve(this.tempDirectory(), 'processinfo') }