Skip to content

Commit

Permalink
add page last updated to coverage-report template
Browse files Browse the repository at this point in the history
  • Loading branch information
ariellalgilmore committed Feb 12, 2024
1 parent 318c011 commit bf79705
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scripts/coverage-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1138,12 +1138,26 @@ $('#example_summary_prototype').html(countPrototype);
$('#example_summary_mouse').html(countMouse);
$('#example_summary_pointer').html(countPointer);

// Create a new Date object
var currentDate = new Date();

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

// cheerio seems to fold the doctype lines despite the template
const result = $.html()
.replace('<!DOCTYPE html>', '<!DOCTYPE html>\n')
.replace(
'<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">',
'<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">\n'
)
.replace(
'<p>Page last updated: </p>',
`<p> Page last updated: ${formattedDate}</p>`
);

fs.writeFile(coverageReportPath, result, function (err) {
Expand Down
1 change: 1 addition & 0 deletions scripts/coverage-report.template
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<body>
<main>
<h1>Coverage and Quality Reports</h1>
<p>Page last updated: </p>
<section>
<h2>About These Reports</h2>
<p>
Expand Down

0 comments on commit bf79705

Please sign in to comment.