close #37
This commit is contained in:
parent
58f5e4b1d9
commit
f0175875b3
|
@ -13,6 +13,7 @@ import (
|
||||||
|
|
||||||
"github.com/hacdias/caddy-hugo/assets"
|
"github.com/hacdias/caddy-hugo/assets"
|
||||||
"github.com/hacdias/caddy-hugo/config"
|
"github.com/hacdias/caddy-hugo/config"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/hugo/commands"
|
"github.com/spf13/hugo/commands"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
@ -164,6 +165,10 @@ 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 {
|
||||||
|
commands.NewSite(&cobra.Command{}, []string{c.Path})
|
||||||
|
}
|
||||||
|
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -191,6 +196,20 @@ func Run(c *config.Config) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 // Either not empty or error, suits both cases
|
||||||
|
}
|
||||||
|
|
||||||
var splitCapitalizeExceptions = map[string]string{
|
var splitCapitalizeExceptions = map[string]string{
|
||||||
"youtube": "YouTube",
|
"youtube": "YouTube",
|
||||||
"github": "GitHub",
|
"github": "GitHub",
|
||||||
|
|
Loading…
Reference in New Issue