Skip to content

Commit 97813a8

Browse files
committed
Move logic
1 parent 7029a4c commit 97813a8

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

pkg/runtime/internal/envdef/collection.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package envdef
22

33
import (
4+
"os"
45
"path/filepath"
6+
"runtime"
57
"sync"
68

79
"github.com/ActiveState/cli/internal/errs"
@@ -63,5 +65,29 @@ func (c *Collection) Environment(installPath string, inherit bool) (map[string]s
6365
}
6466
}
6567
constants := NewConstants(installPath)
66-
return result.ExpandVariables(constants).GetEnv(inherit), nil
68+
env := result.ExpandVariables(constants).GetEnv(inherit)
69+
promotePath(env)
70+
return env, nil
71+
}
72+
73+
// promotPath is a temporary fix to ensure that the PATH is interpreted correctly on Windows
74+
// Should be properly addressed by https://activestatef.atlassian.net/browse/DX-3030
75+
func promotePath(env map[string]string) {
76+
if runtime.GOOS != "windows" {
77+
return
78+
}
79+
80+
PATH, exists := env["PATH"]
81+
if !exists {
82+
return
83+
}
84+
85+
// If Path exists, prepend PATH values to it
86+
Path, pathExists := env["Path"]
87+
if !pathExists {
88+
return
89+
}
90+
91+
env["Path"] = PATH + string(os.PathListSeparator) + Path
92+
delete(env, "PATH")
6793
}

pkg/runtime/runtime.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"maps"
55
"os"
66
"path/filepath"
7-
"runtime"
87

98
"github.com/ActiveState/cli/internal/errs"
109
"github.com/ActiveState/cli/internal/fileutils"
@@ -166,34 +165,9 @@ func (r *Runtime) getEnv(inherit bool) (map[string]string, map[string]string, er
166165
execVars["PATH"] += string(os.PathListSeparator) + vars["PATH"]
167166
}
168167

169-
promotePath(vars)
170-
promotePath(execVars)
171-
172168
return vars, execVars, nil
173169
}
174170

175-
// promotPath is a temporary fix to ensure that the PATH is interpreted correctly on Windows
176-
// Should be properly addressed by https://activestatef.atlassian.net/browse/DX-3030
177-
func promotePath(env map[string]string) {
178-
if runtime.GOOS != "windows" {
179-
return
180-
}
181-
182-
PATH, exists := env["PATH"]
183-
if !exists {
184-
return
185-
}
186-
187-
// If Path exists, prepend PATH values to it
188-
Path, pathExists := env["Path"]
189-
if !pathExists {
190-
return
191-
}
192-
193-
env["Path"] = PATH + string(os.PathListSeparator) + Path
194-
delete(env, "PATH")
195-
}
196-
197171
func (r *Runtime) Env(inherit bool) Environment {
198172
if inherit {
199173
return r.envInherit

0 commit comments

Comments
 (0)