Skip to content

Commit

Permalink
services/serve: use cmdrunner to run npm dev for user's frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgooz committed Jul 31, 2020
1 parent 09c00a5 commit d4679d4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions starport/services/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"log"
"net/http"
"os"
"os/exec"
"path/filepath"
"time"

Expand All @@ -26,12 +25,17 @@ type App struct {
}

func Serve(ctx context.Context, app App, verbose bool) error {
cmdNpm := exec.CommandContext(ctx, "npm", "run", "dev")
cmdNpm.Dir = filepath.Join(app.Path, "frontend")
cmdNpm.Start()
go cmdrunner.
New().
Run(ctx, step.New(
step.Exec("npm", "run", "dev"),
step.Workdir(filepath.Join(app.Path, "frontend")),
))

serveCtx, cancel := context.WithCancel(ctx)
startServe(serveCtx, app, verbose) // TODO handle error
go runDevServer(app, verbose)

w := watcher.New()
w.SetMaxEvents(1)
go func() {
Expand Down

0 comments on commit d4679d4

Please sign in to comment.