aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/version.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/version.ts')
-rw-r--r--server/helpers/version.ts36
1 files changed, 36 insertions, 0 deletions
diff --git a/server/helpers/version.ts b/server/helpers/version.ts
new file mode 100644
index 000000000..5b3bf59dd
--- /dev/null
+++ b/server/helpers/version.ts
@@ -0,0 +1,36 @@
1import { execPromise, execPromise2 } from './core-utils'
2import { logger } from './logger'
3
4async function getServerCommit () {
5 try {
6 const tag = await execPromise2(
7 '[ ! -d .git ] || git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || true',
8 { stdio: [ 0, 1, 2 ] }
9 )
10
11 if (tag) return tag.replace(/^v/, '')
12 } catch (err) {
13 logger.debug('Cannot get version from git tags.', { err })
14 }
15
16 try {
17 const version = await execPromise('[ ! -d .git ] || git rev-parse --short HEAD')
18
19 if (version) return version.toString().trim()
20 } catch (err) {
21 logger.debug('Cannot get version from git HEAD.', { err })
22 }
23
24 return ''
25}
26
27function getNodeABIVersion () {
28 const version = process.versions.modules
29
30 return parseInt(version)
31}
32
33export {
34 getServerCommit,
35 getNodeABIVersion
36}