mirror of
https://github.com/facundoolano/jorge.git
synced 2024-12-26 21:58:51 +01:00
print site building times
This commit is contained in:
parent
d3ca71e95e
commit
2afd897ab3
2 changed files with 9 additions and 2 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/alecthomas/kong"
|
"github.com/alecthomas/kong"
|
||||||
"github.com/facundoolano/jorge/config"
|
"github.com/facundoolano/jorge/config"
|
||||||
|
@ -20,12 +21,16 @@ type Build struct {
|
||||||
|
|
||||||
// Read the files in src/ render them and copy the result to target/
|
// Read the files in src/ render them and copy the result to target/
|
||||||
func (cmd *Build) Run(ctx *kong.Context) error {
|
func (cmd *Build) Run(ctx *kong.Context) error {
|
||||||
|
start := time.Now()
|
||||||
|
|
||||||
config, err := config.Load(cmd.ProjectDir)
|
config, err := config.Load(cmd.ProjectDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return site.Build(*config)
|
err = site.Build(*config)
|
||||||
|
fmt.Printf("done in %.2fs\n", time.Since(start).Seconds())
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prompt the user for a string value
|
// Prompt the user for a string value
|
||||||
|
|
|
@ -121,6 +121,7 @@ func runWatcher(config *config.Config, broker *EventBroker) (*fsnotify.Watcher,
|
||||||
// rebuilding the site and publishing a rebuild event to clients.
|
// rebuilding the site and publishing a rebuild event to clients.
|
||||||
func rebuildSite(config *config.Config, watcher *fsnotify.Watcher, broker *EventBroker) {
|
func rebuildSite(config *config.Config, watcher *fsnotify.Watcher, broker *EventBroker) {
|
||||||
fmt.Printf("building site\n")
|
fmt.Printf("building site\n")
|
||||||
|
start := time.Now()
|
||||||
|
|
||||||
// since new nested directories could be triggering this change, and we need to watch those too
|
// since new nested directories could be triggering this change, and we need to watch those too
|
||||||
// and since re-watching files is a noop, I just re-add the entire src everytime there's a change
|
// and since re-watching files is a noop, I just re-add the entire src everytime there's a change
|
||||||
|
@ -135,7 +136,8 @@ func rebuildSite(config *config.Config, watcher *fsnotify.Watcher, broker *Event
|
||||||
|
|
||||||
broker.publish("rebuild")
|
broker.publish("rebuild")
|
||||||
|
|
||||||
fmt.Println("done\nserving at", config.SiteUrl)
|
elapsed := time.Since(start)
|
||||||
|
fmt.Printf("done in %.2fs\nserving at %s\n", elapsed.Seconds(), config.SiteUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure the given watcher to notify for changes in the project source files
|
// Configure the given watcher to notify for changes in the project source files
|
||||||
|
|
Loading…
Reference in a new issue