4
4
"bytes"
5
5
"errors"
6
6
"fmt"
7
- "github.com/mutagen-io/mutagen/pkg/prompting"
8
7
"io"
9
8
"strings"
10
9
"time"
@@ -15,6 +14,7 @@ import (
15
14
"github.com/mutagen-io/mutagen/pkg/logging"
16
15
"github.com/mutagen-io/mutagen/pkg/mutagen"
17
16
"github.com/mutagen-io/mutagen/pkg/platform/terminal"
17
+ "github.com/mutagen-io/mutagen/pkg/prompting"
18
18
streampkg "github.com/mutagen-io/mutagen/pkg/stream"
19
19
)
20
20
@@ -147,6 +147,21 @@ func connect(logger *logging.Logger, transport Transport, mode, prompter string,
147
147
// agentInvocationPath computes the agent invocation path, relative to the user's home
148
148
// directory on the remote.
149
149
func agentInvocationPath (cmdExe bool ) string {
150
+ dataDirectoryName := filesystem .MutagenDataDirectoryName
151
+ if mutagen .DevelopmentModeEnabled {
152
+ dataDirectoryName = filesystem .MutagenDataDirectoryDevelopmentName
153
+ }
154
+ return remotePathFromHome (cmdExe ,
155
+ dataDirectoryName ,
156
+ filesystem .MutagenAgentsDirectoryName ,
157
+ mutagen .Version ,
158
+ BaseName ,
159
+ )
160
+ }
161
+
162
+ // remotePathFromHome constructs a path string from the given components as a list of relative path components from
163
+ // the user's home directory. If cmdExe is true, construct a path cmd.exe will understand.
164
+ func remotePathFromHome (cmdExe bool , components ... string ) string {
150
165
// Unless we have reason to assume that this is a cmd.exe environment, we
151
166
// construct a path using forward slashes. This will work for all POSIX
152
167
// systems and POSIX-like environments on Windows. If we know we're hitting
@@ -174,16 +189,7 @@ func agentInvocationPath(cmdExe bool) string {
174
189
pathSeparator = "\\ "
175
190
pathComponents = nil
176
191
}
177
- dataDirectoryName := filesystem .MutagenDataDirectoryName
178
- if mutagen .DevelopmentModeEnabled {
179
- dataDirectoryName = filesystem .MutagenDataDirectoryDevelopmentName
180
- }
181
- pathComponents = append (pathComponents ,
182
- dataDirectoryName ,
183
- filesystem .MutagenAgentsDirectoryName ,
184
- mutagen .Version ,
185
- BaseName ,
186
- )
192
+ pathComponents = append (pathComponents , components ... )
187
193
return strings .Join (pathComponents , pathSeparator )
188
194
}
189
195
0 commit comments