chore: pull CLI git rev and version into about dialog

This commit is contained in:
Randall Morey committed 2021-02-02 12:03:50 -05:00
1 parent c40068f211
commit 8e3241d7fd
3 files changed
+32 -4

No files matched your search

+15 -1
View File
@@ -1,5 +1,5 @@
const path = require('path');
const { spawnAsyncJSONPromise } = require('./spawn-promise');
const { spawnAsyncJSONPromise, spawnSync } = require('./spawn-promise');
const cliPath = async () => path.resolve(__dirname, '..', 'cli', 'boundary');
@@ -17,5 +17,19 @@ module.exports = {
'--output-json-errors'
];
return spawnAsyncJSONPromise(command);
},
// Returns JSON-formatted version information from the CLI
version: () => {
const command = [ '-v' ];
const rawOutput = spawnSync(command);
let gitRevision = /Git Revision:\s*(?<rev>.*)\n/.exec(rawOutput);
let versionNumber = /Version Number:\s*(?<ver>.*)\n/.exec(rawOutput);
if (gitRevision) gitRevision = gitRevision.groups.rev;
if (versionNumber) versionNumber = versionNumber.groups.ver;
const formatted = versionNumber
? `CLI Version ${versionNumber}; Git Rev ${gitRevision}`
: `CLI Git Rev ${gitRevision}`;
return { gitRevision, versionNumber, formatted };
return rawOutput;
}
}