优化 path(break change)
This commit is contained in:
+1
-7
@@ -52,7 +52,6 @@ func parseConfig() {
|
|||||||
if cfg.Core.Version > Version {
|
if cfg.Core.Version > Version {
|
||||||
log.Panicln(PreError, "current fileboy support max version : ", Version)
|
log.Panicln(PreError, "current fileboy support max version : ", Version)
|
||||||
}
|
}
|
||||||
cfg.Monitor.RootWatch = false
|
|
||||||
// init map
|
// init map
|
||||||
cfg.Monitor.TypesMap = map[string]bool{}
|
cfg.Monitor.TypesMap = map[string]bool{}
|
||||||
cfg.Monitor.IncludeDirsMap = map[string]bool{}
|
cfg.Monitor.IncludeDirsMap = map[string]bool{}
|
||||||
@@ -71,17 +70,13 @@ func eventDispatcher(event fsnotify.Event) {
|
|||||||
!keyInMonitorTypesMap(ext, cfg) {
|
!keyInMonitorTypesMap(ext, cfg) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fileName := relativePath(projectFolder, event.Name)
|
|
||||||
if !cfg.Monitor.RootWatch && fileName != "filegirl.yaml" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch event.Op {
|
switch event.Op {
|
||||||
case
|
case
|
||||||
fsnotify.Write,
|
fsnotify.Write,
|
||||||
fsnotify.Rename:
|
fsnotify.Rename:
|
||||||
log.Println("EVENT", event.Op.String(), ":", event.Name)
|
log.Println("EVENT", event.Op.String(), ":", event.Name)
|
||||||
taskMan.Put(&changedFile{
|
taskMan.Put(&changedFile{
|
||||||
Name: fileName,
|
Name: relativePath(projectFolder, event.Name),
|
||||||
Changed: time.Now().UnixNano(),
|
Changed: time.Now().UnixNano(),
|
||||||
Ext: ext,
|
Ext: ext,
|
||||||
})
|
})
|
||||||
@@ -104,7 +99,6 @@ func addWatcher() {
|
|||||||
log.Fatalln(PreError, "dirs must be relative paths ! err path:", dir)
|
log.Fatalln(PreError, "dirs must be relative paths ! err path:", dir)
|
||||||
}
|
}
|
||||||
if darr[0] == "." {
|
if darr[0] == "." {
|
||||||
cfg.Monitor.RootWatch = true
|
|
||||||
if len(darr) == 2 && darr[1] == "*" {
|
if len(darr) == 2 && darr[1] == "*" {
|
||||||
// The highest priority
|
// The highest priority
|
||||||
dirsMap = map[string]bool{
|
dirsMap = map[string]bool{
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ type FileGirl struct {
|
|||||||
Types []string `yaml:"types"`
|
Types []string `yaml:"types"`
|
||||||
IncludeDirs []string `yaml:"includeDirs"`
|
IncludeDirs []string `yaml:"includeDirs"`
|
||||||
ExceptDirs []string `yaml:"exceptDirs"`
|
ExceptDirs []string `yaml:"exceptDirs"`
|
||||||
// project root watcher flag
|
|
||||||
RootWatch bool `yaml:"-"`
|
|
||||||
// convert to
|
// convert to
|
||||||
TypesMap map[string]bool `yaml:"-"`
|
TypesMap map[string]bool `yaml:"-"`
|
||||||
IncludeDirsMap map[string]bool `yaml:"-"`
|
IncludeDirsMap map[string]bool `yaml:"-"`
|
||||||
|
|||||||
@@ -55,5 +55,9 @@ func listFile(folder string, fun func(string)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func relativePath(folder, p string) string {
|
func relativePath(folder, p string) string {
|
||||||
return strings.TrimPrefix(p, folder)
|
s := strings.ReplaceAll(strings.TrimPrefix(p, folder), "\\", "/")
|
||||||
|
if strings.HasPrefix(s, "/") && len(s) > 1 {
|
||||||
|
s = s[1:]
|
||||||
|
}
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user