From 0d7401b2e3d8865c93aeb1c3d9d9b826e784b6ed Mon Sep 17 00:00:00 2001 From: cenfun Date: Tue, 30 Jul 2024 22:27:03 +0800 Subject: [PATCH] refactor markdown API --- lib/reports/markdown-details.js | 3 +-- lib/reports/markdown-summary.js | 3 +-- lib/utils/markdown.js | 4 ++-- lib/utils/util.js | 6 +++++- package-lock.json | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/reports/markdown-details.js b/lib/reports/markdown-details.js index a9785e93..0e7f4884 100644 --- a/lib/reports/markdown-details.js +++ b/lib/reports/markdown-details.js @@ -1,5 +1,4 @@ const path = require('path'); -const generateMarkdownGrid = require('../utils/markdown.js'); const Util = require('../utils/util.js'); const { getRowData, getFilteredFiles } = require('./console-details.js'); @@ -103,7 +102,7 @@ const markdownDetailsReport = async (reportData, reportOptions, options) => { name: 'Uncovered Lines' }]; - const markdownGrid = generateMarkdownGrid({ + const markdownGrid = Util.markdown({ options: { name: reportData.name }, diff --git a/lib/reports/markdown-summary.js b/lib/reports/markdown-summary.js index e918b790..3f7ea32e 100644 --- a/lib/reports/markdown-summary.js +++ b/lib/reports/markdown-summary.js @@ -1,5 +1,4 @@ const path = require('path'); -const generateMarkdownGrid = require('../utils/markdown.js'); const Util = require('../utils/util.js'); const { getSummaryColumns } = require('./console-summary.js'); @@ -28,7 +27,7 @@ const markdownSummaryReport = async (reportData, reportOptions, options) => { const columns = getSummaryColumns(color); - const markdownGrid = generateMarkdownGrid({ + const markdownGrid = Util.markdown({ options: { name: reportData.name }, diff --git a/lib/utils/markdown.js b/lib/utils/markdown.js index 515ce937..f206325e 100644 --- a/lib/utils/markdown.js +++ b/lib/utils/markdown.js @@ -52,7 +52,7 @@ const renderHyphen = (column) => { return ':'.padEnd(width, '-'); }; -const generateMarkdownGrid = (data) => { +const markdown = (data) => { const options = { name: '', @@ -129,4 +129,4 @@ const generateMarkdownGrid = (data) => { }; -module.exports = generateMarkdownGrid; +module.exports = markdown; diff --git a/lib/utils/util.js b/lib/utils/util.js index de51b19e..d46ff63b 100644 --- a/lib/utils/util.js +++ b/lib/utils/util.js @@ -6,10 +6,13 @@ const os = require('os'); const crypto = require('crypto'); const EC = require('eight-colors'); const CG = require('console-grid'); +const acornWalk = require('acorn-walk'); + const Share = require('../platform/share.js'); const request = require('./request.js'); const version = require('../../package.json').version; -const acornWalk = require('acorn-walk'); +const markdown = require('./markdown.js'); + const { findUpSync, supportsColor } = require('../packages/monocart-coverage-vendor.js'); // https://github.com/chalk/supports-color @@ -29,6 +32,7 @@ const Util = { root: process.cwd(), request, + markdown, relativePath: function(p, root) { p = `${p}`; diff --git a/package-lock.json b/package-lock.json index 98955751..5e75867a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "monocart-coverage-reports", - "version": "2.9.3", + "version": "2.10.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "monocart-coverage-reports", - "version": "2.9.3", + "version": "2.10.0", "license": "MIT", "workspaces": [ "test"