node version logic
This commit is contained in:
@@ -379,18 +379,19 @@ def install_nodejs_from_distro():
|
|||||||
with step("Installing Node.js from distribution repositories"):
|
with step("Installing Node.js from distribution repositories"):
|
||||||
apt_install(["nodejs"])
|
apt_install(["nodejs"])
|
||||||
|
|
||||||
if shutil.which("node"):
|
if not shutil.which("npm"):
|
||||||
node_ver = run_out(["node", "--version"], check=False).strip()
|
apt_try_install(["npm"])
|
||||||
print(f"Node.js: {node_ver}")
|
|
||||||
|
|
||||||
if not shutil.which("npm"):
|
if shutil.which("node"):
|
||||||
apt_try_install(["npm"])
|
node_ver = run_out(["node", "--version"], check=False).strip()
|
||||||
|
print(f"Node.js: {node_ver}")
|
||||||
|
|
||||||
if shutil.which("npm"):
|
if shutil.which("npm"):
|
||||||
npm_ver = run_out(["npm", "--version"], check=False).strip()
|
npm_ver = run_out(["npm", "--version"], check=False).strip()
|
||||||
print(f"npm: {npm_ver}")
|
print(f"npm: {npm_ver}")
|
||||||
return True
|
return True
|
||||||
return False
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def ensure_minimum_nodejs(min_version=MIN_NODEJS_VERSION, user_requested_version=None):
|
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
|
["npm", "--version"], check=False
|
||||||
).strip()
|
).strip()
|
||||||
print(f"Node.js: {node_ver}")
|
print(f"Node.js: {node_ver}")
|
||||||
print(f" npm: {npm_ver}")
|
print(f"npm: {npm_ver}")
|
||||||
else:
|
else:
|
||||||
print(f"Node.js: {node_ver}")
|
print(f"Node.js: {node_ver}")
|
||||||
return True
|
return True
|
||||||
@@ -425,7 +426,7 @@ def ensure_minimum_nodejs(min_version=MIN_NODEJS_VERSION, user_requested_version
|
|||||||
if shutil.which("npm"):
|
if shutil.which("npm"):
|
||||||
npm_ver = run_out(["npm", "--version"], check=False).strip()
|
npm_ver = run_out(["npm", "--version"], check=False).strip()
|
||||||
print(f"Node.js: {node_ver}")
|
print(f"Node.js: {node_ver}")
|
||||||
print(f" npm: {npm_ver}")
|
print(f"npm: {npm_ver}")
|
||||||
else:
|
else:
|
||||||
print(f"Node.js: {node_ver}")
|
print(f"Node.js: {node_ver}")
|
||||||
return True
|
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:
|
if has_nodejs and major and major >= min_version:
|
||||||
print(f"✓ Distribution provides Node.js v{version_str} (>= v{min_version})")
|
print(f"✓ Distribution provides Node.js v{version_str} (>= v{min_version})")
|
||||||
print()
|
|
||||||
if install_nodejs_from_distro():
|
if install_nodejs_from_distro():
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
@@ -476,12 +476,10 @@ def ensure_minimum_nodejs(min_version=MIN_NODEJS_VERSION, user_requested_version
|
|||||||
|
|
||||||
if shutil.which("node"):
|
if shutil.which("node"):
|
||||||
node_ver = run_out(["node", "--version"], check=False).strip()
|
node_ver = run_out(["node", "--version"], check=False).strip()
|
||||||
|
print(f" Node.js: {node_ver}")
|
||||||
if shutil.which("npm"):
|
if shutil.which("npm"):
|
||||||
npm_ver = run_out(["npm", "--version"], check=False).strip()
|
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
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user