Skip to content

Commit

Permalink
fix: track commented out stylesheet helpers, when retrieving css file…
Browse files Browse the repository at this point in the history
…s from templates
  • Loading branch information
jairo-bc committed Feb 14, 2024
1 parent 3e43256 commit 6b402e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/StylesheetsFileResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ const path = require('path');
const cheerio = require('cheerio');
const recursiveReadDir = require('recursive-readdir');

const STYLESHEET_REGEXP = /{{\s*stylesheet\s*([\/a-zA-Z'"\.-]+)\s*}}/gi;
const STYLESHEET_REGEXP = /{{\s*stylesheet\s*([\/a-zA-Z'"\.-]+)\s*/gi;

class StylesheetsFileResolver {
constructor(themePath) {
this.themePath = themePath;
this.alreadyExlcudedComments = [];
}

async get() {
Expand Down Expand Up @@ -47,7 +48,8 @@ class StylesheetsFileResolver {
});
for (const comment of comments) {
const { data } = comment;
if (data && data.includes('stylesheet') && data.includes(cssFilePath)) {
if (data && data.includes('stylesheet') && data.includes(cssFilePath) && !this.alreadyExlcudedComments.includes(data)) {
this.alreadyExlcudedComments.push(data);
return true;
}
}
Expand Down
1 change: 1 addition & 0 deletions test/mocks/themes/invalid/templates/pages/page2.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title>page2.html</title>
{{head.scripts}}
{{ stylesheet "assets/css/test.css" }}
/* {{ stylesheet "assets/css/test.css" }} */
/* {{ stylesheet "assets/css/commented.css" }} */
</head>
<body>
Expand Down

0 comments on commit 6b402e8

Please sign in to comment.