-
Notifications
You must be signed in to change notification settings - Fork 28
/
Install.ps1
59 lines (50 loc) · 1.48 KB
/
Install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#
# VirtualEnvWrapper for Power shell
#
# Installation script
#
$PowerShellProfile = $PROFILE.CurrentUserAllHosts
$PowerShellPath = Split-Path $PowerShellProfile
$InstallationPath = Join-Path $PowerShellPath Modules
function Ask-User($Message)
{
Do
{
$Key = (Read-Host "$Message [Y/n]").ToLower()
} While ($Key -ne "y" -And $Key -ne "n")
return $Key
}
Write-Host
$key = Ask-User "Do you want to install VirtualEnvWrapper for PowerShell"
if ($key -eq "n")
{
Exit
}
# Test powershell directories in ~\Documents. If don't exists create it
if (!(Test-Path $InstallationPath))
{
Write-Host "Create directory : $InstallationPath"
New-Item -ItemType Directory -Force -Path $InstallationPath
}
Copy-Item VirtualEnvWrapper.psm1 $InstallationPath\VirtualEnvWrapper.psm1
# If Powershell profile doesn't exist, add it with necessary contents
# Otherwise append contents to existing profile
if (!(Test-Path $PowerShellProfile))
{
$key = Ask-User "The powershell profile is missing. Do you want to create it?"
if ($key -eq "y")
{
Copy-Item Profile.ps1 $PowerShellProfile
}
}
else
{
$From = Get-Content -Path Profile.ps1
if(!(Select-String -SimpleMatch "VirtualEnvWrapper.psm1" -Path $PowerShellProfile))
{
Add-Content -Path $PowerShellProfile -Value "`r`n"
Add-Content -Path $PowerShellProfile -Value $From
}
}
Write-Host "Installation done. Close this PowerShell and re-open it to activate VirtualEnvWrapper"
Write-Host