Skip to content

Commit

Permalink
cmd: watch now works with file input and output (not just dirs), see #…
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Mar 9, 2021
1 parent a242db2 commit 9b77a7e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions cmd/minify/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,10 @@ func run() int {
return 1
}
}
if !dirDst && (sync || watch) {
if !dirDst && sync {
if sync {
Error.Println("--sync requires destination to be a directory")
}
if watch {
Error.Println("--watch requires destination to be a directory")
}
return 1
}
if verbose {
Expand Down Expand Up @@ -373,6 +370,7 @@ func run() int {
go minifyWorker(chanTasks, chanFails)
}

fmt.Println(watch)
if !watch {
for _, task := range tasks {
chanTasks <- task
Expand All @@ -395,6 +393,7 @@ func run() int {
if !recursive {
files = inputs
}
fmt.Println(files)
for _, filename := range files {
watcher.AddPath(filename)
if filename == output {
Expand Down
2 changes: 1 addition & 1 deletion cmd/minify/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (w *Watcher) Run() chan string {
watched = true
break
}
} else if rel, err := filepath.Rel(path, event.Name); err == nil {
} else if _, err := filepath.Rel(path, event.Name); err == nil {
// dir in w.paths
watched = true
break
Expand Down

0 comments on commit 9b77a7e

Please sign in to comment.