-
Notifications
You must be signed in to change notification settings - Fork 16
/
get-hugo.sh
69 lines (48 loc) · 1.46 KB
/
get-hugo.sh
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
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
DIR=${PWD}
HUGO_TYPE='extended'
# Check for positional parameter, if found we assume it's the intended version
if [ ! $1 ]; then
#Required to be SET. TODO: Test for this, and if version is not present load from present. Use something like https://zwbetz.com/script-to-install-latest-hugo-release-on-linux-and-mac/
HUGO_VERSION=$(node -p "require('./package.json').hugo.version")
HUGO_TYPE=$(node -p "require('./package.json').hugo.extended")
else
HUGO_VERSION=$1
fi
FILE=hugo_${HUGO_VERSION}
set -e
if [ -n $HUGO_VERSION ]; then
echo Installing $HUGO_VERSION
else
exit
fi
#
if [ $HUGO_TYPE != false ] || [ $HUGO_TYPE != "false" ]; then
echo WE ARE Using Hugo Extended
EXTENDED="extended_"
else
echo NOT Using Hugo Extended
EXTENDED=""
fi
echo Cleaning bin directory
if [ -d ${PWD}/bin ]; then
rm -rf ${PWD}/bin
fi
echo Make temp directory
mkdir -p ${PWD}/temp ${PWD}/bin
echo Move to temp directory
pushd ${PWD}/temp
echo Current Directory: ${PWD}
curl -L https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${EXTENDED}${HUGO_VERSION}_macOS-64bit.tar.gz -o ${FILE}.tar.gz
TARBALL=${FILE}.tar.gz
echo Extracting $TARBALL
tar --extract --file $TARBALL
# do we need sudo command for these?
chmod +x hugo
mv hugo $DIR/bin/${FILE}
# Clean up temp directory (popd) ?
rm -rf $DIR/temp
location="$(which $DIR/bin/${FILE})"
echo "Hugo binary location: $location"
version="$($DIR/bin/${FILE} version)"
echo $version