Skip to content

Commit 6ae321d

Browse files
updated to work with powershell instead of cmd.exe
1 parent 1e32aeb commit 6ae321d

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

main.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,9 @@ func createEnv(name string, pythonVersion string) {
8888
// Returns activation script as string, with OS-specific syntax
8989
func generateActivateScript(envPath string) string {
9090
if runtime.GOOS == "windows" {
91-
return fmt.Sprintf(`@echo off
92-
set "UVE_OLD_PATH=%%PATH%%"
93-
set "VIRTUAL_ENV=%s"
94-
set "PATH=%s\Scripts;%%PATH%%"
91+
return fmt.Sprintf(`$env:UVE_OLD_PATH = $env:PATH
92+
$env:VIRTUAL_ENV = "%s"
93+
$env:PATH = "%s\Scripts;" + $env:PATH
9594
`, envPath, envPath)
9695
}
9796
return fmt.Sprintf(`export UVE_OLD_PATH="$PATH"
@@ -105,12 +104,11 @@ export PATH="%s/bin:$PATH"
105104
// Returns deactivation script as string, with OS-specific syntax
106105
func generateDeactivateScript() string {
107106
if runtime.GOOS == "windows" {
108-
return `@echo off
109-
if defined UVE_OLD_PATH (
110-
set "PATH=%UVE_OLD_PATH%"
111-
set "UVE_OLD_PATH="
112-
)
113-
set "VIRTUAL_ENV="
107+
return `if ($env:UVE_OLD_PATH) {
108+
$env:PATH = $env:UVE_OLD_PATH
109+
Remove-Item Env:\UVE_OLD_PATH
110+
}
111+
Remove-Item Env:\VIRTUAL_ENV -ErrorAction SilentlyContinue
114112
`
115113
}
116114
return `if [ -n "$UVE_OLD_PATH" ]; then

0 commit comments

Comments
 (0)