Skip to content

Commit

Permalink
Fix base path detection when importing lda command
Browse files Browse the repository at this point in the history
  • Loading branch information
Tzvonimir committed Oct 30, 2024
1 parent d231705 commit f7a1959
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ func install(cmd *cobra.Command, _ []string) error {
AutoCredential: autoCredentials,
IsWorkspace: isWorkspace,
ShellTypeToLocation: user.Conf.ShellTypeToLocation,
BaseCommandPath: cmd.CommandPath(),
}
dmn := daemon.NewDaemon(daemonConf, logging.Log)

Expand Down
24 changes: 23 additions & 1 deletion daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os/exec"
"os/user"
"path/filepath"
"strings"

"github.com/devzero-inc/local-developer-analytics/config"
"github.com/devzero-inc/local-developer-analytics/util"
Expand Down Expand Up @@ -46,6 +47,7 @@ type Config struct {
AutoCredential bool
IsWorkspace bool
ShellTypeToLocation map[config.ShellType]string
BaseCommandPath string
}

// Daemon is the service that configures background service
Expand Down Expand Up @@ -93,8 +95,28 @@ func (d *Daemon) InstallDaemonConfiguration() error {
tmpConf["Group"] = group.Name
}

commands := strings.Split(d.config.BaseCommandPath, " ")

basePath := BaseCollectCommand

if len(commands) > 0 && commands[0] != "lda" {

var path string
for _, command := range commands {
d.logger.Debug().Msgf("Checking command path: %s", command)
if command == "lda" {
break
}
path = path + command + " "
}

basePath = path + basePath
}

d.logger.Info().Msgf("Base path: %s", basePath)

collectCmd := []string{
BaseCollectCommand,
basePath,
}
if d.config.AutoCredential {
collectCmd = append(collectCmd, "-a")
Expand Down

0 comments on commit f7a1959

Please sign in to comment.