Skip to content

Commit

Permalink
Use last updated git commit date of coverage files folder
Browse files Browse the repository at this point in the history
  • Loading branch information
howard-e committed Feb 26, 2024
1 parent add0ec5 commit 1bcd295
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"npm run reference-tables",
"git add content/index/index.html",
"npm run coverage-report",
"git add coverage/"
"git add content/about/coverage-and-quality/"
]
},
"ava": {
Expand Down
38 changes: 30 additions & 8 deletions scripts/coverage-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
const glob = require('glob');
const cheerio = require('cheerio');
const HTMLParser = require('node-html-parser');
Expand All @@ -17,6 +18,10 @@ const joinPaths = (...segments) => {
return path.join(...segments).replace(/\\/g, '/');
};

const coverageFilesPath = joinPaths(
__dirname,
'../content/about/coverage-and-quality/'
);
const coverageReportPath = joinPaths(
__dirname,
'../content/about/coverage-and-quality/coverage-and-quality-report.html'
Expand Down Expand Up @@ -1138,15 +1143,32 @@ $('#example_summary_prototype').html(countPrototype);
$('#example_summary_mouse').html(countMouse);
$('#example_summary_pointer').html(countPointer);

// Create a new Date object
var currentDate = new Date();
const getLastModifiedCoverageFilesFormattedDate = () => {
// Create a new Date object using git log date found for coverage-and-quality folder
const output = execSync(
`git log -1 --pretty="format:%cI" ${coverageFilesPath}`,
{ cwd: path.dirname(coverageFilesPath) }
);

// Format the date as a string
const formattedDate = currentDate.toLocaleDateString('en-US', {
day: 'numeric',
month: 'long',
year: 'numeric',
});
let date;
try {
date = new Date(output);
} catch (err) {
console.error(err);
return;
}

// Format the date as a string
const formattedDate = date.toLocaleDateString('en-US', {
day: 'numeric',
month: 'long',
year: 'numeric',
});

return formattedDate;
};

const formattedDate = getLastModifiedCoverageFilesFormattedDate();

// cheerio seems to fold the doctype lines despite the template
const result = $.html()
Expand Down

0 comments on commit 1bcd295

Please sign in to comment.