1
0
Fork 0
mirror of synced 2024-06-01 06:41:12 -04:00
zimfw/src/tools/install.zsh.erb
Eric Nielsen 3567694a0f
Use repository's default branch
instead of hardcoding the default to `master`, when no branch is
specified in `zmodule`.
Fixes #422
2021-01-02 19:09:52 -05:00

19 lines
616 B
Plaintext

# This runs in a new shell
readonly MODULE=${1}
readonly DIR=${2}
readonly URL=${3}
readonly BRANCH=${5:+-b ${5}}
readonly -i PRINTLEVEL=${6}
readonly CLEAR_LINE=$'\E[2K\r'
if [[ -e ${DIR} ]]; then
# Already exists
return 0
fi
if (( PRINTLEVEL > 0 )) print -Rn ${CLEAR_LINE}"Installing ${MODULE}<%= ellipsis %>"
if ERR=$(command git clone ${=BRANCH} -q --recursive ${URL} ${DIR} 2>&1); then
if (( PRINTLEVEL > 0 )) print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b Installed"
else
print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git clone%f"$'\n'${(F):- ${(f)^ERR}}
return 1
fi