Skip to content

Commit

Permalink
cmd: allow use of dash - for source/destination to mean stdin/stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Jul 31, 2023
1 parent 3dedbc7 commit e87a716
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/minify/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ func run() int {
return 1
}
inputs := f.Args()
if len(inputs) == 1 && inputs[0] == "-" {
inputs = inputs[:0]
} else if output == "-" {
output = ""
}
useStdin := len(inputs) == 0

Error = log.New(ioutil.Discard, "", 0)
Expand Down Expand Up @@ -345,6 +350,10 @@ func run() int {
////////////////

for i, input := range inputs {
if input == "-" {
Error.Println("cannot mix files and stdin as input")
return 1
}
inputs[i] = filepath.Clean(input)
if input[len(input)-1] == '/' {
inputs[i] += "/"
Expand Down

0 comments on commit e87a716

Please sign in to comment.