Add support for npm

main
Micke Nordin 3 years ago
parent 7a904e57fe
commit edea918f77
Signed by: micke
GPG Key ID: 0DA0A7A5708FE257

@ -67,6 +67,8 @@ def parse_packages(provider: str, input: str) -> list[dict]:
second_pass = first_pass.split('-') second_pass = first_pass.split('-')
package = second_pass[0] package = second_pass[0]
version = "-".join(second_pass[1:]) version = "-".join(second_pass[1:])
case "npm":
package, version = line.split(':')
case "pip": case "pip":
package, version = line.split('==') package, version = line.split('==')
case "ubuntu": case "ubuntu":
@ -107,11 +109,15 @@ def get_packages(image: str, hash: dict) -> list[dict]:
(output, _) = run_command_in_image(image, command) (output, _) = run_command_in_image(image, command)
(pip_output, _) = run_command_in_image(image, ["sh", "-c", "python3 -m pip list --format freeze || true"]) (pip_output, _) = run_command_in_image(image, ["sh", "-c", "python3 -m pip list --format freeze || true"])
(npm_output, _) = run_command_in_image(image, ["sh", "-c", "npm ls -p -l || true"])
os_result = parse_packages(os, output.decode()) os_result = parse_packages(os, output.decode())
result = result + os_result result = result + os_result
if pip_output: if pip_output:
pip_result = parse_packages("pip", pip_output.decode()) pip_result = parse_packages("pip", pip_output.decode())
result += pip_result result += pip_result
if npm_output:
npm_result = parse_packages("npm", npm_output.decode())
result += npm_result
return result return result
if __name__ == "__main__": if __name__ == "__main__":

Loading…
Cancel
Save