Added the hugoExtended
This commit is contained in:
parent
e635243b54
commit
1f5cdffd0b
6 changed files with 41 additions and 12 deletions
|
|
@ -16,11 +16,19 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
_downloadURL = "https://github.com/gohugoio/hugo/releases/download/v%s/hugo_%s_Linux-%s.tar.gz"
|
||||
_downloadURL = "https://github.com/gohugoio/hugo/releases/download/v%s/%s_%s_Linux-%s.tar.gz"
|
||||
)
|
||||
|
||||
func downloadURL(version string) string {
|
||||
func downloadURL(version string, extended bool) string {
|
||||
var archType string
|
||||
var binary string
|
||||
|
||||
if extended {
|
||||
binary = "hugo_extended"
|
||||
} else {
|
||||
binary = "hugo"
|
||||
}
|
||||
|
||||
switch runtime.GOARCH {
|
||||
case "amd64":
|
||||
archType = "64bit"
|
||||
|
|
@ -33,7 +41,7 @@ func downloadURL(version string) string {
|
|||
default:
|
||||
archType = "unsupported"
|
||||
}
|
||||
return fmt.Sprintf(_downloadURL, version, version, archType)
|
||||
return fmt.Sprintf(_downloadURL, version, binary, version, archType)
|
||||
}
|
||||
|
||||
func getTempFile() (string, io.WriteCloser, error) {
|
||||
|
|
@ -46,8 +54,8 @@ func getTempFile() (string, io.WriteCloser, error) {
|
|||
}
|
||||
|
||||
// Get will download the specified hugo verion
|
||||
func Get(version string) (string, error) {
|
||||
resp, err := http.Get(downloadURL(version))
|
||||
func Get(version string, extended bool) (string, error) {
|
||||
resp, err := http.Get(downloadURL(version, extended))
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,20 @@ import (
|
|||
|
||||
func TestDownloadURL(t *testing.T) {
|
||||
want := "https://github.com/gohugoio/hugo/releases/download/v1.0/hugo_1.0_Linux-64bit.tar.gz"
|
||||
if got := downloadURL("1.0"); got != want {
|
||||
if got := downloadURL("1.0", false); got != want {
|
||||
t.Errorf("Download url is not correct, got: %s, want: %s", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDownloadURLExtended(t *testing.T) {
|
||||
want := "https://github.com/gohugoio/hugo/releases/download/v0.55.4/hugo_extended_0.55.4_Linux-64bit.tar.gz"
|
||||
if got := downloadURL("0.55.4", true); got != want {
|
||||
t.Errorf("Download url is not correct, got: %s, want: %s", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
if binPath , err := Get("0.42"); err != nil {
|
||||
if binPath , err := Get("0.42", false); err != nil {
|
||||
t.Errorf("Failed to download archive: %s", err)
|
||||
if binPath == "" {
|
||||
t.Errorf("binPath was nil")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue