From 28395247153c570787f389c1e2e135eae5cf3055 Mon Sep 17 00:00:00 2001 From: Baptiste Gallet Date: Wed, 23 Oct 2019 16:14:04 +0200 Subject: [PATCH 1/4] Add support for relative option --- packages/istanbul-reports/lib/lcov/index.js | 5 ++--- packages/istanbul-reports/lib/lcovonly/index.js | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/istanbul-reports/lib/lcov/index.js b/packages/istanbul-reports/lib/lcov/index.js index b765b70c..936c3bd7 100644 --- a/packages/istanbul-reports/lib/lcov/index.js +++ b/packages/istanbul-reports/lib/lcov/index.js @@ -8,10 +8,9 @@ const LcovOnlyReport = require('../lcovonly'); const HtmlReport = require('../html'); class LcovReport extends ReportBase { - constructor() { + constructor(opts) { super(); - - this.lcov = new LcovOnlyReport({ file: 'lcov.info' }); + this.lcov = new LcovOnlyReport({ file: 'lcov.info', ...opts}); this.html = new HtmlReport({ subdir: 'lcov-report' }); } } diff --git a/packages/istanbul-reports/lib/lcovonly/index.js b/packages/istanbul-reports/lib/lcovonly/index.js index 2cee4fb0..6a42f6e6 100644 --- a/packages/istanbul-reports/lib/lcovonly/index.js +++ b/packages/istanbul-reports/lib/lcovonly/index.js @@ -9,6 +9,7 @@ class LcovOnlyReport extends ReportBase { constructor(opts) { super(); this.file = opts.file || 'lcov.info'; + this.relative = opts.relative || false; this.contentWriter = null; } @@ -25,9 +26,10 @@ class LcovOnlyReport extends ReportBase { const branches = fc.b; const branchMap = fc.branchMap; const summary = node.getCoverageSummary(); + const path = require('path'); writer.println('TN:'); //no test name - writer.println('SF:' + fc.path); + writer.println('SF:' + (this.relative ? path.relative(process.cwd(), fc.path) : fc.path)); Object.values(functionMap).forEach(meta => { writer.println('FN:' + [meta.decl.start.line, meta.name].join(',')); From 64da02f10737dcaa71e307104c6dc65c6068c42a Mon Sep 17 00:00:00 2001 From: Baptiste Gallet Date: Mon, 28 Oct 2019 12:24:23 +0100 Subject: [PATCH 2/4] Fix prettier requirements --- packages/istanbul-reports/lib/lcov/index.js | 2 +- packages/istanbul-reports/lib/lcovonly/index.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/istanbul-reports/lib/lcov/index.js b/packages/istanbul-reports/lib/lcov/index.js index 936c3bd7..383c2027 100644 --- a/packages/istanbul-reports/lib/lcov/index.js +++ b/packages/istanbul-reports/lib/lcov/index.js @@ -10,7 +10,7 @@ const HtmlReport = require('../html'); class LcovReport extends ReportBase { constructor(opts) { super(); - this.lcov = new LcovOnlyReport({ file: 'lcov.info', ...opts}); + this.lcov = new LcovOnlyReport({ file: 'lcov.info', ...opts }); this.html = new HtmlReport({ subdir: 'lcov-report' }); } } diff --git a/packages/istanbul-reports/lib/lcovonly/index.js b/packages/istanbul-reports/lib/lcovonly/index.js index 6a42f6e6..9819b52b 100644 --- a/packages/istanbul-reports/lib/lcovonly/index.js +++ b/packages/istanbul-reports/lib/lcovonly/index.js @@ -30,6 +30,12 @@ class LcovOnlyReport extends ReportBase { writer.println('TN:'); //no test name writer.println('SF:' + (this.relative ? path.relative(process.cwd(), fc.path) : fc.path)); + writer.println( + 'SF:' + + (this.relative + ? path.relative(process.cwd(), fc.path) + : fc.path) + ); Object.values(functionMap).forEach(meta => { writer.println('FN:' + [meta.decl.start.line, meta.name].join(',')); From 1a0bd50610f27c236f0edb8092b5fc02453e4fa6 Mon Sep 17 00:00:00 2001 From: Baptiste Gallet Date: Mon, 28 Oct 2019 12:30:30 +0100 Subject: [PATCH 3/4] Fix: removed faulty line --- packages/istanbul-reports/lib/lcovonly/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/istanbul-reports/lib/lcovonly/index.js b/packages/istanbul-reports/lib/lcovonly/index.js index 9819b52b..04c23abb 100644 --- a/packages/istanbul-reports/lib/lcovonly/index.js +++ b/packages/istanbul-reports/lib/lcovonly/index.js @@ -28,8 +28,7 @@ class LcovOnlyReport extends ReportBase { const summary = node.getCoverageSummary(); const path = require('path'); - writer.println('TN:'); //no test name - writer.println('SF:' + (this.relative ? path.relative(process.cwd(), fc.path) : fc.path)); + writer.println('TN:'); //no test nam writer.println( 'SF:' + (this.relative From 01b54204efae8bc078d7948d25711b535af08757 Mon Sep 17 00:00:00 2001 From: Baptiste Gallet Date: Wed, 20 Nov 2019 11:59:48 +0100 Subject: [PATCH 4/4] use projectRoot instead of relative option --- packages/istanbul-reports/lib/lcovonly/index.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/istanbul-reports/lib/lcovonly/index.js b/packages/istanbul-reports/lib/lcovonly/index.js index 04c23abb..7aa2a866 100644 --- a/packages/istanbul-reports/lib/lcovonly/index.js +++ b/packages/istanbul-reports/lib/lcovonly/index.js @@ -9,7 +9,7 @@ class LcovOnlyReport extends ReportBase { constructor(opts) { super(); this.file = opts.file || 'lcov.info'; - this.relative = opts.relative || false; + this.projectRoot = opts.projectRoot || process.cwd(); this.contentWriter = null; } @@ -29,12 +29,7 @@ class LcovOnlyReport extends ReportBase { const path = require('path'); writer.println('TN:'); //no test nam - writer.println( - 'SF:' + - (this.relative - ? path.relative(process.cwd(), fc.path) - : fc.path) - ); + writer.println('SF:' + path.relative(this.projectRoot, fc.path)); Object.values(functionMap).forEach(meta => { writer.println('FN:' + [meta.decl.start.line, meta.name].join(','));