Skip to content

Commit

Permalink
changed version gen file to regular js file
Browse files Browse the repository at this point in the history
  • Loading branch information
zachsents authored Oct 24, 2024
1 parent b31c5e8 commit e5fd692
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
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) {
async function createVersionsFile(filename) {
const revision = process.argv[2]
?? (await exec('git rev-parse --short HEAD')).stdout.toString().trim();
const branch = process.argv[3]
Expand All @@ -16,17 +15,17 @@ async function createVersionsFile(filename: string) {
version = 'Latest';
}

console.log(`version: '${process.env.npm_package_version}', revision: '${revision}', branch: '${branch}', version: '${version}'`);
console.log(`revision: '${revision}', branch: '${branch}', version: '${version}'`);

const content = dedent`
// this file is automatically generated by git.version.ts script
export const versions = {
revision: '${revision}',
branch: '${branch}',
version: '${version}'
};`;
const content = `
// this file is automatically generated by git.version.ts script
export const versions = {
revision: '${revision}',
branch: '${branch}',
version: '${version}'
};`;

writeFileSync(filename, content, {encoding: 'utf8'});
}

createVersionsFile('src/environments/versions.ts');
await createVersionsFile('src/environments/versions.ts');
2 changes: 1 addition & 1 deletion SBOLCanvasFrontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "ng build --configuration production --base-href=/canvas/",
"predev": "npm run prebuild",
"dev": "ng serve -o",
"gitversion": "ts-node -O \"{\\\"module\\\":\\\"commonjs\\\"}\" git.version.ts",
"gitversion": "node git.version.js",
"postinstall": "patch-package"
},
"private": true,
Expand Down

0 comments on commit e5fd692

Please sign in to comment.