Add default command back in

This commit is contained in:
trading_peter 2022-11-29 10:23:42 +01:00
parent 8433170681
commit 427e287895
3 changed files with 21 additions and 3 deletions

View File

@ -9,7 +9,12 @@ import (
) )
func buildAction(ctx *cli.Context) error { func buildAction(ctx *cli.Context) error {
cfgPath := ctx.String("c") cfgPath, err := filepath.Abs(ctx.String("c"))
if err != nil {
return err
}
os.Chdir(filepath.Dir(cfgPath)) os.Chdir(filepath.Dir(cfgPath))
opts := readCfg(cfgPath) opts := readCfg(cfgPath)

View File

@ -10,6 +10,7 @@ import (
"strings" "strings"
"github.com/evanw/esbuild/pkg/api" "github.com/evanw/esbuild/pkg/api"
"github.com/jaschaephraim/lrserver"
"github.com/otiai10/copy" "github.com/otiai10/copy"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
) )
@ -94,6 +95,11 @@ func main() {
Usage: "watch for changes and trigger the build", Usage: "watch for changes and trigger the build",
Flags: []cli.Flag{ Flags: []cli.Flag{
cfgParam, cfgParam,
&cli.UintFlag{
Name: "lr-port",
Value: uint(lrserver.DefaultPort),
Usage: "port for the live reload server",
},
}, },
Action: watchAction, Action: watchAction,
}, },
@ -132,6 +138,7 @@ func main() {
}, },
}, },
}, },
DefaultCommand: "watch",
} }
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {

View File

@ -15,7 +15,12 @@ import (
) )
func watchAction(ctx *cli.Context) error { func watchAction(ctx *cli.Context) error {
cfgPath := ctx.String("c") cfgPath, err := filepath.Abs(ctx.String("c"))
if err != nil {
return err
}
os.Chdir(filepath.Dir(cfgPath)) os.Chdir(filepath.Dir(cfgPath))
optsSetups := readCfg(cfgPath) optsSetups := readCfg(cfgPath)
@ -100,7 +105,8 @@ func watchAction(ctx *cli.Context) error {
go func() { go func() {
fmt.Println("Starting live reload server") fmt.Println("Starting live reload server")
lr := lrserver.New(lrserver.DefaultName, lrserver.DefaultPort) port := ctx.Uint("lr-port")
lr := lrserver.New(lrserver.DefaultName, uint16(port))
go func() { go func() {
for { for {