aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/version.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-08-03 15:08:36 +0200
committerChocobozzz <me@florianbigard.com>2022-08-03 15:08:36 +0200
commitc795e19663a93c24908a7318975f820bac63164f (patch)
tree149a303be38eedf5aa5a0ec02938f67c75a267fe /server/helpers/version.ts
parentfd59208e8ccd796f9ad7e35db82d0c33acfcb92c (diff)
downloadPeerTube-c795e19663a93c24908a7318975f820bac63164f.tar.gz
PeerTube-c795e19663a93c24908a7318975f820bac63164f.tar.zst
PeerTube-c795e19663a93c24908a7318975f820bac63164f.zip
Automatically rebuild native modules on ABI change
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}