diff options
author | Christian Clauss <cclauss@me.com> | 2019-09-21 22:54:27 +0300 |
---|---|---|
committer | Sam Roberts <vieuxtech@gmail.com> | 2019-09-23 22:06:47 +0300 |
commit | 06929956f9c438d29ca127d8be147e7969bfae35 (patch) | |
tree | 9747ebd2ceb6cacf9335e09d11ca7e4af256cef7 /tools/getnodeversion.py | |
parent | cbd3a1cb77f7cb969223bb61edcbd65352f81426 (diff) |
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>
Diffstat (limited to 'tools/getnodeversion.py')
-rw-r--r-- | tools/getnodeversion.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/tools/getnodeversion.py b/tools/getnodeversion.py index c9f82160c0f..b362950dd36 100644 --- a/tools/getnodeversion.py +++ b/tools/getnodeversion.py @@ -1,21 +1,21 @@ from __future__ import print_function import os -import re -node_version_h = os.path.join( - os.path.dirname(__file__), - '..', - 'src', - 'node_version.h') -f = open(node_version_h) +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 -for line in f: - if re.match('^#define NODE_MAJOR_VERSION', line): - major = line.split()[2] - if re.match('^#define NODE_MINOR_VERSION', line): - minor = line.split()[2] - if re.match('^#define NODE_PATCH_VERSION', line): - patch = line.split()[2] -print('%(major)s.%(minor)s.%(patch)s'% locals()) +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()))) |