✨ support on_project_start
This commit is contained in:
parent
84f1f289ca
commit
724f18395b
@ -5,18 +5,21 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Project struct {
|
type Project struct {
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
Root string `yaml:"root"`
|
Root string `yaml:"root"`
|
||||||
Windows []Window `yaml:"windows"`
|
OnProjectStart []string `yaml:"on_project_start"`
|
||||||
|
Windows []Window `yaml:"windows"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartProject(name string) {
|
func StartProject(name string) {
|
||||||
@ -26,6 +29,21 @@ func StartProject(name string) {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run startup commands
|
||||||
|
if len(p.OnProjectStart) > 0 {
|
||||||
|
for _, command := range p.OnProjectStart {
|
||||||
|
args := strings.Fields(command)
|
||||||
|
cmd := exec.Command(args[0], args[1:]...)
|
||||||
|
cmd.Dir = p.GetRoot()
|
||||||
|
output, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Unable to run start command:", err, output)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
fmt.Println(string(output))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tmux := CreateTmux(false)
|
tmux := CreateTmux(false)
|
||||||
|
|
||||||
if !sessionExists(name) {
|
if !sessionExists(name) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user