diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-02-19 10:39:36 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-02-19 17:14:35 +0100 |
commit | 0b96aba022d51cf9939605c029bb8dba806653a1 (patch) | |
tree | f7d2883a6ea85546e4e9536f6ccfb184bc4293af /commands | |
parent | fa520a2d983b982394ad10088393fb303e48980a (diff) |
commands: Add "hugo mod verify"
See #6907
Diffstat (limited to 'commands')
-rw-r--r-- | commands/mod.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/commands/mod.go b/commands/mod.go index 582ebfda7..61e3c74e6 100644 --- a/commands/mod.go +++ b/commands/mod.go @@ -29,7 +29,28 @@ type modCmd struct { *baseBuilderCmd } +func (c *modCmd) newVerifyCmd() *cobra.Command { + var clean bool + + verifyCmd := &cobra.Command{ + Use: "verify", + Short: "Verify dependencies.", + Long: `Verify checks that the dependencies of the current module, which are stored in a local downloaded source cache, have not been modified since being downloaded. +`, + RunE: func(cmd *cobra.Command, args []string) error { + return c.withModsClient(true, func(c *modules.Client) error { + return c.Verify(clean) + }) + }, + } + + verifyCmd.Flags().BoolVarP(&clean, "clean", "", false, "delete module cache for dependencies that fail verification") + + return verifyCmd +} + func (b *commandsBuilder) newModCmd() *modCmd { + c := &modCmd{} const commonUsage = ` @@ -184,6 +205,7 @@ If a module is vendored, that is where Hugo will look for it's dependencies. }) }, }, + c.newVerifyCmd(), &cobra.Command{ Use: "tidy", Short: "Remove unused entries in go.mod and go.sum.", |