in aws_lambda_builders/workflows/nodejs_npm/workflow.py [0:0]
def can_use_install_links(npm_process: SubprocessNpm) -> bool:
"""
Checks the version of npm that is currently installed to determine
whether or not --install-links can be used
Parameters
----------
npm_process: SubprocessNpm
Object containing helper methods to call the npm process
Returns
-------
bool
True if the current npm version meets the minimum for --install-links
"""
try:
current_version = npm_process.run(["--version"])
LOG.debug(f"Currently installed version of npm is: {current_version}")
current_version = current_version.split(".")
major_version = int(current_version[0])
minor_version = int(current_version[1])
except (ValueError, IndexError):
LOG.debug(f"Failed to parse {current_version} output from npm for --install-links validation")
return False
is_older_major_version = major_version < MINIMUM_NPM_VERSION_INSTALL_LINKS[0]
is_older_patch_version = (
major_version == MINIMUM_NPM_VERSION_INSTALL_LINKS[0]
and minor_version < MINIMUM_NPM_VERSION_INSTALL_LINKS[1]
)
return not (is_older_major_version or is_older_patch_version)