Skip to content

Commit

Permalink
Follow symlink if required (#137)
Browse files Browse the repository at this point in the history
* Follow symlink is required

* update air_example.toml, ignore symlink for files

Co-authored-by: canzheng <[email protected]>
  • Loading branch information
zhengcan and canzheng authored Apr 23, 2021
1 parent 8b2f43f commit d012f24
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions air_example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ exclude_file = []
exclude_regex = []
# Exclude unchanged files.
exclude_unchanged = true
# Follow symlink for directories
follow_symlink = true
# This log file places in your tmp_dir.
log = "air.log"
# It's not necessary to trigger build each time file changes if it's too frequent.
Expand Down
1 change: 1 addition & 0 deletions runner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type cfgBuild struct {
ExcludeFile []string `toml:"exclude_file"`
ExcludeRegex []string `toml:"exclude_regex"`
ExcludeUnchanged bool `toml:"exclude_unchanged"`
FollowSymlink bool `toml:"follow_symlink"`
Delay int `toml:"delay"`
StopOnError bool `toml:"stop_on_error"`
SendInterrupt bool `toml:"send_interrupt"`
Expand Down
19 changes: 19 additions & 0 deletions runner/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,25 @@ func (e *Engine) cacheFileChecksums(root string) error {
e.watcherDebug("!exclude checksum %s", e.config.rel(path))
return filepath.SkipDir
}

// Follow symbolic link
if e.config.Build.FollowSymlink && (info.Mode()&os.ModeSymlink) > 0 {
link, err := filepath.EvalSymlinks(path)
if err != nil {
return err
}
linkInfo, err := os.Stat(link)
if err != nil {
return err
}
if linkInfo.IsDir() {
err = e.watchDir(link)
if err != nil {
return err
}
}
return nil
}
}

if e.isExcludeFile(path) || !e.isIncludeExt(path) {
Expand Down

0 comments on commit d012f24

Please sign in to comment.