forked from regisf/virtualenvwrapper-powershell
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInstall.ps1
47 lines (37 loc) · 1.32 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
#
# VirtualEnvWrapper for Power shell
#
# Installation script
#
$PowerShellProfile = $PROFILE.CurrentUserAllHosts
$PowerShellPath = Split-Path $PowerShellProfile
Import-LocalizedData -BaseDirectory .\VirtualEnvWrapper -FileName VirtualEnvWrapper.psd1 -BindingVariable Data
$ModuleVersion = $Data.ModuleVersion
$InstallationDirectory = Join-Path $PowerShellPath Modules
$InstallationPath = Join-Path $InstallationDirectory "VirtualEnvWrapper"
$InstallationPath = Join-Path $InstallationPath $ModuleVersion
if (!(Test-Path $InstallationDirectory))
{
Write-Host "Creating directory: $InstallationDirectory"
New-Item -ItemType Directory -Force -Path $InstallationDirectory
}
if (Test-Path $InstallationPath) {
Write-Host "Removing previously installed version $ModuleVersion"
Remove-Item -Recurse -Force $InstallationPath
}
Copy-Item -Recurse .\VirtualEnvWrapper $InstallationPath
if (!(Test-Path $PowerShellProfile))
{
Copy-Item Profile.ps1 $PowerShellProfile
}
else
{
$From = Get-Content -Path Profile.ps1
if(!(Select-String -SimpleMatch "VirtualEnvWrapper" -Path $PowerShellProfile))
{
Add-Content -Path $PowerShellProfile -Value "`r`n"
Add-Content -Path $PowerShellProfile -Value $From
}
}
Write-Host "Installation complete. Please restart PowerShell to use VirtualEnvWrapper"
Write-Host