bug fix #175
This commit is contained in:
parent
f0e28d1602
commit
6ba5a47b0e
|
@ -795,7 +795,7 @@ func setup(c *cli.Context) (err error) {
|
||||||
Resolve: func(d interact.Context) bool {
|
Resolve: func(d interact.Context) bool {
|
||||||
val, _ := d.Ans().Bool()
|
val, _ := d.Ans().Bool()
|
||||||
if val {
|
if val {
|
||||||
r.Schema.Projects[len(r.Schema.Projects)-1].Watcher.Ignore.Paths = r.Schema.Projects[len(r.Schema.Projects)-1].Watcher.Ignore.Paths[:len(r.Schema.Projects[len(r.Schema.Projects)-1].Watcher.Ignore.Paths)-1]
|
r.Schema.Projects[len(r.Schema.Projects)-1].Watcher.Ignore = r.Schema.Projects[len(r.Schema.Projects)-1].Watcher.Ignore[:len(r.Schema.Projects[len(r.Schema.Projects)-1].Watcher.Ignore)-1]
|
||||||
}
|
}
|
||||||
return val
|
return val
|
||||||
},
|
},
|
||||||
|
@ -815,7 +815,7 @@ func setup(c *cli.Context) (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return d.Err()
|
return d.Err()
|
||||||
}
|
}
|
||||||
r.Schema.Projects[len(r.Schema.Projects)-1].Watcher.Ignore.Paths = append(r.Schema.Projects[len(r.Schema.Projects)-1].Watcher.Ignore.Paths, val)
|
r.Schema.Projects[len(r.Schema.Projects)-1].Watcher.Ignore = append(r.Schema.Projects[len(r.Schema.Projects)-1].Watcher.Ignore, val)
|
||||||
d.Reload()
|
d.Reload()
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|
|
@ -30,7 +30,7 @@ type Watch struct {
|
||||||
Paths []string `yaml:"paths" json:"paths"`
|
Paths []string `yaml:"paths" json:"paths"`
|
||||||
Scripts []Command `yaml:"scripts,omitempty" json:"scripts,omitempty"`
|
Scripts []Command `yaml:"scripts,omitempty" json:"scripts,omitempty"`
|
||||||
Hidden bool `yaml:"hidden,omitempty" json:"hidden,omitempty"`
|
Hidden bool `yaml:"hidden,omitempty" json:"hidden,omitempty"`
|
||||||
Ignore Ignore `yaml:"ignore,omitempty" json:"ignore,omitempty"`
|
Ignore []string `yaml:"ignored_paths,omitempty" json:"ignored_paths,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Ignore struct {
|
type Ignore struct {
|
||||||
|
@ -356,7 +356,7 @@ func (p *Project) Validate(path string, fcheck bool) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// check ignored
|
// check ignored
|
||||||
for _, v := range p.Watcher.Ignore.Exts {
|
for _, v := range p.Watcher.Ignore {
|
||||||
if v == e {
|
if v == e {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -373,7 +373,7 @@ func (p *Project) Validate(path string, fcheck bool) bool {
|
||||||
}
|
}
|
||||||
separator := string(os.PathSeparator)
|
separator := string(os.PathSeparator)
|
||||||
// supported paths
|
// supported paths
|
||||||
for _, v := range p.Watcher.Ignore.Paths {
|
for _, v := range p.Watcher.Ignore {
|
||||||
s := append([]string{p.Path}, strings.Split(v, separator)...)
|
s := append([]string{p.Path}, strings.Split(v, separator)...)
|
||||||
abs, _ := filepath.Abs(filepath.Join(s...))
|
abs, _ := filepath.Abs(filepath.Join(s...))
|
||||||
if path == abs || strings.HasPrefix(path, abs+separator) {
|
if path == abs || strings.HasPrefix(path, abs+separator) {
|
||||||
|
|
|
@ -129,9 +129,7 @@ func TestProject_Validate(t *testing.T) {
|
||||||
parent: &r,
|
parent: &r,
|
||||||
Watcher: Watch{
|
Watcher: Watch{
|
||||||
Exts: []string{},
|
Exts: []string{},
|
||||||
Ignore: Ignore{
|
Ignore: []string{"/test/ignore"},
|
||||||
Paths:[]string{"/test/ignore"},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
for i, v := range data {
|
for i, v := range data {
|
||||||
|
|
|
@ -68,9 +68,7 @@ func (s *Schema) New(c *cli.Context) Project {
|
||||||
Args: params(c),
|
Args: params(c),
|
||||||
Watcher: Watch{
|
Watcher: Watch{
|
||||||
Paths: []string{"/"},
|
Paths: []string{"/"},
|
||||||
Ignore: Ignore{
|
Ignore: []string{".git", ".realize", "vendor"},
|
||||||
Paths:[]string{".git", ".realize", "vendor"},
|
|
||||||
},
|
|
||||||
Exts: []string{"go"},
|
Exts: []string{"go"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"github.com/go-siris/siris/core/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Dafault host and port
|
// Dafault host and port
|
||||||
|
|
Loading…
Reference in New Issue