mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 04:42:57 +00:00
Fix: robust version hash injection in build process
Replaced the fragile regex-based version injection in `scripts/build-dist.mjs` with a robust placeholder method. - Added `<!-- VERSION_INFO -->` placeholder to `index.html`. - Updated `scripts/build-dist.mjs` to target the placeholder, while retaining regex fallback for safety. - Ensures version info is reliably injected during local builds regardless of code formatting. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
93d9bb7585
commit
53c0e9e8f4
4 files changed
+33
-20
No files matched your search
+13
-5
@@ -171,14 +171,22 @@ function injectVersionInfo() {
|
||||
v: ${hash.slice(0, 8)} • ${date}
|
||||
</div>`;
|
||||
|
||||
// Fallback search if whitespace differs
|
||||
const taglineRegex = /(seed\. zap\. subscribe\.\s*<\/h2>)/;
|
||||
if (taglineRegex.test(content)) {
|
||||
content = content.replace(taglineRegex, '$1' + versionHtml);
|
||||
// Robust replacement using explicit comment placeholder
|
||||
const placeholder = '<!-- VERSION_INFO -->';
|
||||
if (content.includes(placeholder)) {
|
||||
content = content.replace(placeholder, versionHtml);
|
||||
fs.writeFileSync(indexHtmlPath, content);
|
||||
console.log(`Injected version: ${hash.slice(0, 8)} • ${date}`);
|
||||
} else {
|
||||
console.warn('Could not find tagline to inject version info.');
|
||||
// Fallback search if placeholder is missing (legacy behavior)
|
||||
const taglineRegex = /(seed\. zap\. subscribe\.\s*<\/h2>)/;
|
||||
if (taglineRegex.test(content)) {
|
||||
content = content.replace(taglineRegex, '$1' + versionHtml);
|
||||
fs.writeFileSync(indexHtmlPath, content);
|
||||
console.log(`Injected version (via fallback regex): ${hash.slice(0, 8)} • ${date}`);
|
||||
} else {
|
||||
console.warn('Could not find placeholder or tagline to inject version info.');
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user