1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

Merge pull request #90 from fdncred/update_get_latest_linux

updated to follow redirects as in 0.36.0
This commit is contained in:
Darren Schroeder 2021-08-27 08:53:55 -05:00 committed by GitHub
commit 161bd55c99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
# A small script to auto-update nushell in linux
# WIP - Not finished yet
def get-latest [] {
# requires nushell 0.36.0 or greater
def get-latest-linux [] {
# fetch the information about the latest release
let metadata = (fetch https://api.github.com/repos/nushell/nushell/releases/latest)
let release_name = ($metadata | get name | split row ' ' | nth 0)
@ -13,15 +13,11 @@ def get-latest [] {
let file_name = ($asset_info | get name)
# tell you what i'm doing
$"Release name is ($release_name)(char newline)(char newline)"
$"($body)(char newline)(char newline)Downloading..."
# fetch doesn't appear to follow redirects so get the actual download url
let redirected_url = (fetch $download_url --raw)
# pull the download url out with xpath, thank you!
let real_download_url = ($redirected_url | xpath '//@href' | get '//@href')
# now do the real download of the archive
fetch $real_download_url | save $file_name
$"($body)(char newline)(char newline)Downloading and following redirects ..."
# fetch follows redirects now
fetch $download_url | save $file_name
# tell you what i'm doing
$"Extracting ($file_name) to /tmp(char newline)"
$"(char newline)Extracting ($file_name) to /tmp(char newline)"
# extract the tar file to the temp folder
tar -xf ($file_name) -C /tmp
# parse the $file_name to get the folder