Skip to content

Commit b3a0ddd

Browse files
Add condition for OS
Signed-off-by: Harshita-Kanal <[email protected]>
1 parent 2142578 commit b3a0ddd

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

Makefile

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ GITHUB_TOKEN?=
44
PACK_BIN?=$(shell which pack)
55
SERVE_PORT=1313
66
BASE_URL?=
7+
HUGO_BIN=./tools/bin/hugo
8+
9+
#retreive latest hugo version
10+
_latestver:=$(shell curl --silent "https://api.github.com/repos/gohugoio/hugo/tags" | jq -r '.[0].name' | tr -d v)
711

812
ifndef BASE_URL
913
ifdef GITPOD_WORKSPACE_URL
@@ -28,17 +32,24 @@ clean:
2832

2933
.PHONY: install-hugo
3034
install-hugo:
35+
3136
@echo "> Installing hugo..."
3237
@echo "This may take a while depending on your connection."
38+
3339
ifeq ($(OS),Windows_NT)
34-
@echo $(shell uname -s)
35-
cd tools; mkdir bin; cd bin; curl -L -O $(shell curl https://api.github.com/repos/gohugoio/hugo/releases/latest | jq -r '.assets[30].browser_download_url')
36-
40+
@echo $(shell uname -s) ;
41+
cd tools; mkdir bin; cd bin; curl -s -L -O $(shell curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | jq -r '.assets[30].browser_download_url')
3742
else
38-
@echo $(shell uname -s)
39-
cd tools; mkdir bin; cd bin; curl -L -O $(shell curl https://api.github.com/repos/gohugoio/hugo/releases/latest | jq -r '.assets[26].browser_download_url')
43+
ifeq ($(shell uname -s),Darwin)
44+
@echo $(shell uname -s)
45+
cd tools; mkdir bin; cd bin; curl -s -L -O $(shell curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | jq -r '.assets[28].browser_download_url'); tar xvfz hugo_extended_${_latestver}_macOS-64bit.tar.gz
46+
else
47+
@echo $(shell uname -s)
48+
cd tools; mkdir bin; cd bin; curl -s -L -O $(shell curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | jq -r '.assets[27].browser_download_url'); tar xvfz hugo_extended_${_latestver}_Linux-64bit.tar.gz
49+
endif
4050
endif
4151

52+
4253

4354

4455
.PHONY: upgrade-pack
@@ -80,16 +91,16 @@ serve: export PACK_VERSION:=$(PACK_VERSION)
8091
serve: install-hugo pack-version pack-docs-update
8192
@echo "> Serving..."
8293
ifeq ($(BASE_URL),)
83-
hugo server --disableFastRender --port=$(SERVE_PORT)
94+
$(HUGO_BIN) server --disableFastRender --port=$(SERVE_PORT)
8495
else
85-
hugo server --disableFastRender --port=$(SERVE_PORT) --baseURL=$(BASE_URL) --appendPort=false
96+
$(HUGO_BIN) server --disableFastRender --port=$(SERVE_PORT) --baseURL=$(BASE_URL) --appendPort=false
8697
endif
8798

8899
.PHONY: build
89100
build: export PACK_VERSION:=$(PACK_VERSION)
90101
build: install-hugo pack-version pack-docs-update
91102
@echo "> Building..."
92-
hugo
103+
$(HUGO_BIN)
93104

94105
.PHONY: test
95106
test: install-pack-cli install-ugo

0 commit comments

Comments
 (0)