mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
22 lines
538 B
Python
22 lines
538 B
Python
"""Utility functions for frontend-related tasks."""
|
|
|
|
# Standard Library
|
|
import shutil
|
|
import subprocess
|
|
|
|
|
|
def get_node_version() -> int:
|
|
"""Get the system's NodeJS version."""
|
|
node_path = shutil.which("node")
|
|
|
|
raw_version = subprocess.check_output( # noqa: S603
|
|
[node_path, "--version"]
|
|
).decode()
|
|
|
|
# Node returns the version as 'v14.5.0', for example. Remove the v.
|
|
version = raw_version.replace("v", "")
|
|
# Parse the version parts.
|
|
major, minor, patch = version.split(".")
|
|
|
|
return int(major)
|