Add some features

This commit is contained in:
2023-09-13 11:45:24 +02:00
parent 760decfb85
commit 9e7f716be8
7 changed files with 485 additions and 48 deletions

View File

@ -2,7 +2,6 @@ package main
import (
"fmt"
"net/http"
"os"
"os/signal"
"path/filepath"
@ -63,6 +62,7 @@ func watchAction(ctx *cli.Context) error {
fmt.Printf("Watching %d elements in %s\n", len(w.WatchedFiles()), opts.Watch.Path)
purge(opts)
cp(opts)
build(opts)
replace(opts)
@ -74,15 +74,12 @@ func watchAction(ctx *cli.Context) error {
if opts.Serve.Path != "" {
go func() {
port := 8888
port := 8080
if opts.Serve.Port != 0 {
port = opts.Serve.Port
}
http.Handle("/", http.FileServer(http.Dir(opts.Serve.Path)))
fmt.Printf("Serving contents of %s at :%d\n", opts.Serve.Path, port)
err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
err := Serve(opts.Serve.Path, uint(port))
if err != nil {
fmt.Printf("%+v\n", err.Error())