Last active
December 15, 2015 11:49
-
-
Save abombss/5255607 to your computer and use it in GitHub Desktop.
Add-GitIgnore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Add-GitIgnoreForVS ([switch]$DisableNugetRestore,[switch]$PassThru) { | |
$cmdArgs = @{ | |
Name="VisualStudio" | |
PassThru=$PassThru | |
Uncomment=( & {if($DisableNugetRestore) { @() } else { @("packages/") } }) | |
} | |
Add-GitIgnore @cmdArgs | |
} | |
function Add-GitIgnore ([string]$Name, [switch]$PassThru, [string]$UserRepo="github/gitignore", [string]$Branch="master", [string[]]$Uncomment) { | |
$content = Invoke-WebRequest -uri "https://raw.github.com/$UserRepo/$Branch/$Name.gitignore" | | |
Select-Object -Exp Content | | |
%{ $origContent = $_; $UnComment |% { $origContent -replace "(?m)^#$_", "$_" } } | |
if ($PassThru) { | |
$content | |
} else { | |
$content | Out-File .gitignore | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment