From a24d382eb61959e7cc309ea00ca906ca8c30cda3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Brand=C3=A9ho?= Date: Sat, 6 May 2023 00:57:29 +0200 Subject: [PATCH] use version.parse in check_node_version() (#951) --- pynecone/utils/prerequisites.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pynecone/utils/prerequisites.py b/pynecone/utils/prerequisites.py index 9b9b52b84..11b83633f 100644 --- a/pynecone/utils/prerequisites.py +++ b/pynecone/utils/prerequisites.py @@ -21,7 +21,7 @@ from pynecone.config import get_config from pynecone.utils import console, path_ops -def check_node_version(min_version): +def check_node_version(min_version=constants.MIN_NODE_VERSION): """Check the version of Node.js. Args: @@ -35,10 +35,10 @@ def check_node_version(min_version): result = subprocess.run( ["node", "-v"], stdout=subprocess.PIPE, stderr=subprocess.PIPE ) - # The output will be in the form "vX.Y.Z", so we can split it on the "v" character and take the second part - version = result.stdout.decode().strip().split("v")[1] + # The output will be in the form "vX.Y.Z", but version.parse() can handle it + current_version = version.parse(result.stdout.decode()) # Compare the version numbers - return version.split(".") >= min_version.split(".") + return current_version >= version.parse(min_version) except Exception: return False @@ -73,7 +73,7 @@ def get_package_manager() -> str: config = get_config() # Check that the node version is valid. - if not check_node_version(constants.MIN_NODE_VERSION): + if not check_node_version(): console.print( f"[red]Node.js version {constants.MIN_NODE_VERSION} or higher is required to run Pynecone." )