Skip to content

Commit

Permalink
feat: expand env in watch-file path
Browse files Browse the repository at this point in the history
Signed-off-by: Pouyan Heyratpour <[email protected]>
  • Loading branch information
pouyanh committed Mar 7, 2024
1 parent 7a5085e commit 0cdb975
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 6 additions & 5 deletions config/viper/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ func (k Kill) decode() config.Kill {
}

type Command struct {
Shell string `mapstructure:"shell"`
Env []string `mapstructure:"env"`
Exec string `mapstructure:"exec"`
Path string `mapstructure:"path"`
Shell string `mapstructure:"shell"`
Env []string `mapstructure:"env"`
Exec string `mapstructure:"exec"`
Path string `mapstructure:"path"`
}

func (c Command) decode() config.Command {
Expand All @@ -181,8 +181,9 @@ func testStringZero(v string) bool {
return len(strings.TrimSpace(v)) == 0
}

//nolint:unused
func testStringSliceZero(v []string) bool {
return v == nil || len(v) == 0
return len(v) == 0
}

func testNil[T any](v *T) bool {
Expand Down
7 changes: 5 additions & 2 deletions polywatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"os/exec"
"os/signal"
"path/filepath"
"strings"
"sync"
"syscall"
Expand Down Expand Up @@ -74,11 +75,13 @@ func newPolyWatcher(cfg config.Watcher) (*polyWatcher, error) {

w := watcher.New()
for _, wf := range cfg.Watch.Files {
path := filepath.Clean(os.ExpandEnv(wf.Path))

var err error
if wf.Recursive {
err = w.AddRecursive(wf.Path)
err = w.AddRecursive(path)
} else {
err = w.Add(wf.Path)
err = w.Add(path)
}

if err != nil {
Expand Down

0 comments on commit 0cdb975

Please sign in to comment.