File: install.ps1

package info (click to toggle)
git-secrets 1.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 256 kB
  • sloc: sh: 996; makefile: 27
file content (48 lines) | stat: -rw-r--r-- 1,400 bytes parent folder | download
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
Param([string]$InstallationDirectory = $($Env:USERPROFILE + "\.git-secrets"))

Write-Host "Checking to see if installation directory already exists..."
if (-not (Test-Path $InstallationDirectory))
{
    Write-Host "Creating installation directory."
    New-Item -ItemType Directory -Path $InstallationDirectory | Out-Null
}
else
{
    Write-Host "Installation directory already exists."
}

Write-Host "Copying files."
Copy-Item ./git-secrets -Destination $InstallationDirectory -Force
Copy-Item ./git-secrets.1 -Destination $InstallationDirectory -Force

Write-Host "Checking if directory already exists in Path..."
$currentPath = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($currentPath -notlike "*$InstallationDirectory*")
{
    Write-Host "Adding to path."
    $newPath = $currentPath
    if(-not ($newPath.EndsWith(";")))
    {
        $newPath = $newPath + ";"
    }
    $newPath = $newPath + $InstallationDirectory
    [Environment]::SetEnvironmentVariable("PATH", $newPath, "User")
}
else
{
    Write-Host "Already in Path."
}

# Adding to Session
Write-Host "Adding to user session."
$currentSessionPath = $Env:Path
if ($currentSessionPath -notlike "*$InstallationDirectory*")
{
    if(-not ($currentSessionPath.EndsWith(";")))
    {
        $currentSessionPath = $currentSessionPath + ";"
    }
    $Env:Path = $currentSessionPath + $InstallationDirectory
}

Write-Host "Done."