mod-build 4.0.98-beta.2 → 4.0.98-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/tasks/grab-bbb-logo.js +11 -15
package/package.json
CHANGED
package/tasks/grab-bbb-logo.js
CHANGED
|
@@ -45,8 +45,14 @@ async function fetchBbbSvgMarkup() {
|
|
|
45
45
|
return (await response.text()).trim();
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function
|
|
49
|
-
|
|
48
|
+
function buildBbbSymbol(svgMarkup) {
|
|
49
|
+
const symbol = svgMarkup.replace(/^[\s\S]*?<svg\b/i, '<symbol').replace(/<\/svg>\s*$/i, '</symbol>');
|
|
50
|
+
|
|
51
|
+
if (/^<symbol\b[^>]*\bid\s*=/i.test(symbol)) {
|
|
52
|
+
return symbol;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return symbol.replace(/^<symbol\b/i, '<symbol id="bbb"');
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
async function updateBbbLogo(svgMarkup) {
|
|
@@ -78,26 +84,16 @@ async function updateAccreditedBusinessText() {
|
|
|
78
84
|
|
|
79
85
|
async function updateBbbInSprite(svgMarkup) {
|
|
80
86
|
const spriteFiles = walkFiles(process.cwd(), (_fullPath, fileName) => fileName === 'sprite.svg');
|
|
81
|
-
const
|
|
87
|
+
const updatedSymbol = buildBbbSymbol(svgMarkup);
|
|
82
88
|
|
|
83
89
|
for (const spritePath of spriteFiles) {
|
|
84
90
|
const contents = fs.readFileSync(spritePath, 'utf8');
|
|
85
|
-
const symbolMatch = contents.match(bbbSymbolRegex);
|
|
86
|
-
|
|
87
|
-
if (!symbolMatch) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
const openTagMatch = existingSymbol.match(/^<symbol\b[^>]*>/i);
|
|
93
|
-
|
|
94
|
-
if (!openTagMatch) {
|
|
92
|
+
if (!bbbSymbolRegex.test(contents)) {
|
|
95
93
|
continue;
|
|
96
94
|
}
|
|
97
95
|
|
|
98
|
-
const
|
|
99
|
-
const updatedContents = contents.replace(existingSymbol, updatedSymbol);
|
|
100
|
-
|
|
96
|
+
const updatedContents = contents.replace(bbbSymbolRegex, updatedSymbol);
|
|
101
97
|
fs.writeFileSync(spritePath, updatedContents, 'utf8');
|
|
102
98
|
console.log(`Updated BBB symbol in sprite: ${spritePath}`);
|
|
103
99
|
}
|