0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/tools/getnodeversion.py
Christian Clauss 06929956f9 tools: cleanup getnodeversion.py for readability
PR-URL: https://github.com/nodejs/node/pull/29648
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-09-23 12:06:47 -07:00

22 lines
676 B
Python

from __future__ import print_function
import os
def get_major_minor_patch(text):
for line in text.splitlines():
if line.startswith('#define NODE_MAJOR_VERSION'):
major = line.split()[2]
elif line.startswith('#define NODE_MINOR_VERSION'):
minor = line.split()[2]
elif line.startswith('#define NODE_PATCH_VERSION'):
patch = line.split()[2]
return major, minor, patch
node_version_h = os.path.join(os.path.dirname(__file__),
'..',
'src',
'node_version.h')
with open(node_version_h) as in_file:
print('.'.join(get_major_minor_patch(in_file.read())))