modules: Improve "hugo mod clean"

* Only clean project modules
* Optional glob pattern of module paths to clean

Closes #6907
This commit is contained in:
Bjørn Erik Pedersen
2020-02-19 16:59:54 +01:00
parent 0b96aba022
commit dce210ab56
3 changed files with 62 additions and 22 deletions

View File

@@ -15,6 +15,7 @@
package hugofs
import (
"fmt"
"os"
"strings"
@@ -97,7 +98,7 @@ func isWrite(flag int) bool {
func MakeReadableAndRemoveAllModulePkgDir(fs afero.Fs, dir string) (int, error) {
// Safe guard
if !strings.Contains(dir, "pkg") {
panic("invalid dir")
panic(fmt.Sprint("invalid dir:", dir))
}
counter := 0