-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-version.js
26 lines (22 loc) · 884 Bytes
/
git-version.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
const { gitDescribeSync } = require('git-describe');
const { version } = require('./package.json');
const { resolve, relative } = require('path');
const { writeFileSync, existsSync, mkdirSync } = require('fs-extra');
const gitInfo = gitDescribeSync({
dirtyMark: false,
dirtySemver: false,
customArguments: ['--tags']
});
console.log(gitInfo);
gitInfo.version = version;
if (!existsSync(__dirname + '/src/environments')) {
mkdirSync(__dirname + '/src/environments');
}
const file = resolve(__dirname, 'src', 'environments', 'version.ts');
writeFileSync(file,
`// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
/* tslint:disable */
export const VERSION = ${JSON.stringify(gitInfo, null, 4)};
/* tslint:enable */
`, { encoding: 'utf-8' });
console.log(`Wrote version info ${gitInfo.raw} to ${relative(resolve(__dirname, '..'), file)}`);