mirror of
https://github.com/TECHNOFAB11/jsonnet-bundler.git
synced 2025-12-11 23:50:05 +01:00
Revert to pkg/errors usage for Go 1.11 & 1.12
This commit is contained in:
parent
f1b13bd42d
commit
442ccc505a
1 changed files with 5 additions and 5 deletions
10
pkg/local.go
10
pkg/local.go
|
|
@ -16,11 +16,11 @@ package pkg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/jsonnet-bundler/jsonnet-bundler/spec"
|
"github.com/jsonnet-bundler/jsonnet-bundler/spec"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LocalPackage struct {
|
type LocalPackage struct {
|
||||||
|
|
@ -36,7 +36,7 @@ func NewLocalPackage(source *spec.LocalSource) Interface {
|
||||||
func (p *LocalPackage) Install(ctx context.Context, name, dir, version string) (lockVersion string, err error) {
|
func (p *LocalPackage) Install(ctx context.Context, name, dir, version string) (lockVersion string, err error) {
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to get current working directory: %w", err)
|
return "", errors.Wrap(err, "failed to get current working directory: %w")
|
||||||
}
|
}
|
||||||
|
|
||||||
oldname := filepath.Join(wd, p.Source.Directory)
|
oldname := filepath.Join(wd, p.Source.Directory)
|
||||||
|
|
@ -44,17 +44,17 @@ func (p *LocalPackage) Install(ctx context.Context, name, dir, version string) (
|
||||||
|
|
||||||
err = os.RemoveAll(newname)
|
err = os.RemoveAll(newname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to clean previous destination path: %w", err)
|
return "", errors.Wrap(err, "failed to clean previous destination path: %w")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = os.Stat(oldname)
|
_, err = os.Stat(oldname)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return "", fmt.Errorf("symlink destination path does not exist: %w", err)
|
return "", errors.Wrap(err, "symlink destination path does not exist: %w")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.Symlink(oldname, newname)
|
err = os.Symlink(oldname, newname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to create symlink for local dependency: %w", err)
|
return "", errors.Wrap(err, "failed to create symlink for local dependency: %w")
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", nil
|
return "", nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue