From e9b13f961bda8fd474ddd0e8ed2f607b55d2f2f7 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Mon, 22 Feb 2016 21:37:47 +0000 Subject: [PATCH] update install script --- insthugo/insthugo.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/insthugo/insthugo.go b/insthugo/insthugo.go index f5278204..f2f8d24f 100644 --- a/insthugo/insthugo.go +++ b/insthugo/insthugo.go @@ -154,17 +154,24 @@ func Install() string { tempfiles = append(tempfiles, bin+"/README.md", bin+"/LICENSE.md") clean() - ftorename := bin + "/" + strings.Replace(filename, ".tar.gz", "", 1) + ftorename := bin + "/" - if runtime.GOOS == "darwin" { - ftorename = bin + "/" + strings.Replace(filename, ".zip", "", 1) + switch runtime.GOOS { + case "darwin": + ftorename += strings.Replace(filename, ".zip", "", 1) + case "windows": + ftorename += strings.Replace(filename, ".zip", ".exe", 1) + default: + ftorename += strings.Replace(filename, ".tar.gz", "", 1) } - if runtime.GOOS == "windows" { - ftorename = bin + "/" + strings.Replace(filename, ".zip", ".exe", 1) + err = os.Rename(ftorename, hugo) + + if err != nil { + fmt.Println(err) + os.Exit(-1) } - os.Rename(ftorename, hugo) fmt.Println("Hugo installed at " + hugo) return hugo }