diff --git a/loader/directory_refresher.go b/loader/directory_refresher.go index 7796f56..7e17935 100644 --- a/loader/directory_refresher.go +++ b/loader/directory_refresher.go @@ -12,8 +12,8 @@ func (d *DirectoryRefresher) WatchDirectory(runtimePath string, appDirPath strin } func (d *DirectoryRefresher) ShouldRefresh(path string, op FileSystemOp) bool { - if filepath.Base(path) == d.currDir && - op == Write || op == Create || op == Chmod { + if filepath.Dir(path) == d.currDir && + (op == Write || op == Create || op == Chmod) { return true } return false diff --git a/loader/loader_test.go b/loader/loader_test.go index 7119e33..262a7d1 100644 --- a/loader/loader_test.go +++ b/loader/loader_test.go @@ -158,4 +158,17 @@ func TestDirectoryRefresher(t *testing.T) { snapshot = loader.Snapshot() assert.Equal("hello2", snapshot.Get("file2")) + + // Write to the file + f, err := os.OpenFile(appDir+"/file2", os.O_RDWR, os.ModeAppend) + assert.NoError(err) + _, err = f.WriteString("hello3") + assert.NoError(err) + f.Sync() + + // Wait for the update + <-runtime_update + + snapshot = loader.Snapshot() + assert.Equal("hello3", snapshot.Get("file2")) }