Revert "make run server build the binary instead of outputting each run to a tmp file"
This reverts commit d9c7fb3936.
This commit is contained in:
parent
d9c7fb3936
commit
c52f10f92d
1 changed files with 2 additions and 37 deletions
|
|
@ -1,42 +1,7 @@
|
||||||
package run
|
package run
|
||||||
|
|
||||||
import (
|
import "github.com/maddalax/htmgo/cli/htmgo/tasks/process"
|
||||||
"fmt"
|
|
||||||
"github.com/maddalax/htmgo/cli/htmgo/tasks/process"
|
|
||||||
"io/fs"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Server(flags ...process.RunFlag) error {
|
func Server(flags ...process.RunFlag) error {
|
||||||
buildDir := "./__htmgo/temp-build"
|
return process.Run(process.NewRawCommand("run-server", "go run .", flags...))
|
||||||
_ = os.RemoveAll(buildDir)
|
|
||||||
err := os.Mkdir(buildDir, 0755)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
process.RunOrExit(process.NewRawCommand("", fmt.Sprintf("go build -o %s", buildDir)))
|
|
||||||
|
|
||||||
binaryPath := ""
|
|
||||||
|
|
||||||
// find the binary that was built
|
|
||||||
err = filepath.WalkDir(buildDir, func(path string, d fs.DirEntry, err error) error {
|
|
||||||
if d.IsDir() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
binaryPath = path
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if binaryPath == "" {
|
|
||||||
return fmt.Errorf("could not find the binary")
|
|
||||||
}
|
|
||||||
|
|
||||||
return process.Run(process.NewRawCommand("run-server", fmt.Sprintf("./%s", binaryPath), flags...))
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue