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:
Diffstat (limited to 'modules/client.go')
-rw-r--r--modules/client.go33
1 files changed, 17 insertions, 16 deletions
diff --git a/modules/client.go b/modules/client.go
index 6e1cfe881..78ba9f5ae 100644
--- a/modules/client.go
+++ b/modules/client.go
@@ -47,7 +47,8 @@ import (
"github.com/gohugoio/hugo/common/hugio"
- "github.com/pkg/errors"
+ "errors"
+
"github.com/spf13/afero"
)
@@ -241,7 +242,7 @@ func (c *Client) Vendor() error {
// See https://github.com/gohugoio/hugo/issues/8239
// This is an error situation. We need something to vendor.
if t.Mounts() == nil {
- return errors.Errorf("cannot vendor module %q, need at least one mount", t.Path())
+ return fmt.Errorf("cannot vendor module %q, need at least one mount", t.Path())
}
fmt.Fprintln(&modulesContent, "# "+t.Path()+" "+t.Version())
@@ -253,22 +254,22 @@ func (c *Client) Vendor() error {
targetFilename := filepath.Join(vendorDir, t.Path(), mount.Source)
fi, err := c.fs.Stat(sourceFilename)
if err != nil {
- return errors.Wrap(err, "failed to vendor module")
+ return fmt.Errorf("failed to vendor module: %w", err)
}
if fi.IsDir() {
if err := hugio.CopyDir(c.fs, sourceFilename, targetFilename, nil); err != nil {
- return errors.Wrap(err, "failed to copy module to vendor dir")
+ return fmt.Errorf("failed to copy module to vendor dir: %w", err)
}
} else {
targetDir := filepath.Dir(targetFilename)
if err := c.fs.MkdirAll(targetDir, 0755); err != nil {
- return errors.Wrap(err, "failed to make target dir")
+ return fmt.Errorf("failed to make target dir: %w", err)
}
if err := hugio.CopyFile(c.fs, sourceFilename, targetFilename); err != nil {
- return errors.Wrap(err, "failed to copy module file to vendor")
+ return fmt.Errorf("failed to copy module file to vendor: %w", err)
}
}
}
@@ -278,7 +279,7 @@ func (c *Client) Vendor() error {
_, err := c.fs.Stat(resourcesDir)
if err == nil {
if err := hugio.CopyDir(c.fs, resourcesDir, filepath.Join(vendorDir, t.Path(), files.FolderResources), nil); err != nil {
- return errors.Wrap(err, "failed to copy resources to vendor dir")
+ return fmt.Errorf("failed to copy resources to vendor dir: %w", err)
}
}
@@ -287,7 +288,7 @@ func (c *Client) Vendor() error {
_, err = c.fs.Stat(configDir)
if err == nil {
if err := hugio.CopyDir(c.fs, configDir, filepath.Join(vendorDir, t.Path(), "config"), nil); err != nil {
- return errors.Wrap(err, "failed to copy config dir to vendor dir")
+ return fmt.Errorf("failed to copy config dir to vendor dir: %w", err)
}
}
@@ -361,7 +362,7 @@ func (c *Client) get(args ...string) error {
args = append([]string{"-d"}, args...)
}
if err := c.runGo(context.Background(), c.logger.Out(), append([]string{"get"}, args...)...); err != nil {
- errors.Wrapf(err, "failed to get %q", args)
+ return fmt.Errorf("failed to get %q: %w", args, err)
}
return nil
}
@@ -372,7 +373,7 @@ func (c *Client) get(args ...string) error {
func (c *Client) Init(path string) error {
err := c.runGo(context.Background(), c.logger.Out(), "mod", "init", path)
if err != nil {
- return errors.Wrap(err, "failed to init modules")
+ return fmt.Errorf("failed to init modules: %w", err)
}
c.GoModulesFilename = filepath.Join(c.ccfg.WorkingDir, goModFilename)
@@ -458,7 +459,7 @@ func (c *Client) listGoMods() (goModules, error) {
out := ioutil.Discard
err := c.runGo(context.Background(), out, args...)
if err != nil {
- return errors.Wrap(err, "failed to download modules")
+ return fmt.Errorf("failed to download modules: %w", err)
}
return nil
}
@@ -477,7 +478,7 @@ func (c *Client) listGoMods() (goModules, error) {
}
err := c.runGo(context.Background(), b, args...)
if err != nil {
- return errors.Wrap(err, "failed to list modules")
+ return fmt.Errorf("failed to list modules: %w", err)
}
dec := json.NewDecoder(b)
@@ -487,7 +488,7 @@ func (c *Client) listGoMods() (goModules, error) {
if err == io.EOF {
break
}
- return errors.Wrap(err, "failed to decode modules list")
+ return fmt.Errorf("failed to decode modules list: %w", err)
}
if err := handle(m); err != nil {
@@ -657,7 +658,7 @@ If you then run 'hugo mod graph' it should resolve itself to the most recent ver
_, ok := err.(*exec.ExitError)
if !ok {
- return errors.Errorf("failed to execute 'go %v': %s %T", args, err, err)
+ return fmt.Errorf("failed to execute 'go %v': %s %T", args, err, err)
}
// Too old Go version
@@ -666,7 +667,7 @@ If you then run 'hugo mod graph' it should resolve itself to the most recent ver
return nil
}
- return errors.Errorf("go command failed: %s", stderr)
+ return fmt.Errorf("go command failed: %s", stderr)
}
@@ -706,7 +707,7 @@ func (c *Client) shouldVendor(path string) bool {
}
func (c *Client) createThemeDirname(modulePath string, isProjectMod bool) (string, error) {
- invalid := errors.Errorf("invalid module path %q; must be relative to themesDir when defined outside of the project", modulePath)
+ invalid := fmt.Errorf("invalid module path %q; must be relative to themesDir when defined outside of the project", modulePath)
modulePath = filepath.Clean(modulePath)
if filepath.IsAbs(modulePath) {