fix LocalPackage install for relative paths

The vendor dir (here called "dir") is already joined with the CWD
in installCommand(). it should not be joined again here.

Also adds a logging message to show that a local package was
installed.
This commit is contained in:
Benoit Gagnon 2020-04-30 22:45:49 -04:00
parent ccd60c13eb
commit 13568d0b65
2 changed files with 6 additions and 2 deletions

View file

@ -72,7 +72,8 @@ func installCommand(dir, jsonnetHome string, uris []string, single bool) int {
}
}
locked, err := pkg.Ensure(jsonnetFile, filepath.Join(dir, jsonnetHome), lockFile.Dependencies)
vendorDir := filepath.Join(dir, jsonnetHome)
locked, err := pkg.Ensure(jsonnetFile, vendorDir, lockFile.Dependencies)
kingpin.FatalIfError(err, "failed to install packages")
pkg.CleanLegacyName(jsonnetFile.Dependencies)

View file

@ -19,6 +19,7 @@ import (
"os"
"path/filepath"
"github.com/fatih/color"
"github.com/pkg/errors"
"github.com/jsonnet-bundler/jsonnet-bundler/spec/v1/deps"
@ -41,7 +42,7 @@ func (p *LocalPackage) Install(ctx context.Context, name, dir, version string) (
}
oldname := filepath.Join(wd, p.Source.Directory)
newname := filepath.Join(wd, filepath.Join(dir, name))
newname := filepath.Join(dir, name)
err = os.RemoveAll(newname)
if err != nil {
@ -58,5 +59,7 @@ func (p *LocalPackage) Install(ctx context.Context, name, dir, version string) (
return "", errors.Wrap(err, "failed to create symlink for local dependency: %w")
}
color.Magenta("LOCAL %s -> %s", name, oldname)
return "", nil
}