You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
963 B
26 lines
963 B
import { writeFileSync } from 'fs';
|
|
import { dedent } from 'tslint/lib/utils';
|
|
import { promisify } from 'util';
|
|
import * as child from 'child_process';
|
|
const exec = promisify(child.exec);
|
|
|
|
async function createVersionsFile(filename: string) {
|
|
const tag = (await exec('git describe --tags')).stdout.toString().trim();
|
|
const revision = (await exec('git rev-parse --short HEAD')).stdout.toString().trim();
|
|
const branch = (await exec('git rev-parse --abbrev-ref HEAD')).stdout.toString().trim();
|
|
|
|
console.log(`version: '${process.env.npm_package_version}', revision: '${revision}', branch: '${branch}'`);
|
|
|
|
const content = dedent`
|
|
// this file is automatically generated by git.version.ts script
|
|
export const versions = {
|
|
version: '${tag}',
|
|
revision: '${revision}',
|
|
branch: '${branch}'
|
|
};`;
|
|
|
|
writeFileSync(filename, content, {encoding: 'utf8'});
|
|
}
|
|
|
|
createVersionsFile('src/environments/versions.ts');
|