update new site
This commit is contained in:
parent
582991da41
commit
3c3c63b898
|
@ -2,6 +2,7 @@ package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -167,8 +168,25 @@ func ParseComponents(r *http.Request) []string {
|
||||||
|
|
||||||
// Run is used to run the static website generator
|
// Run is used to run the static website generator
|
||||||
func Run(c *config.Config) {
|
func Run(c *config.Config) {
|
||||||
if is, _ := IsEmpty(c.Path); is {
|
create := false
|
||||||
commands.NewSite(&cobra.Command{}, []string{c.Path})
|
|
||||||
|
if _, err := os.Stat(c.Path + "config.yaml"); os.IsNotExist(err) {
|
||||||
|
create = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := os.Stat(c.Path + "config.json"); os.IsNotExist(err) {
|
||||||
|
create = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := os.Stat(c.Path + "config.toml"); os.IsNotExist(err) {
|
||||||
|
create = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if create {
|
||||||
|
fmt.Print("Are you sure you want to generate a Hugo website on " + c.Path + "? (y/n)")
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
cmd.Flags().Bool("force", true, "")
|
||||||
|
commands.NewSite(cmd, []string{c.Path})
|
||||||
}
|
}
|
||||||
|
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
|
@ -198,21 +216,6 @@ func Run(c *config.Config) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsEmpty checks if a folder is empty
|
|
||||||
func IsEmpty(name string) (bool, error) {
|
|
||||||
f, err := os.Open(name)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
|
|
||||||
_, err = f.Readdir(1)
|
|
||||||
if err == io.EOF {
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var splitCapitalizeExceptions = map[string]string{
|
var splitCapitalizeExceptions = map[string]string{
|
||||||
"youtube": "YouTube",
|
"youtube": "YouTube",
|
||||||
"github": "GitHub",
|
"github": "GitHub",
|
||||||
|
|
Loading…
Reference in New Issue