Skip to content

Commit

Permalink
cmd: trailing slash for destination path resolves ambiguity when writ…
Browse files Browse the repository at this point in the history
…ing to a directory
  • Loading branch information
tdewolff committed Jul 31, 2023
1 parent b59895a commit 3dedbc7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/minify/README.md
Expand Up @@ -172,7 +172,9 @@ 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.
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. Both `src/` and `src/*` are equivalent, except that the second case uses input expansion from bash and ignores hidden files starting with a dot.

A trailing slash in the destination path will write a single file into a directory instead of to a file of that name.

### 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.
Expand Down
3 changes: 3 additions & 0 deletions cmd/minify/main.go
Expand Up @@ -966,6 +966,9 @@ Next:

// IsDir returns true if the passed string looks like it specifies a directory, false otherwise.
func IsDir(dir string) bool {
if 0 < len(dir) && dir[len(dir)-1] == '/' {
return true
}
info, err := os.Lstat(dir)
return err == nil && info.Mode().IsDir() && info.Mode()&os.ModeSymlink == 0
}
Expand Down

0 comments on commit 3dedbc7

Please sign in to comment.