Add default command back in
This commit is contained in:
parent
8433170681
commit
427e287895
7
build.go
7
build.go
@ -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)
|
||||||
|
|
||||||
|
7
main.go
7
main.go
@ -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 {
|
||||||
|
10
watch.go
10
watch.go
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user