@@ -13,7 +13,6 @@ import (
13
13
"text/template"
14
14
15
15
"github.com/pkg/errors"
16
-
17
16
"go.jetpack.io/devbox/internal/cmdutil"
18
17
"go.jetpack.io/devbox/internal/nix"
19
18
"go.jetpack.io/devbox/internal/plugin"
@@ -48,7 +47,7 @@ func CreateWrappers(ctx context.Context, devbox devboxer) error {
48
47
_ = os .RemoveAll (filepath .Join (devbox .ProjectDir (), plugin .WrapperPath ))
49
48
50
49
// Recreate the bin wrapper directory
51
- destPath := filepath .Join (devbox . ProjectDir (), plugin . WrapperBinPath )
50
+ destPath := filepath .Join (GetWrapperBinPath ( devbox ) )
52
51
_ = os .MkdirAll (destPath , 0755 )
53
52
54
53
bashPath := cmdutil .GetPathOrDefault ("bash" , "/bin/bash" )
@@ -91,13 +90,17 @@ func CreateWrappers(ctx context.Context, devbox devboxer) error {
91
90
return errors .WithStack (err )
92
91
}
93
92
}
94
- if err = createDevboxSymlink (devbox . ProjectDir () ); err != nil {
93
+ if err = createDevboxSymlink (devbox ); err != nil {
95
94
return err
96
95
}
97
96
98
97
return createSymlinksForSupportDirs (devbox .ProjectDir ())
99
98
}
100
99
100
+ func GetWrapperBinPath (devbox devboxer ) string {
101
+ return filepath .Join (devbox .ProjectDir (), plugin .WrapperBinPath )
102
+ }
103
+
101
104
type createWrapperArgs struct {
102
105
devboxer
103
106
BashPath string
@@ -168,15 +171,15 @@ func createSymlinksForSupportDirs(projectDir string) error {
168
171
169
172
// Creates a symlink for devbox in .devbox/virtenv/.wrappers/bin
170
173
// so that devbox can be available inside a pure shell
171
- func createDevboxSymlink (projectDir string ) error {
174
+ func createDevboxSymlink (devbox devboxer ) error {
172
175
173
176
// Get absolute path for where devbox is called
174
177
devboxPath , err := filepath .Abs (os .Args [0 ])
175
178
if err != nil {
176
179
return errors .Wrap (err , "failed to create devbox symlink. Devbox command won't be available inside the shell" )
177
180
}
178
181
// Create a symlink between devbox in .wrappers/bin
179
- err = os .Symlink (devboxPath , filepath .Join (projectDir , plugin . WrapperBinPath , "devbox" ))
182
+ err = os .Symlink (devboxPath , filepath .Join (GetWrapperBinPath ( devbox ) , "devbox" ))
180
183
if err != nil && ! errors .Is (err , fs .ErrExist ) {
181
184
return errors .Wrap (err , "failed to create devbox symlink. Devbox command won't be available inside the shell" )
182
185
}
0 commit comments