1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-18 11:53:59 -05:00

Refactor release_url to take platform as an argument

This commit is contained in:
Andy Hayden 2018-08-31 23:04:47 -07:00 committed by Ryan Dahl
parent c0ef797fc9
commit 89dddca3b4

View file

@ -27,11 +27,11 @@ FILENAME_LOOKUP = {
} }
def latest_release_url(): def release_url(platform):
try: try:
filename = FILENAME_LOOKUP[sys.platform] filename = FILENAME_LOOKUP[platform]
except KeyError: except KeyError:
print("Unable to locate appropriate filename for", sys.platform) print("Unable to locate appropriate filename for", platform)
sys.exit(1) sys.exit(1)
html = urlopen(RELEASES_URL).read().decode('utf-8') html = urlopen(RELEASES_URL).read().decode('utf-8')
@ -49,7 +49,7 @@ def main():
bin_dir = deno_bin_dir() bin_dir = deno_bin_dir()
exe_fn = os.path.join(bin_dir, "deno") exe_fn = os.path.join(bin_dir, "deno")
url = latest_release_url() url = release_url(sys.platform)
print("Downloading", url) print("Downloading", url)
compressed = urlopen(url).read() compressed = urlopen(url).read()
@ -80,11 +80,11 @@ def mkdir(d):
def deno_bin_dir(): def deno_bin_dir():
home = os.path.expanduser("~") home = os.path.expanduser("~")
d = os.path.join(home, ".deno") deno = os.path.join(home, ".deno")
mkdir(d) mkdir(deno)
b = os.path.join(d, "bin") deno_bin = os.path.join(deno, "bin")
mkdir(b) mkdir(deno_bin)
return b return deno_bin
if __name__ == '__main__': if __name__ == '__main__':