File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 7
7
"log"
8
8
"os"
9
9
"os/exec"
10
+ "os/user"
10
11
"path/filepath"
11
12
"runtime"
12
13
"sort"
@@ -83,9 +84,7 @@ func (f *fetcher) Fetch(cfgFile string, selectedTools ...string) error {
83
84
if err != nil {
84
85
return err
85
86
}
86
- if tb .Target == "" {
87
- tb .Target = "./tools"
88
- }
87
+ sanitizeTargetDir (tb )
89
88
90
89
if tb .Upx {
91
90
f .checkUpxAvailable ()
@@ -134,6 +133,16 @@ func (f *fetcher) Fetch(cfgFile string, selectedTools ...string) error {
134
133
return SaveYamlFile (filepath .Join (tb .Target , toolboxVersionsFile ), tb .Versions ())
135
134
}
136
135
136
+ func sanitizeTargetDir (tb * types.Toolbox ) {
137
+ if tb .Target == "" {
138
+ tb .Target = "./tools"
139
+ } else if strings .HasPrefix (tb .Target , "~/" ) {
140
+ usr , _ := user .Current ()
141
+ dir := usr .HomeDir
142
+ tb .Target = filepath .Join (dir , tb .Target [2 :])
143
+ }
144
+ }
145
+
137
146
func (f * fetcher ) assureTargetDirAvailable (tb * types.Toolbox ) error {
138
147
if _ , err := os .Stat (tb .Target ); err != nil {
139
148
if os .IsNotExist (err ) {
You can’t perform that action at this time.
0 commit comments