support absolute dir

main
ehlxr 2020-11-11 15:17:48 +08:00
parent 4b3bf5e77c
commit 4f3ad86984
1 changed files with 11 additions and 10 deletions

View File

@ -55,9 +55,9 @@ type changedFile struct {
Event string Event string
} }
func parseConfig() { func parseConfig(filegirlYamlPath string) {
cfg = new(FileGirl) cfg = new(FileGirl)
fc, err := ioutil.ReadFile(getFileGirlPath()) fc, err := ioutil.ReadFile(filegirlYamlPath)
if err != nil { if err != nil {
logError("the filegirl.yaml file in", projectFolder, "is not exist! ", err) logError("the filegirl.yaml file in", projectFolder, "is not exist! ", err)
fmt.Print(firstRunHelp) fmt.Print(firstRunHelp)
@ -132,9 +132,9 @@ func addWatcher() {
if len(darr) < 1 || len(darr) > 2 { if len(darr) < 1 || len(darr) > 2 {
logAndExit("filegirl section monitor dirs is error. ", dir) logAndExit("filegirl section monitor dirs is error. ", dir)
} }
if strings.HasPrefix(darr[0], "/") { //if strings.HasPrefix(darr[0], "/") {
logAndExit("dirs must be relative paths ! err path:", dir) // logAndExit("dirs must be relative paths ! err path:", dir)
} //}
if darr[0] == "." { if darr[0] == "." {
if len(darr) == 2 && darr[1] == "*" { if len(darr) == 2 && darr[1] == "*" {
// The highest priority // The highest priority
@ -150,7 +150,8 @@ func addWatcher() {
dirsMap[projectFolder] = true dirsMap[projectFolder] = true
} }
} else { } else {
md := projectFolder + "/" + darr[0] //md := projectFolder + "/" + darr[0]
md := darr[0]
dirsMap[md] = true dirsMap[md] = true
if len(darr) == 2 && darr[1] == "*" { if len(darr) == 2 && darr[1] == "*" {
listFile(md, func(d string) { listFile(md, func(d string) {
@ -263,7 +264,7 @@ func parseArgs() {
switch { switch {
case len(os.Args) == 1: case len(os.Args) == 1:
show() show()
parseConfig() parseConfig(getFileGirlPath())
done := make(chan bool) done := make(chan bool)
initWatcher() initWatcher()
defer watcher.Close() defer watcher.Close()
@ -304,13 +305,13 @@ func parseArgs() {
logUInfo("profile filegirl.yaml created ok") logUInfo("profile filegirl.yaml created ok")
return return
case "exec": case "exec":
parseConfig() parseConfig(getFileGirlPath())
newTaskMan(0, cfg.Notifier.CallUrl).run(new(changedFile)) newTaskMan(0, cfg.Notifier.CallUrl).run(new(changedFile))
return return
case "profile": case "profile":
filegirlYamlName = os.Args[2] filegirlYamlPath := os.Args[2]
show() show()
parseConfig() parseConfig(filegirlYamlPath)
done := make(chan bool) done := make(chan bool)
initWatcher() initWatcher()
defer watcher.Close() defer watcher.Close()