-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgit.versions.ts
More file actions
34 lines (29 loc) · 1.02 KB
/
git.versions.ts
File metadata and controls
34 lines (29 loc) · 1.02 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
const { gitDescribeSync } = require('git-describe');
const { writeFileSync, existsSync, readFileSync } = require('fs');
let versionInfo: any;
const p = JSON.parse(readFileSync('package.json', 'utf8'));
if (p.version) {
const version = {
semver: {
version: p.version,
},
};
versionInfo = JSON.stringify(version, null, 2);
} else if (existsSync('.git')) {
const gitInfo = gitDescribeSync();
versionInfo = JSON.stringify(gitInfo, null, 2);
} else {
const version = {
hash: process.env.GIT_REV,
semver: {
version: process.env.TRAVIS_TAG,
},
};
versionInfo = JSON.stringify(version, null, 2);
}
versionInfo = `export const version = ${versionInfo}`;
writeFileSync('apps/geomat/src/environments/version.ts', versionInfo);
writeFileSync('apps/dive/src/environments/version.ts', versionInfo);
writeFileSync('apps/ais/src/environments/version.ts', versionInfo);
writeFileSync('apps/planty/src/environments/version.ts', versionInfo);
writeFileSync('apps/wabe/src/environments/version.ts', versionInfo);