mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
Install dev dependencies before starting dev mode (#1615)
This commit is contained in:
parent
1f62b5773d
commit
b21a92ecdb
2 changed files with 30 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/bitfield/script"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
|
|
@ -183,6 +184,28 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
|||
signal.Notify(quitChannel, os.Interrupt, os.Kill, syscall.SIGTERM)
|
||||
exitCodeChannel := make(chan int, 1)
|
||||
|
||||
// Install if needed
|
||||
installCommand := projectConfig.GetDevInstallerCommand()
|
||||
if installCommand == "" {
|
||||
return fmt.Errorf("no `frontend:dev` or `frontend:install` defined. Please add one of these to your wails.json")
|
||||
}
|
||||
|
||||
// Install initial frontend dev dependencies
|
||||
err = os.Chdir(filepath.Join(cwd, "frontend"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
LogGreen("Installing frontend dependencies...")
|
||||
pipe := script.Exec(installCommand)
|
||||
pipe.Wait()
|
||||
if pipe.Error() != nil {
|
||||
return pipe.Error()
|
||||
}
|
||||
err = os.Chdir(cwd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// frontend:dev:watcher command.
|
||||
if command := projectConfig.DevWatcherCommand; command != "" {
|
||||
closer, devServerURL, err := runFrontendDevWatcherCommand(cwd, command, projectConfig.FrontendDevServerURL == "auto")
|
||||
|
|
|
|||
|
|
@ -84,6 +84,13 @@ type Project struct {
|
|||
NSISType string `json:"nsisType"`
|
||||
}
|
||||
|
||||
func (p *Project) GetDevInstallerCommand() string {
|
||||
if p.DevCommand != "" {
|
||||
return p.DevCommand
|
||||
}
|
||||
return p.InstallCommand
|
||||
}
|
||||
|
||||
func (p *Project) Save() error {
|
||||
data, err := json.MarshalIndent(p, "", " ")
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue