commands: Add "hugo mod verify"

See #6907
This commit is contained in:
Bjørn Erik Pedersen 2020-02-19 10:39:36 +01:00
parent fa520a2d98
commit 0b96aba022
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
4 changed files with 85 additions and 13 deletions

View file

@ -17,6 +17,8 @@ import (
"io"
"os"
"github.com/gohugoio/hugo/hugofs"
"github.com/pkg/errors"
"github.com/spf13/afero"
)
@ -121,18 +123,6 @@ func (c *Cache) pruneRootDir(force bool) (int, error) {
return 0, nil
}
counter := 0
// Module cache has 0555 directories; make them writable in order to remove content.
afero.Walk(c.Fs, c.pruneAllRootDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return nil
}
if info.IsDir() {
counter++
c.Fs.Chmod(path, 0777)
}
return nil
})
return 1, c.Fs.RemoveAll(c.pruneAllRootDir)
return hugofs.MakeReadableAndRemoveAllModulePkgDir(c.Fs, c.pruneAllRootDir)
}