code review
This commit is contained in:
parent
bccfaca01d
commit
b7c50a2efb
16
realize.go
16
realize.go
|
@ -122,25 +122,25 @@ func main() {
|
|||
},
|
||||
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"){
|
||||
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") {
|
||||
r.Config.Legacy = settings.Legacy{
|
||||
c.Config.Legacy = settings.Legacy{
|
||||
Status: p.Bool("legacy"),
|
||||
Interval: interval,
|
||||
}
|
||||
}
|
||||
if p.Bool("no-config") || len(r.Blueprint.Projects) <= 0 {
|
||||
if p.Bool("no-config") || len(c.Blueprint.Projects) <= 0 {
|
||||
if p.Bool("no-config") {
|
||||
r.Config.Create = false
|
||||
c.Config.Create = false
|
||||
}
|
||||
r.Blueprint.Projects = []watcher.Project{}
|
||||
if err := r.Blueprint.Add(p); err != nil {
|
||||
c.Blueprint.Projects = []watcher.Project{}
|
||||
if err := c.Blueprint.Add(p); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package settings
|
||||
|
||||
import (
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
"os"
|
||||
"time"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
var Dir = ".realize/"
|
||||
|
|
|
@ -16,7 +16,7 @@ func (h *Blueprint) Run(p *cli.Context) error {
|
|||
wg.Add(len(h.Projects))
|
||||
for k, element := range h.Projects {
|
||||
tools := tools{}
|
||||
if element.Cmds.Fmt{
|
||||
if element.Cmds.Fmt {
|
||||
tools.Fmt = tool{
|
||||
status: &h.Projects[k].Cmds.Fmt,
|
||||
cmd: "gofmt",
|
||||
|
@ -24,7 +24,7 @@ func (h *Blueprint) Run(p *cli.Context) error {
|
|||
name: "Go Fmt",
|
||||
}
|
||||
}
|
||||
if element.Cmds.Generate{
|
||||
if element.Cmds.Generate {
|
||||
tools.Generate = tool{
|
||||
status: &h.Projects[k].Cmds.Generate,
|
||||
cmd: "go",
|
||||
|
@ -32,7 +32,7 @@ func (h *Blueprint) Run(p *cli.Context) error {
|
|||
name: "Go Generate",
|
||||
}
|
||||
}
|
||||
if element.Cmds.Test{
|
||||
if element.Cmds.Test {
|
||||
tools.Test = tool{
|
||||
status: &h.Projects[k].Cmds.Test,
|
||||
cmd: "go",
|
||||
|
@ -178,5 +178,5 @@ func (h *Blueprint) check() error {
|
|||
h.Clean()
|
||||
return nil
|
||||
}
|
||||
return errors.New("there are no projects")
|
||||
return errors.New("There are no projects")
|
||||
}
|
||||
|
|
|
@ -286,10 +286,10 @@ func (p *Project) tool(path string, tool tool) error {
|
|||
// Cmd calls an wrapper for execute the commands after/before
|
||||
func (p *Project) cmd(flag string, changed bool) {
|
||||
for _, cmd := range p.Watcher.Scripts {
|
||||
if strings.ToLower(cmd.Type) == flag{
|
||||
if strings.ToLower(cmd.Type) == flag {
|
||||
if changed && cmd.Changed || !changed && cmd.Startup {
|
||||
errors, logs := p.command(cmd)
|
||||
msg = fmt.Sprintln(p.pname(p.Name, 5), ":", style.Green.Bold("Command"), style.Green.Bold("\"") + cmd.Command + style.Green.Bold("\""))
|
||||
msg = fmt.Sprintln(p.pname(p.Name, 5), ":", style.Green.Bold("Command"), style.Green.Bold("\"")+cmd.Command+style.Green.Bold("\""))
|
||||
out = BufferOut{Time: time.Now(), Text: cmd.Command, Type: flag}
|
||||
if logs != "" {
|
||||
p.print("log", out, msg, "")
|
||||
|
@ -323,7 +323,7 @@ func (p *Project) ignore(str string) bool {
|
|||
}
|
||||
|
||||
// Routines launches the toolchain run, build, install
|
||||
func (p *Project) routines(wr *sync.WaitGroup,channel chan bool, watcher watcher, file string) {
|
||||
func (p *Project) routines(wr *sync.WaitGroup, channel chan bool, watcher watcher, file string) {
|
||||
if len(file) > 0 {
|
||||
p.cmd("before", true)
|
||||
path := filepath.Dir(file)
|
||||
|
|
Loading…
Reference in New Issue