add download_npm_package
This commit is contained in:
@@ -1,16 +1,22 @@
|
|||||||
from os import system
|
from os import system
|
||||||
from re import findall, match, search
|
from re import findall
|
||||||
from sys import argv
|
from sys import argv
|
||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
def npm_create_package_lock_file(package):
|
def npm_create_package_lock_file(package):
|
||||||
system("npm i --package-lock-only " + package)
|
system("npm i --package-lock-only " + package)
|
||||||
|
|
||||||
|
|
||||||
def get_all_urls_packages():
|
def get_all_urls_packages():
|
||||||
return list(dict.fromkeys(findall("https://.+.tgz", open("package-lock.json", "rt").read())))
|
with open("package-lock.json", "rt") as package_lock_file:
|
||||||
|
content = package_lock_file.read()
|
||||||
|
return list(dict.fromkeys(findall("https://.+.tgz", content)))
|
||||||
|
|
||||||
|
|
||||||
|
def download_npm_package(url:str):
|
||||||
|
with open(url.split("/")[-1], "wb") as npm_package_file:
|
||||||
|
npm_package_file.write(requests.get(url))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Reference in New Issue
Block a user