Compare commits
No commits in common. "30f8be3d5d40102187c57310423c08793eaaf898" and "734a6ce62e17bf8e86c87e2137bcc6a7b3a4cc3f" have entirely different histories.
30f8be3d5d
...
734a6ce62e
15
build.go
15
build.go
@ -1,9 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/evanw/esbuild/pkg/api"
|
||||
@ -36,19 +34,6 @@ func buildAction(ctx *cli.Context) error {
|
||||
|
||||
api.Build(o.ESBuild.BuildOptions)
|
||||
replace(o)
|
||||
|
||||
if ctx.Bool("p") && o.ProductionBuildOptions.CmdPostBuild != "" {
|
||||
fmt.Printf("Executing post production build command `%s`\n", o.ProductionBuildOptions.CmdPostBuild)
|
||||
cmd := exec.Command("sh", "-c", o.ProductionBuildOptions.CmdPostBuild)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
err := cmd.Run()
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to execute post production build command `%s`: %+v\n", o.ProductionBuildOptions.CmdPostBuild, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
7
main.go
7
main.go
@ -28,7 +28,7 @@ type ESBuildExtended struct {
|
||||
type options struct {
|
||||
ESBuild ESBuildExtended
|
||||
Watch struct {
|
||||
Paths []string
|
||||
Path string
|
||||
Exclude []string
|
||||
}
|
||||
Serve struct {
|
||||
@ -52,9 +52,6 @@ type options struct {
|
||||
From string
|
||||
To string
|
||||
}
|
||||
ProductionBuildOptions struct {
|
||||
CmdPostBuild string
|
||||
}
|
||||
}
|
||||
|
||||
func readCfg(cfgPath string) []options {
|
||||
@ -92,7 +89,7 @@ func main() {
|
||||
app := &cli.App{
|
||||
Name: "gowebbuild",
|
||||
Usage: "All in one tool to build web frontend projects.",
|
||||
Version: "4.4.0",
|
||||
Version: "4.3.0",
|
||||
Authors: []*cli.Author{{
|
||||
Name: "trading-peter (https://github.com/trading-peter)",
|
||||
}},
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"Watch": {
|
||||
"Paths": [ "./frontend/src" ],
|
||||
"Path": "./frontend/src",
|
||||
"Exclude": [ "./dist" ]
|
||||
},
|
||||
"Copy": [
|
||||
@ -45,8 +45,5 @@
|
||||
"Bundle": true,
|
||||
"Write": true,
|
||||
"LogLevel": 3
|
||||
},
|
||||
"ProductionBuildOptions": {
|
||||
"CmdPostBuild": "my-build-script.sh"
|
||||
}
|
||||
}
|
14
watch.go
14
watch.go
@ -38,15 +38,9 @@ func watchAction(ctx *cli.Context) error {
|
||||
w.Ignore(opts.Watch.Exclude...)
|
||||
}
|
||||
|
||||
if opts.ESBuild.Outdir != "" {
|
||||
w.Ignore(opts.ESBuild.Outdir)
|
||||
}
|
||||
|
||||
for _, p := range opts.Watch.Paths {
|
||||
if err := w.AddRecursive(p); err != nil {
|
||||
fmt.Println(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
if err := w.AddRecursive(opts.Watch.Path); err != nil {
|
||||
fmt.Println(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
go func() {
|
||||
@ -66,7 +60,7 @@ func watchAction(ctx *cli.Context) error {
|
||||
}
|
||||
}()
|
||||
|
||||
fmt.Printf("Watching %d elements in %s\n", len(w.WatchedFiles()), opts.Watch.Paths)
|
||||
fmt.Printf("Watching %d elements in %s\n", len(w.WatchedFiles()), opts.Watch.Path)
|
||||
|
||||
purge(opts)
|
||||
cp(opts)
|
||||
|
Loading…
Reference in New Issue
Block a user