Skip to content

Commit 0911fba

Browse files
committed
rename and add comments for clarity
1 parent 418fb88 commit 0911fba

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
@@ -75,6 +75,11 @@ func PrintEnvrcContent(w io.Writer) error {
7575
return impl.PrintEnvrcContent(w)
7676
}
7777

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

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
@@ -348,25 +348,6 @@ func (d *Devbox) PrintEnvVars(ctx context.Context) ([]string, error) {
348348
return keyEqualsValue(envs), nil
349349
}
350350

351-
// OnlyPathWithoutWrappers is a small utility to filter WrapperBin paths from PATH
352-
func OnlyPathWithoutWrappers() string {
353-
354-
path := []string{}
355-
for _, p := range strings.Split(os.Getenv("PATH"), string(filepath.ListSeparator)) {
356-
// Intentionally do not include projectDir with plugin.WrapperBinPath so that
357-
// we filter out bin-wrappers for devbox-global and devbox-project.
358-
if !strings.Contains(p, plugin.WrapperBinPath) {
359-
path = append(path, p)
360-
}
361-
}
362-
363-
envs := map[string]string{
364-
"PATH": strings.Join(path, string(filepath.ListSeparator)),
365-
}
366-
367-
return exportify(envs)
368-
}
369-
370351
func (d *Devbox) ShellEnvHash(ctx context.Context) (string, error) {
371352
envs, err := d.nixEnv(ctx)
372353
if err != nil {
@@ -1247,3 +1228,22 @@ func (d *Devbox) convertEnvToMap(currentEnv []string) (map[string]string, error)
12471228
}
12481229
return env, nil
12491230
}
1231+
1232+
// ExportedSystemPathWithoutWrappers is a small utility to filter WrapperBin paths from PATH
1233+
func ExportedSystemPathWithoutWrappers() string {
1234+
1235+
path := []string{}
1236+
for _, p := range strings.Split(os.Getenv("PATH"), string(filepath.ListSeparator)) {
1237+
// Intentionally do not include projectDir with plugin.WrapperBinPath so that
1238+
// we filter out bin-wrappers for devbox-global and devbox-project.
1239+
if !strings.Contains(p, plugin.WrapperBinPath) {
1240+
path = append(path, p)
1241+
}
1242+
}
1243+
1244+
envs := map[string]string{
1245+
"PATH": strings.Join(path, string(filepath.ListSeparator)),
1246+
}
1247+
1248+
return exportify(envs)
1249+
}

0 commit comments

Comments
 (0)