Skip to content

Commit d012f24

Browse files
zhengcancanzheng
and
canzheng
authored
Follow symlink if required (#137)
* Follow symlink is required * update air_example.toml, ignore symlink for files Co-authored-by: canzheng <[email protected]>
1 parent 8b2f43f commit d012f24

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

air_example.toml

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ exclude_file = []
2424
exclude_regex = []
2525
# Exclude unchanged files.
2626
exclude_unchanged = true
27+
# Follow symlink for directories
28+
follow_symlink = true
2729
# This log file places in your tmp_dir.
2830
log = "air.log"
2931
# It's not necessary to trigger build each time file changes if it's too frequent.

runner/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type cfgBuild struct {
3939
ExcludeFile []string `toml:"exclude_file"`
4040
ExcludeRegex []string `toml:"exclude_regex"`
4141
ExcludeUnchanged bool `toml:"exclude_unchanged"`
42+
FollowSymlink bool `toml:"follow_symlink"`
4243
Delay int `toml:"delay"`
4344
StopOnError bool `toml:"stop_on_error"`
4445
SendInterrupt bool `toml:"send_interrupt"`

runner/engine.go

+19
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,25 @@ func (e *Engine) cacheFileChecksums(root string) error {
143143
e.watcherDebug("!exclude checksum %s", e.config.rel(path))
144144
return filepath.SkipDir
145145
}
146+
147+
// Follow symbolic link
148+
if e.config.Build.FollowSymlink && (info.Mode()&os.ModeSymlink) > 0 {
149+
link, err := filepath.EvalSymlinks(path)
150+
if err != nil {
151+
return err
152+
}
153+
linkInfo, err := os.Stat(link)
154+
if err != nil {
155+
return err
156+
}
157+
if linkInfo.IsDir() {
158+
err = e.watchDir(link)
159+
if err != nil {
160+
return err
161+
}
162+
}
163+
return nil
164+
}
146165
}
147166

148167
if e.isExcludeFile(path) || !e.isIncludeExt(path) {

0 commit comments

Comments
 (0)