node version logic

This commit is contained in:
Mateusz Gruszczyński
2025-10-26 19:07:23 +01:00
parent 47439874ac
commit 641f98dc4e

View File

@@ -379,18 +379,19 @@ def install_nodejs_from_distro():
with step("Installing Node.js from distribution repositories"):
apt_install(["nodejs"])
if shutil.which("node"):
node_ver = run_out(["node", "--version"], check=False).strip()
print(f"Node.js: {node_ver}")
if not shutil.which("npm"):
apt_try_install(["npm"])
if not shutil.which("npm"):
apt_try_install(["npm"])
if shutil.which("node"):
node_ver = run_out(["node", "--version"], check=False).strip()
print(f"Node.js: {node_ver}")
if shutil.which("npm"):
npm_ver = run_out(["npm", "--version"], check=False).strip()
print(f"npm: {npm_ver}")
return True
return False
if shutil.which("npm"):
npm_ver = run_out(["npm", "--version"], check=False).strip()
print(f"npm: {npm_ver}")
return True
return False
def ensure_minimum_nodejs(min_version=MIN_NODEJS_VERSION, user_requested_version=None):
@@ -416,7 +417,7 @@ def ensure_minimum_nodejs(min_version=MIN_NODEJS_VERSION, user_requested_version
["npm", "--version"], check=False
).strip()
print(f"Node.js: {node_ver}")
print(f" npm: {npm_ver}")
print(f"npm: {npm_ver}")
else:
print(f"Node.js: {node_ver}")
return True
@@ -425,7 +426,7 @@ def ensure_minimum_nodejs(min_version=MIN_NODEJS_VERSION, user_requested_version
if shutil.which("npm"):
npm_ver = run_out(["npm", "--version"], check=False).strip()
print(f"Node.js: {node_ver}")
print(f" npm: {npm_ver}")
print(f"npm: {npm_ver}")
else:
print(f"Node.js: {node_ver}")
return True
@@ -460,7 +461,6 @@ def ensure_minimum_nodejs(min_version=MIN_NODEJS_VERSION, user_requested_version
if has_nodejs and major and major >= min_version:
print(f"✓ Distribution provides Node.js v{version_str} (>= v{min_version})")
print()
if install_nodejs_from_distro():
return True
else:
@@ -476,12 +476,10 @@ def ensure_minimum_nodejs(min_version=MIN_NODEJS_VERSION, user_requested_version
if shutil.which("node"):
node_ver = run_out(["node", "--version"], check=False).strip()
print(f" Node.js: {node_ver}")
if shutil.which("npm"):
npm_ver = run_out(["npm", "--version"], check=False).strip()
print(f"Node.js: {node_ver}")
print(f" npm: {npm_ver}")
else:
print(f"Node.js: {node_ver}")
print(f" npm: {npm_ver}")
return True
return False