-
Notifications
You must be signed in to change notification settings - Fork 0
/
hugo
executable file
·59 lines (44 loc) · 1.07 KB
/
hugo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
set -e
SCRIPT_PATH="$(
cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
pwd
)"
declare -r SCRIPT_PATH
declare -r HUGO_PATH="${SCRIPT_PATH}/.hugo"
function get_url() {
local version="${1}"
local kernel
kernel="$(uname -s)"
if [[ "${kernel}" == 'Darwin' ]]; then
echo "https://github.com/gohugoio/hugo/releases/download/v${version}/hugo_extended_${version}_darwin-universal.tar.gz"
else
local arch
arch="$(uname -m)"
if [[ "${arch}" == 'x86_64' ]]; then
arch='amd64'
else
arch='arm64'
fi
echo "https://github.com/gohugoio/hugo/releases/download/v${version}/hugo_${version}_linux-${arch}.tar.gz"
fi
}
function install_hugo() {
local version='0.131.0'
local current
current="$(hugo version 2>/dev/null | awk '{print $2}')"
if [[ "${current}" =~ "${version}"-* ]]; then
return
fi
local url
url="$(get_url "${version}")"
mkdir -p "${HUGO_PATH}"
echo "Download ${url}"
curl -L "${url}" -o - | tar -C "${HUGO_PATH}" -zxf -
}
function main() {
export PATH="${HUGO_PATH}:${PATH}"
install_hugo
hugo "${@}"
}
main "${@}"