#58 fixed
This commit is contained in:
parent
350bdbb4a6
commit
e2c06878f5
16
realize.go
16
realize.go
@ -80,7 +80,6 @@ func main() {
|
|||||||
if err := r.Read(&r); err != nil {
|
if err := r.Read(&r); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// increase the file limit
|
// increase the file limit
|
||||||
if r.Config.Flimit != 0 {
|
if r.Config.Flimit != 0 {
|
||||||
if err := r.Flimit(); err != nil {
|
if err := r.Flimit(); err != nil {
|
||||||
@ -111,6 +110,7 @@ func main() {
|
|||||||
Description: "Run a toolchain on a project or a list of projects. If not exist a config file it creates a new one",
|
Description: "Run a toolchain on a project or a list of projects. If not exist a config file it creates a new one",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{Name: "path", Aliases: []string{"p"}, Value: "", Usage: "Project base path."},
|
&cli.StringFlag{Name: "path", Aliases: []string{"p"}, Value: "", Usage: "Project base path."},
|
||||||
|
&cli.StringFlag{Name: "name", Aliases: []string{"n"}, Value: "", Usage: "Run a project by its name."},
|
||||||
&cli.BoolFlag{Name: "test", Aliases: []string{"t"}, Value: false, Usage: "Enable go test."},
|
&cli.BoolFlag{Name: "test", Aliases: []string{"t"}, Value: false, Usage: "Enable go test."},
|
||||||
&cli.BoolFlag{Name: "generate", Aliases: []string{"g"}, Value: false, Usage: "Enable go generate."},
|
&cli.BoolFlag{Name: "generate", Aliases: []string{"g"}, Value: false, Usage: "Enable go generate."},
|
||||||
&cli.BoolFlag{Name: "build", Aliases: []string{"b"}, Value: false, Usage: "Enable go build."},
|
&cli.BoolFlag{Name: "build", Aliases: []string{"b"}, Value: false, Usage: "Enable go build."},
|
||||||
@ -121,6 +121,14 @@ func main() {
|
|||||||
&cli.BoolFlag{Name: "no-config", Aliases: []string{"nc"}, Value: false, Usage: "Ignore existing configurations."},
|
&cli.BoolFlag{Name: "no-config", Aliases: []string{"nc"}, Value: false, Usage: "Ignore existing configurations."},
|
||||||
},
|
},
|
||||||
Action: func(p *cli.Context) error {
|
Action: func(p *cli.Context) error {
|
||||||
|
c := r
|
||||||
|
if p.String("name") != ""{
|
||||||
|
for index, project := range r.Blueprint.Projects{
|
||||||
|
if project.Name == p.String("name"){
|
||||||
|
c.Blueprint.Projects = []watcher.Project{r.Blueprint.Projects[index]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if p.Bool("legacy") {
|
if p.Bool("legacy") {
|
||||||
r.Config.Legacy = settings.Legacy{
|
r.Config.Legacy = settings.Legacy{
|
||||||
Status: p.Bool("legacy"),
|
Status: p.Bool("legacy"),
|
||||||
@ -136,13 +144,13 @@ func main() {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := r.Server.Start(p); err != nil {
|
if err := c.Server.Start(p); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := r.Blueprint.Run(); err != nil {
|
if err := c.Blueprint.Run(p); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := r.Record(r); err != nil {
|
if err := r.Record(c); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -3,7 +3,6 @@ package settings
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
yaml "gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -9,14 +9,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Run launches the toolchain for each project
|
// Run launches the toolchain for each project
|
||||||
func (h *Blueprint) Run() error {
|
func (h *Blueprint) Run(p *cli.Context) error {
|
||||||
err := h.check()
|
err := h.check()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// loop projects
|
// loop projects
|
||||||
wg.Add(len(h.Projects))
|
wg.Add(len(h.Projects))
|
||||||
for k, element := range h.Projects {
|
for k, element := range h.Projects {
|
||||||
tools := tools{}
|
tools := tools{}
|
||||||
if element.Cmds.Fmt {
|
if element.Cmds.Fmt{
|
||||||
tools.Fmt = tool{
|
tools.Fmt = tool{
|
||||||
status: &h.Projects[k].Cmds.Fmt,
|
status: &h.Projects[k].Cmds.Fmt,
|
||||||
cmd: "gofmt",
|
cmd: "gofmt",
|
||||||
@ -24,7 +24,7 @@ func (h *Blueprint) Run() error {
|
|||||||
name: "Go Fmt",
|
name: "Go Fmt",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if element.Cmds.Generate {
|
if element.Cmds.Generate{
|
||||||
tools.Generate = tool{
|
tools.Generate = tool{
|
||||||
status: &h.Projects[k].Cmds.Generate,
|
status: &h.Projects[k].Cmds.Generate,
|
||||||
cmd: "go",
|
cmd: "go",
|
||||||
@ -32,7 +32,7 @@ func (h *Blueprint) Run() error {
|
|||||||
name: "Go Generate",
|
name: "Go Generate",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if element.Cmds.Test {
|
if element.Cmds.Test{
|
||||||
tools.Test = tool{
|
tools.Test = tool{
|
||||||
status: &h.Projects[k].Cmds.Test,
|
status: &h.Projects[k].Cmds.Test,
|
||||||
cmd: "go",
|
cmd: "go",
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/tockins/realize/style"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -12,7 +13,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"github.com/tockins/realize/style"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GoRun is an implementation of the bin execution
|
// GoRun is an implementation of the bin execution
|
||||||
|
@ -31,20 +31,20 @@ type Blueprint struct {
|
|||||||
|
|
||||||
// Project defines the informations of a single project
|
// Project defines the informations of a single project
|
||||||
type Project struct {
|
type Project struct {
|
||||||
settings.Settings `yaml:"-"`
|
settings.Settings `yaml:"-"`
|
||||||
LastChangedOn time.Time `yaml:"-" json:"-"`
|
LastChangedOn time.Time `yaml:"-" json:"-"`
|
||||||
base string
|
base string
|
||||||
Name string `yaml:"name" json:"name"`
|
Name string `yaml:"name" json:"name"`
|
||||||
Path string `yaml:"path" json:"path"`
|
Path string `yaml:"path" json:"path"`
|
||||||
Cmds Cmds `yaml:"cmds" json:"cmds"`
|
Cmds Cmds `yaml:"commands" json:"commands"`
|
||||||
Args []string `yaml:"args,omitempty" json:"args,omitempty"`
|
Args []string `yaml:"args,omitempty" json:"args,omitempty"`
|
||||||
Watcher Watcher `yaml:"watcher" json:"watcher"`
|
Watcher Watcher `yaml:"watcher" json:"watcher"`
|
||||||
Streams Streams `yaml:"streams" json:"streams"`
|
Streams Streams `yaml:"streams" json:"streams"`
|
||||||
Buffer Buffer `yaml:"-" json:"buffer"`
|
Buffer Buffer `yaml:"-" json:"buffer"`
|
||||||
ErrorOutputPattern string `yaml:"errorOutputPattern" json:"errorOutputPattern"`
|
ErrorOutputPattern string `yaml:"errorOutputPattern" json:"errorOutputPattern"`
|
||||||
parent *Blueprint
|
parent *Blueprint
|
||||||
path string
|
path string
|
||||||
tools tools
|
tools tools
|
||||||
}
|
}
|
||||||
|
|
||||||
type tools struct {
|
type tools struct {
|
||||||
|
@ -3,19 +3,19 @@ package watcher
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/fsnotify/fsnotify"
|
||||||
|
"github.com/tockins/realize/style"
|
||||||
"log"
|
"log"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
"reflect"
|
|
||||||
"github.com/fsnotify/fsnotify"
|
|
||||||
"github.com/tockins/realize/style"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var msg string
|
var msg string
|
||||||
@ -285,8 +285,8 @@ func (p *Project) build() error {
|
|||||||
func (p *Project) tool(path string, tool tool) error {
|
func (p *Project) tool(path string, tool tool) error {
|
||||||
if tool.status != nil {
|
if tool.status != nil {
|
||||||
v := reflect.ValueOf(tool.status).Elem()
|
v := reflect.ValueOf(tool.status).Elem()
|
||||||
if v.Interface().(bool) && (strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "")) {
|
if v.Interface().(bool) && (strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "")) {
|
||||||
if strings.HasSuffix(path, ".go"){
|
if strings.HasSuffix(path, ".go") {
|
||||||
tool.options = append(tool.options, path)
|
tool.options = append(tool.options, path)
|
||||||
path = p.base
|
path = p.base
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user