lint
This commit is contained in:
parent
121b6e58f2
commit
7ba2833bf8
|
@ -87,20 +87,20 @@ func WorkingDir() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Duplicates check projects with same name or same combinations of main/path
|
// Duplicates check projects with same name or same combinations of main/path
|
||||||
func Duplicates(value Project, arr []Project) (error, Project) {
|
func Duplicates(value Project, arr []Project) (Project, error) {
|
||||||
for _, val := range arr {
|
for _, val := range arr {
|
||||||
if value.Path == val.Path || value.Name == val.Name {
|
if value.Path == val.Path || value.Name == val.Name {
|
||||||
return errors.New("There is a duplicate of '" + val.Name + "'. Check your config file!"), val
|
return errors.New("There is a duplicate of '" + val.Name + "'. Check your config file!"), val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, Project{}
|
return Project{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean duplicate projects
|
// Clean duplicate projects
|
||||||
func (h *Config) Clean() {
|
func (h *Config) Clean() {
|
||||||
arr := h.Projects
|
arr := h.Projects
|
||||||
for key, val := range arr {
|
for key, val := range arr {
|
||||||
if err, _ := Duplicates(val, arr[key+1:]); err != nil {
|
if _, err := Duplicates(val, arr[key+1:]); err != nil {
|
||||||
h.Projects = append(arr[:key], arr[key+1:]...)
|
h.Projects = append(arr[:key], arr[key+1:]...)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ func (h *Config) Add(params *cli.Context) error {
|
||||||
Ignore: watcherIgnores,
|
Ignore: watcherIgnores,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if err, _ := Duplicates(new, h.Projects); err != nil {
|
if _, err := Duplicates(new, h.Projects); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
h.Projects = append(h.Projects, new)
|
h.Projects = append(h.Projects, new)
|
||||||
|
|
Loading…
Reference in New Issue