-
Notifications
You must be signed in to change notification settings - Fork 27
/
time-stamper.js
33 lines (29 loc) · 1.03 KB
/
time-stamper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const fs = require('fs');
const path = require('path');
const {JSDOM} = require('jsdom');
const filePath = path.join(__dirname, 'index.html');
const buildDate = new Date();
const timestampString = `Last Update: ${buildDate.toLocaleString('tr-TR', { timeZone: 'Europe/Athens' })} (Türkiye)`;
fs.readFile(filePath, 'utf-8', (err, data) => {
if (err) {
console.error('Error reading the HTML file:', err);
return;
}
const dom = new JSDOM(data);
const document = dom.window.document;
const timestampElement = document.getElementById('build-timestamp');
if (timestampElement) {
timestampElement.textContent = timestampString;
} else {
console.error('Element with ID "build-timestamp" not found.');
return;
}
const updatedHtml = dom.serialize();
fs.writeFile(filePath, updatedHtml, 'utf8', (err) => {
if (err) {
console.error('Error writing the HTML file:', err);
return;
}
console.log('Timestamp added successfully!');
});
});