2019-01-22 19:40:43 -05:00
|
|
|
_zimfw_upgrade() {
|
2020-01-02 13:05:53 -05:00
|
|
|
local -r ztarget=${ZIM_HOME}/zimfw.zsh
|
2020-01-11 17:17:09 -05:00
|
|
|
local -r zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz
|
2019-12-01 16:00:47 -05:00
|
|
|
{
|
2020-01-11 16:35:59 -05:00
|
|
|
if (( ${+commands[curl]} )); then
|
2020-07-23 22:49:39 -04:00
|
|
|
command curl -fsSL -o ${ztarget}.new.gz ${zurl} || return 1
|
2020-01-11 16:35:59 -05:00
|
|
|
else
|
2020-01-11 16:23:11 -05:00
|
|
|
local zopt
|
2020-02-03 20:43:36 -05:00
|
|
|
if (( _zprintlevel <= 1 )) zopt='-q'
|
2020-07-23 22:49:39 -04:00
|
|
|
if ! command wget -nv ${zopt} -O ${ztarget}.new.gz ${zurl}; then
|
2020-02-03 20:43:36 -05:00
|
|
|
if (( _zprintlevel <= 1 )) print -u2 -PR "%F{red}<%= error %>Error downloading %B${zurl}%b. Use %B-v%b option to see details.%f"
|
2020-01-11 16:23:11 -05:00
|
|
|
return 1
|
|
|
|
fi
|
2019-12-01 16:00:47 -05:00
|
|
|
fi
|
2020-07-23 22:49:39 -04:00
|
|
|
command gunzip -f ${ztarget}.new.gz || return 1
|
2020-01-20 07:03:20 -05:00
|
|
|
# .latest_version can be outdated and will yield a false warning if zimfw is
|
|
|
|
# upgraded before .latest_version is refreshed. Bad thing about having a cache.
|
|
|
|
_zimfw_mv ${ztarget}{.new,} && command rm -f ${ZIM_HOME}/.latest_version && \
|
|
|
|
_zimfw_print -P '<%= done %>Done with upgrade.'
|
2019-12-01 16:00:47 -05:00
|
|
|
} always {
|
2020-07-23 22:49:39 -04:00
|
|
|
command rm -f ${ztarget}.new{,.gz}
|
2019-12-01 16:00:47 -05:00
|
|
|
}
|
2019-01-22 19:40:43 -05:00
|
|
|
}
|