From f7a1959aa6f30f9ee000f076a7c2fb3530199c2a Mon Sep 17 00:00:00 2001 From: tzvonimir Date: Wed, 30 Oct 2024 13:05:12 +0100 Subject: [PATCH] Fix base path detection when importing lda command --- cmd/cmd.go | 1 + daemon/daemon.go | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index e2ffc62..a618453 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -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) diff --git a/daemon/daemon.go b/daemon/daemon.go index 0c326e9..2d83389 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -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" @@ -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 @@ -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")