fix: use new commit tag file for app version as well

This commit is contained in:
sct
2020-12-27 17:22:21 +00:00
parent 55f9e41f1b
commit d00e470b55
2 changed files with 20 additions and 15 deletions

View File

@@ -1,3 +1,20 @@
import { existsSync } from 'fs';
import path from 'path';
import logger from '../logger';
const COMMIT_TAG_PATH = path.join(__dirname, '../../committag.json');
let commitTag = 'local';
if (existsSync(COMMIT_TAG_PATH)) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
commitTag = require(COMMIT_TAG_PATH).commitTag;
logger.info(`Commit Tag: ${commitTag}`);
}
export const getCommitTag = (): string => {
return commitTag;
};
export const getAppVersion = (): string => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { version } = require('../../package.json');
@@ -5,7 +22,7 @@ export const getAppVersion = (): string => {
let finalVersion = version;
if (version === '0.1.0') {
finalVersion = `develop-${process.env.COMMIT_TAG ?? 'local'}`;
finalVersion = `develop-${getCommitTag()}`;
}
return finalVersion;