Skip to content

Commit f7a1959

Browse files
committed
Fix base path detection when importing lda command
1 parent d231705 commit f7a1959

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

cmd/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ func install(cmd *cobra.Command, _ []string) error {
348348
AutoCredential: autoCredentials,
349349
IsWorkspace: isWorkspace,
350350
ShellTypeToLocation: user.Conf.ShellTypeToLocation,
351+
BaseCommandPath: cmd.CommandPath(),
351352
}
352353
dmn := daemon.NewDaemon(daemonConf, logging.Log)
353354

daemon/daemon.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os/exec"
99
"os/user"
1010
"path/filepath"
11+
"strings"
1112

1213
"github.com/devzero-inc/local-developer-analytics/config"
1314
"github.com/devzero-inc/local-developer-analytics/util"
@@ -46,6 +47,7 @@ type Config struct {
4647
AutoCredential bool
4748
IsWorkspace bool
4849
ShellTypeToLocation map[config.ShellType]string
50+
BaseCommandPath string
4951
}
5052

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

98+
commands := strings.Split(d.config.BaseCommandPath, " ")
99+
100+
basePath := BaseCollectCommand
101+
102+
if len(commands) > 0 && commands[0] != "lda" {
103+
104+
var path string
105+
for _, command := range commands {
106+
d.logger.Debug().Msgf("Checking command path: %s", command)
107+
if command == "lda" {
108+
break
109+
}
110+
path = path + command + " "
111+
}
112+
113+
basePath = path + basePath
114+
}
115+
116+
d.logger.Info().Msgf("Base path: %s", basePath)
117+
96118
collectCmd := []string{
97-
BaseCollectCommand,
119+
basePath,
98120
}
99121
if d.config.AutoCredential {
100122
collectCmd = append(collectCmd, "-a")

0 commit comments

Comments
 (0)