Skip to content

Commit

Permalink
Merge pull request #20 from AxaGuilDEv/fix/refactor-code
Browse files Browse the repository at this point in the history
fix: reuse utility function
  • Loading branch information
sandydelhoute authored Feb 21, 2023
2 parents c107f1b + a4193f6 commit 62d1ebb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
10 changes: 1 addition & 9 deletions src/reporters/generatorReports.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const fs = require("fs");
const path = require("path");
const folderTemplate = "templates";
const folderTranslate = "translate";
const minify = require("html-minifier").minify;

Expand Down Expand Up @@ -115,13 +114,6 @@ const populateTemplate = async (options, results, htmlPerPageResult) => {
gasesNumberOfVisits: results.gasesNumberOfVisits,
});

const myCss = {
style: fs.readFileSync(
path.join(__dirname, folderTemplate, "./style.css"),
"utf8"
),
};

return ejs.render(template, {
[globalNoteTag]: statusGreen(results.globalNote, options),
[globalPerformanceTag]: performanceBlockTemplate,
Expand All @@ -131,7 +123,7 @@ const populateTemplate = async (options, results, htmlPerPageResult) => {
[htmlPerPageBlock]: htmlPerPageResult,
GlobalGreenItMetrics: GlobalGreenItMetricsTemplate,
Translations: options.translations,
myCss: myCss,
style: readTemplate("./style.css"),
lang: options.lang
});
};
Expand Down
2 changes: 1 addition & 1 deletion src/reporters/readTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const fs = require("fs");
const path = require("path");
const readTemplate = (templateFile) => {
const templatePath = path.join(__dirname, folderTemplate, templateFile);
return fs.readFileSync(templatePath).toString();
return fs.readFileSync(templatePath, "utf-8").toString();
};
module.exports = {
readTemplate,
Expand Down
2 changes: 1 addition & 1 deletion src/reporters/templates/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<body>
<style>
<%- myCss.style %>
<%- style %>
</style>
<article class="lh-root lh-vars lh-screenshot-overlay--enabled">
<div class="lh-header-container">
Expand Down

0 comments on commit 62d1ebb

Please sign in to comment.