Skip to content

Commit

Permalink
cmd: don't reminify file on watching task with input==output the firs…
Browse files Browse the repository at this point in the history
…t time
  • Loading branch information
tdewolff committed Sep 21, 2022
1 parent 6923a73 commit ec00fe0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/minify/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ func (w *Watcher) Run() chan string {
files := make(chan string, 10)
go func() {
changetimes := map[string]time.Time{}

// prevent reminifying the first time for files with input==output
for path := range w.paths {
if info, err := os.Lstat(path); err == nil && info.Mode().IsRegular() {
changetimes[path] = time.Now()
}
}

for w.watcher.Events != nil && w.watcher.Errors != nil {
select {
case event, ok := <-w.watcher.Events:
Expand Down

0 comments on commit ec00fe0

Please sign in to comment.