From b59895a2872f8d4a374b9e85f9c36ece4ba5718b Mon Sep 17 00:00:00 2001 From: Taco de Wolff Date: Mon, 31 Jul 2023 11:02:22 +0200 Subject: [PATCH] cmd: trailing slash in source path will not copy directory itself but all the files inside --- cmd/minify/README.md | 2 ++ cmd/minify/main.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/cmd/minify/README.md b/cmd/minify/README.md index 2a5247aa9b..b14f6a16bf 100644 --- a/cmd/minify/README.md +++ b/cmd/minify/README.md @@ -172,6 +172,8 @@ Minify only javascript files in **src/**: $ minify -r -o out/ --match="\.js$" src ``` +A trailing slash in the source path will copy all files inside the directory, while omitting the trainling slash will copy the directory as well. + ### Concatenate When multiple inputs are given and the output is either standard output or a single file, it will concatenate the files together if you use the bundle option. diff --git a/cmd/minify/main.go b/cmd/minify/main.go index a7a9866b7c..cec53aafa1 100644 --- a/cmd/minify/main.go +++ b/cmd/minify/main.go @@ -346,6 +346,9 @@ func run() int { for i, input := range inputs { inputs[i] = filepath.Clean(input) + if input[len(input)-1] == '/' { + inputs[i] += "/" + } } // set output file or directory, empty means stdout