forked from ghostfolio/ghostfolio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreplace.build.js
33 lines (29 loc) · 830 Bytes
/
replace.build.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 dotenv = require('dotenv');
const path = require('path');
const replace = require('replace-in-file');
dotenv.config({
path: path.resolve(__dirname, '.env')
});
const now = new Date();
const buildTimestamp = `${formatWithTwoDigits(
now.getDate()
)}.${formatWithTwoDigits(
now.getMonth() + 1
)}.${now.getFullYear()} ${formatWithTwoDigits(
now.getHours()
)}:${formatWithTwoDigits(now.getMinutes())}`;
try {
const changedFiles = replace.sync({
files: './dist/apps/client/main.*.js',
from: /{BUILD_TIMESTAMP}/g,
to: buildTimestamp,
allowEmptyPaths: false
});
console.log('Build version set: ' + buildTimestamp);
console.log(changedFiles);
} catch (error) {
console.error('Error occurred:', error);
}
function formatWithTwoDigits(aNumber) {
return aNumber < 10 ? '0' + aNumber : aNumber;
}