script to install Hugo - missing sha256

This commit is contained in:
Henrique Dias
2016-02-20 22:31:46 +00:00
parent 6bcae605f2
commit e8874fabf1
3 changed files with 194 additions and 2 deletions

View File

@@ -1,8 +1,14 @@
package config
import (
"fmt"
"log"
"os"
"os/user"
"runtime"
"strings"
"github.com/hacdias/caddy-hugo/insthugo"
"github.com/mholt/caddy/caddy/setup"
)
@@ -12,13 +18,31 @@ type Config struct {
Path string // Hugo files path
Styles string // Admin styles path
Args []string // Hugo arguments
Hugo string // Hugo executable path
}
// ParseHugo parses the configuration file
func ParseHugo(c *setup.Controller) (*Config, error) {
// First check if Hugo is installed
user, err := user.Current()
if err != nil {
log.Fatal(err)
}
conf := &Config{
Public: strings.Replace(c.Root, "./", "", -1),
Path: "./",
Hugo: user.HomeDir + "/.caddy/bin/hugo",
}
if runtime.GOOS == "windows" {
conf.Hugo += ".exe"
}
if _, err := os.Stat(conf.Hugo); os.IsNotExist(err) {
fmt.Print("hey")
insthugo.Install()
}
for c.Next() {