Skip to content

Commit

Permalink
Fix version discovery; #356, #357 (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekalinin committed Jun 4, 2024
1 parent 9d74cd8 commit 69e310a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nodeenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ def parse_version(version_str):
"""
Parse version string to a tuple of integer parts
"""
return tuple(map(int, version_str.replace('v', '').split('.')))
v = version_str.replace('v', '').split('.')[:3]
# remove all after '+' in the PATCH part of the version
if len(v) >= 3:
v[2] = v[2].split('+')[0]
return tuple(map(int, v))


def node_version_from_args(args):
Expand Down
6 changes: 6 additions & 0 deletions tests/nodeenv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,9 @@ def test__download_node_file():
n_attempt=5
)
assert m_urlopen.call_count == 5


def test_parse_version():
assert nodeenv.parse_version("v21.7") == (21, 7)
assert nodeenv.parse_version("v21.7.3") == (21, 7, 3)
assert nodeenv.parse_version("v21.7.3+0-b20240228T18452699") == (21, 7, 3)

0 comments on commit 69e310a

Please sign in to comment.