forked from damoeb/rss-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-info.js
39 lines (27 loc) · 978 Bytes
/
build-info.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
34
35
36
37
38
39
const { writeFileSync } = require('fs');
// based on git.version.ts from https://stackoverflow.com/a/42199863
const { exec } = require('child_process');
async function createVersionsFile(filename) {
exec('git rev-parse --short HEAD', (error, stdout, stderr) => {
if (error) {
console.error(error);
return;
}
const revision = stdout.toString().trim();
exec('git rev-parse --abbrev-ref HEAD', (error, stdout, stderr) => {
if (error) {
console.error(error);
return;
}
const branch = stdout.toString().trim();
console.log(`version: '${process.env.npm_package_version}', revision: '${revision}', branch: '${branch}'`);
const content = `{
"version": "${process.env.npm_package_version}",
"revision": "${revision}",
"date": "${new Date().getTime()}"
}`;
writeFileSync(filename, content, {encoding: 'utf8'});
});
});
}
createVersionsFile(process.argv[2]);