Skip to content

Commit

Permalink
Add installation script to simplify setup on windows. Modified README.
Browse files Browse the repository at this point in the history
  • Loading branch information
costleya committed Jul 26, 2018
1 parent ab7ff3f commit 635895a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 4 deletions.
22 changes: 18 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,29 @@ Installing git-secrets
~~~~~~~~~~~~~~~~~~~~~~

``git-secrets`` must be placed somewhere in your PATH so that it is picked up
by ``git`` when running ``git secrets``. You can use ``install`` target of the
provided Makefile to install ``git secrets`` and the man page. You can
customize the install path using the PREFIX and MANPREFIX variables.
by ``git`` when running ``git secrets``.

**\*nix (Linux/OSX)**

You can use ``install`` target of the provided Makefile to install
``git secrets`` and the man page. You can customize the install path
using the PREFIX and MANPREFIX variables.

::

make install

Or, installing with Homebrew (for OS X users).
**Windows**

Run the provided install.ps1 powershell script. This will copy the needed files
to an installation directory ("%USERPROFILE%/.git-secrets" by default) and add
the directory to the current user PATH.

::

PS > ./install.ps1

**Homebrew (for OS X users).**

::

Expand Down
48 changes: 48 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,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."

0 comments on commit 635895a

Please sign in to comment.