mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-02 04:19:33 -05:00
copying static content to destination
This commit is contained in:
parent
736677a21d
commit
61258858af
1 changed files with 12 additions and 4 deletions
16
main.go
16
main.go
|
@ -16,8 +16,10 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/howeyc/fsnotify"
|
"github.com/howeyc/fsnotify"
|
||||||
|
"github.com/mostafah/fsync"
|
||||||
flag "github.com/ogier/pflag"
|
flag "github.com/ogier/pflag"
|
||||||
"github.com/spf13/hugo/hugolib"
|
"github.com/spf13/hugo/hugolib"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -63,16 +65,16 @@ func main() {
|
||||||
config.UglyUrls = *uglyUrls
|
config.UglyUrls = *uglyUrls
|
||||||
config.Verbose = *verbose
|
config.Verbose = *verbose
|
||||||
|
|
||||||
if *destination != "" {
|
|
||||||
config.PublishDir = *destination
|
|
||||||
}
|
|
||||||
|
|
||||||
if *baseUrl != "" {
|
if *baseUrl != "" {
|
||||||
config.BaseUrl = *baseUrl
|
config.BaseUrl = *baseUrl
|
||||||
} else if *server {
|
} else if *server {
|
||||||
config.BaseUrl = "http://localhost:" + *port
|
config.BaseUrl = "http://localhost:" + *port
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *destination != "" {
|
||||||
|
config.PublishDir = *destination
|
||||||
|
}
|
||||||
|
|
||||||
if *version {
|
if *version {
|
||||||
fmt.Println("Hugo Static Site Generator v0.8")
|
fmt.Println("Hugo Static Site Generator v0.8")
|
||||||
}
|
}
|
||||||
|
@ -92,6 +94,12 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy Static to Destination first
|
||||||
|
err := fsync.SyncDel(config.GetAbsPath(config.PublishDir+"/"), config.GetAbsPath(config.StaticDir+"/"))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error copying static files to %s: %v", config.GetAbsPath(config.PublishDir), err)
|
||||||
|
}
|
||||||
|
|
||||||
if *checkMode {
|
if *checkMode {
|
||||||
site := hugolib.NewSite(config)
|
site := hugolib.NewSite(config)
|
||||||
site.Analyze()
|
site.Analyze()
|
||||||
|
|
Loading…
Reference in a new issue