add ignore suffix of the listener file
This commit is contained in:
parent
da54305188
commit
8dc1ebe6d9
@ -96,6 +96,11 @@ monitor:
|
||||
types:
|
||||
- .go
|
||||
|
||||
# 不监听文件的格式,此类文件更改不会执行 command 中的命令
|
||||
# .DS_Store 后缀为 .DS_Store 的文件更改,不会执行 command 中的命令
|
||||
types:
|
||||
- .DS_Store
|
||||
|
||||
# 监听的事件类型,发生此类事件才执行 command 中的命令
|
||||
# 没有该配置默认监听所有事件
|
||||
# write 写入文件事件
|
||||
|
@ -93,6 +93,11 @@ monitor:
|
||||
types:
|
||||
- .go
|
||||
|
||||
# ignore the suffix of the listener file, which changes the file not to execute commands
|
||||
# .DS_Store file changes suffixed with .go not execute commands
|
||||
types:
|
||||
- .DS_Store
|
||||
|
||||
# the type of event to listen to. Only when such an event occurs can the command in command be executed
|
||||
# without this configuration, all events will be monitored by default
|
||||
# write write file event
|
||||
|
13
fileboy.go
13
fileboy.go
@ -72,6 +72,7 @@ func parseConfig() {
|
||||
}
|
||||
// init map
|
||||
cfg.Monitor.TypesMap = map[string]bool{}
|
||||
cfg.Monitor.ExceptTypesMap = map[string]bool{}
|
||||
cfg.Monitor.IncludeDirsMap = map[string]bool{}
|
||||
cfg.Monitor.ExceptDirsMap = map[string]bool{}
|
||||
cfg.Monitor.IncludeDirsRec = map[string]bool{}
|
||||
@ -83,6 +84,9 @@ func parseConfig() {
|
||||
for _, v := range cfg.Instruction {
|
||||
cfg.InstructionMap[v] = true
|
||||
}
|
||||
for _, v := range cfg.Monitor.ExceptTypes {
|
||||
cfg.Monitor.ExceptTypesMap[v] = true
|
||||
}
|
||||
log.Printf("%+v", cfg)
|
||||
}
|
||||
|
||||
@ -92,8 +96,13 @@ func eventDispatcher(event fsnotify.Event) {
|
||||
}
|
||||
ext := path.Ext(event.Name)
|
||||
if len(cfg.Monitor.Types) > 0 &&
|
||||
!keyInMonitorTypesMap(".*", cfg) &&
|
||||
!keyInMonitorTypesMap(ext, cfg) {
|
||||
!keyInMonitorTypesMap(".*", cfg.Monitor.TypesMap) &&
|
||||
!keyInMonitorTypesMap(ext, cfg.Monitor.TypesMap) {
|
||||
return
|
||||
}
|
||||
|
||||
if len(cfg.Monitor.ExceptTypes) > 0 &&
|
||||
keyInMonitorTypesMap(ext, cfg.Monitor.ExceptTypesMap) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -6,11 +6,13 @@ type FileGirl struct {
|
||||
}
|
||||
Monitor struct {
|
||||
Types []string `yaml:"types"`
|
||||
ExceptTypes []string `yaml:"exceptTypes"`
|
||||
IncludeDirs []string `yaml:"includeDirs"`
|
||||
ExceptDirs []string `yaml:"exceptDirs"`
|
||||
Events []string `yaml:"events"`
|
||||
// convert to
|
||||
TypesMap map[string]bool `yaml:"-"`
|
||||
ExceptTypesMap map[string]bool `yaml:"-"`
|
||||
IncludeDirsMap map[string]bool `yaml:"-"`
|
||||
ExceptDirsMap map[string]bool `yaml:"-"`
|
||||
DirsMap map[string]bool `yaml:"-"`
|
||||
|
5
raw.go
5
raw.go
@ -32,6 +32,11 @@ monitor:
|
||||
types:
|
||||
- .go
|
||||
|
||||
# 不监听文件的格式,此类文件更改不会执行 command 中的命令
|
||||
# .DS_Store 后缀为 .DS_Store 的文件更改,不会执行 command 中的命令
|
||||
types:
|
||||
- .DS_Store
|
||||
|
||||
# 监听的事件类型,发生此类事件才执行 command 中的命令
|
||||
# 没有该配置默认监听所有事件
|
||||
# write 写入文件事件
|
||||
|
Loading…
Reference in New Issue
Block a user