mirror of
https://github.com/TECHNOFAB11/jsonnet-bundler.git
synced 2025-12-11 23:50:05 +01:00
Remove symlink before creating new ones
This commit is contained in:
parent
d3bb1f4ea4
commit
e1580b7968
1 changed files with 9 additions and 1 deletions
10
pkg/local.go
10
pkg/local.go
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"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 {
|
||||||
|
|
@ -39,7 +40,14 @@ func (p *LocalPackage) Install(ctx context.Context, name, dir, version string) (
|
||||||
return "", fmt.Errorf("failed to get current working directory: %v", err)
|
return "", fmt.Errorf("failed to get current working directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.Symlink(filepath.Join(wd, p.Source.Directory), filepath.Join(wd, dir, name))
|
destPath := filepath.Join(dir, name)
|
||||||
|
|
||||||
|
err = os.RemoveAll(destPath)
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.Wrap(err, "failed to clean previous destination path")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = os.Symlink(filepath.Join(wd, p.Source.Directory), filepath.Join(wd, destPath))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to create symlink for local dependency: %v", err)
|
return "", fmt.Errorf("failed to create symlink for local dependency: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue