-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-revision.js
More file actions
53 lines (46 loc) · 1.32 KB
/
update-revision.js
File metadata and controls
53 lines (46 loc) · 1.32 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Copyright (c) 2026 Stuart Donaldson. Licensed under the MIT License.
* See LICENSE file for details.
*/
const fs = require('fs');
const path = require('path');
// Get current date and time in format "Feb 3, 2026 14:30"
const now = new Date();
const dateStr = now.toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
year: 'numeric'
});
const timeStr = now.toLocaleTimeString('en-US', {
hour: '2-digit',
minute: '2-digit',
hour12: false
});
const currentDateTime = `${dateStr} ${timeStr}`;
const versionPath = path.join(__dirname, 'src', 'version.html');
// Read the file
fs.readFile(versionPath, 'utf8', (err, data) => {
if (err) {
console.error('Error reading version.html:', err);
process.exit(1);
}
// Replace the version string
const updatedData = data.replace(
/version: "[^"]*"/,
`version: "v1.0 (Rev. ${currentDateTime})"`
);
// Also update buildDate with full ISO datetime
const buildDateStr = now.toISOString();
const updatedData2 = updatedData.replace(
/buildDate: "[^"]*"/,
`buildDate: "${buildDateStr}"`
);
// Write back
fs.writeFile(versionPath, updatedData2, 'utf8', (err) => {
if (err) {
console.error('Error writing version.html:', err);
process.exit(1);
}
console.log(`Revision date/time updated to: ${currentDateTime}`);
});
});