1
0
Fork 0
mirror of synced 2024-05-24 11:10:30 -04:00
zimfw/src/stage2/50_zimfw_upgrade.zsh.erb
Eric Nielsen 6806bea72e
Download latest release instead of from master
Using GitHub URL to latest release asset as described in
https://help.github.com/en/github/administering-a-repository/linking-to-releases#linking-to-the-latest-release

There's a counter of release assets downloads, which is nice.
Download zimfw.zsh when installing, and zimfw.zsh.gz when upgrading, so
we can have separate counts.
2020-01-12 17:37:39 -05:00

21 lines
764 B
Plaintext

_zimfw_upgrade() {
local -r ztarget=${ZIM_HOME}/zimfw.zsh
local -r zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz
{
setopt LOCAL_OPTIONS PIPE_FAIL
if (( ${+commands[curl]} )); then
command curl -fsSL ${zurl} | command gunzip > ${ztarget}.new || return 1
else
local zopt
(( _zprintlevel <= 1 )) && zopt='-q'
if ! command wget -nv ${zopt} -O - ${zurl} | command gunzip > ${ztarget}.new; then
(( _zprintlevel <= 1 )) && print -u2 -PR "%F{red}<%= error %>Error downloading %B${zurl}%b. Use %B-v%b option to see details.%f"
return 1
fi
fi
_zimfw_mv ${ztarget}{.new,} && _zimfw_print -P '<%= done %>Done with upgrade.'
} always {
command rm -f ${ztarget}.new
}
}