Skip to content

Commit

Permalink
fix: fix bindir
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Aug 25, 2021
1 parent 84eee9d commit 3e1eca8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/controller/config.go
Expand Up @@ -44,14 +44,14 @@ type Param struct {

var errConfigFileNotFound = errors.New("configuration file isn't found")

func (ctrl *Controller) readConfig(wd, configFilePath string, cfg *Config) error {
if configFilePath == "" {
p := ctrl.ConfigFinder.Find(wd)
if p == "" {
return errConfigFileNotFound
}
configFilePath = p
func (ctrl *Controller) getConfigFilePath(wd, configFilePath string) string {
if configFilePath != "" {
return configFilePath
}
return ctrl.ConfigFinder.Find(wd)
}

func (ctrl *Controller) readConfig(wd, configFilePath string, cfg *Config) error {
file, err := ctrl.ConfigReader.Read(configFilePath)
if err != nil {
return err //nolint:wrapcheck
Expand Down
7 changes: 7 additions & 0 deletions pkg/controller/exec.go
Expand Up @@ -22,9 +22,16 @@ func (ctrl *Controller) Exec(ctx context.Context, param *Param, args []string) e
if err != nil {
return fmt.Errorf("get the current directory: %w", err)
}
param.ConfigFilePath = ctrl.getConfigFilePath(wd, param.ConfigFilePath)
if param.ConfigFilePath == "" {
return errConfigFileNotFound
}
if err := ctrl.readConfig(wd, param.ConfigFilePath, cfg); err != nil {
return err
}
if cfg.BinDir == "" {
cfg.BinDir = filepath.Join(filepath.Dir(param.ConfigFilePath), ".aqua", "bin")
}
inlineRepo := make(map[string]*PackageInfo, len(cfg.InlineRepository))
for _, pkgInfo := range cfg.InlineRepository {
inlineRepo[pkgInfo.Name] = pkgInfo
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/install.go
Expand Up @@ -16,6 +16,10 @@ func (ctrl *Controller) Install(ctx context.Context, param *Param) error {
if err != nil {
return fmt.Errorf("get the current directory: %w", err)
}
param.ConfigFilePath = ctrl.getConfigFilePath(wd, param.ConfigFilePath)
if param.ConfigFilePath == "" {
return errConfigFileNotFound
}
if err := ctrl.readConfig(wd, param.ConfigFilePath, cfg); err != nil {
return err
}
Expand Down

0 comments on commit 3e1eca8

Please sign in to comment.