Skip to content

Commit 4f27836

Browse files
committed
rename and add comments for clarity
1 parent c312540 commit 4f27836

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

devbox.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ func PrintEnvrcContent(w io.Writer) error {
7474
return impl.PrintEnvrcContent(w)
7575
}
7676

77-
func OnlyPathWithoutWrappers() string {
78-
return impl.OnlyPathWithoutWrappers()
77+
// ExportedSystemPathWithoutWrappers reads $PATH, removes `virtenv/.wrappers/bin` paths,
78+
// and returns a string of the form `export PATH=....`
79+
//
80+
// This small utility function could have been inlined in the boxcli caller, but
81+
// needed the impl.exportify functionality. It does not depend on core-devbox.
82+
func ExportedSystemPathWithoutWrappers() string {
83+
return impl.ExportedSystemPathWithoutWrappers()
7984
}

internal/boxcli/shellenv.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func shellEnvOnlyPathWithoutWrappersCmd() *cobra.Command {
8989
command := &cobra.Command{
9090
Use: "only-path-without-wrappers",
9191
Hidden: true,
92-
Short: "Print shell commands that export PATH without the bin-wrappers",
92+
Short: "[internal] Print shell command that exports the system $PATH without the bin-wrappers paths.",
9393
Args: cobra.ExactArgs(0),
9494
PreRunE: ensureNixInstalled,
9595
RunE: func(cmd *cobra.Command, args []string) error {
@@ -102,5 +102,5 @@ func shellEnvOnlyPathWithoutWrappersCmd() *cobra.Command {
102102
}
103103

104104
func shellEnvOnlyPathWithoutWrappersFunc() string {
105-
return devbox.OnlyPathWithoutWrappers()
105+
return devbox.ExportedSystemPathWithoutWrappers()
106106
}

internal/impl/devbox.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -332,25 +332,6 @@ func (d *Devbox) PrintEnv(ctx context.Context, includeHooks bool) (string, error
332332
return envStr, nil
333333
}
334334

335-
// OnlyPathWithoutWrappers is a small utility to filter WrapperBin paths from PATH
336-
func OnlyPathWithoutWrappers() string {
337-
338-
path := []string{}
339-
for _, p := range strings.Split(os.Getenv("PATH"), string(filepath.ListSeparator)) {
340-
// Intentionally do not include projectDir with plugin.WrapperBinPath so that
341-
// we filter out bin-wrappers for devbox-global and devbox-project.
342-
if !strings.Contains(p, plugin.WrapperBinPath) {
343-
path = append(path, p)
344-
}
345-
}
346-
347-
envs := map[string]string{
348-
"PATH": strings.Join(path, string(filepath.ListSeparator)),
349-
}
350-
351-
return exportify(envs)
352-
}
353-
354335
func (d *Devbox) ShellEnvHash(ctx context.Context) (string, error) {
355336
envs, err := d.nixEnv(ctx)
356337
if err != nil {
@@ -1231,3 +1212,22 @@ func (d *Devbox) convertEnvToMap(currentEnv []string) (map[string]string, error)
12311212
}
12321213
return env, nil
12331214
}
1215+
1216+
// ExportedSystemPathWithoutWrappers is a small utility to filter WrapperBin paths from PATH
1217+
func ExportedSystemPathWithoutWrappers() string {
1218+
1219+
path := []string{}
1220+
for _, p := range strings.Split(os.Getenv("PATH"), string(filepath.ListSeparator)) {
1221+
// Intentionally do not include projectDir with plugin.WrapperBinPath so that
1222+
// we filter out bin-wrappers for devbox-global and devbox-project.
1223+
if !strings.Contains(p, plugin.WrapperBinPath) {
1224+
path = append(path, p)
1225+
}
1226+
}
1227+
1228+
envs := map[string]string{
1229+
"PATH": strings.Join(path, string(filepath.ListSeparator)),
1230+
}
1231+
1232+
return exportify(envs)
1233+
}

0 commit comments

Comments
 (0)