Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-03-03 13:00:45 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-03-03 15:29:58 +0300
commit760a87a45a0a3e6a581851e5cf4fe440e9a8c655 (patch)
treeadae33730f46b231461906b90c881f2a05b284ff /commands
parent3d3fa5c3fe5ee0c9df59d682ee0acaba71a06ae1 (diff)
commands: Add --all flag to hugo mod clean
Diffstat (limited to 'commands')
-rw-r--r--commands/mod.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/commands/mod.go b/commands/mod.go
index 0b88df666..81f660f43 100644
--- a/commands/mod.go
+++ b/commands/mod.go
@@ -18,6 +18,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "regexp"
"github.com/gohugoio/hugo/modules"
"github.com/spf13/cobra"
@@ -49,8 +50,11 @@ func (c *modCmd) newVerifyCmd() *cobra.Command {
return verifyCmd
}
+var moduleNotFoundRe = regexp.MustCompile("module.*not found")
+
func (c *modCmd) newCleanCmd() *cobra.Command {
var pattern string
+ var all bool
cmd := &cobra.Command{
Use: "clean",
Short: "Delete the Hugo Module cache for the current project.",
@@ -62,6 +66,16 @@ Also note that if you configure a positive maxAge for the "modules" file cache,
`,
RunE: func(cmd *cobra.Command, args []string) error {
+ if all {
+ com, err := c.initConfig(false)
+
+ if err != nil && !moduleNotFoundRe.MatchString(err.Error()) {
+ return err
+ }
+
+ _, err = com.hugo().FileCaches.ModulesCache().Prune(true)
+ return err
+ }
return c.withModsClient(true, func(c *modules.Client) error {
return c.Clean(pattern)
})
@@ -69,6 +83,7 @@ Also note that if you configure a positive maxAge for the "modules" file cache,
}
cmd.Flags().StringVarP(&pattern, "pattern", "", "", `pattern matching module paths to clean (all if not set), e.g. "**hugo*"`)
+ cmd.Flags().BoolVarP(&all, "all", "", false, "clean entire module cache")
return cmd
}