Skip to content
Browse files

Adding original chewie until 2.0 is released

  • Loading branch information...
1 parent 5b009bd commit 48f2a84f45ca80a4cda87086b5269cc64c408388 @idavis committed
Showing with 125 additions and 4 deletions.
  1. +2 −0 .NugetFile
  2. +123 −0 chewie.ps1
  3. +0 −4 src/Archetype.Tests/packages.config
View
2 .NugetFile
@@ -0,0 +1,2 @@
+install_to 'lib'
+chew nunit 2.6.1
View
123 chewie.ps1
@@ -0,0 +1,123 @@
+$default_source = ""
+$version_packages = $false
+
+function version_packages
+{
+ $script:version_packages = $true
+}
+
+function source
+{
+ param(
+ [Parameter(Position=0,Mandatory=$true)]
+ [string] $source = $null
+ )
+
+ $script:default_source = $source
+}
+
+function FileExistsInPath
+{
+ param (
+ [Parameter(Position=0,Mandatory=$true)]
+ [string] $fileName = $null
+ )
+
+ $path = Get-Childitem Env:Path
+ $found = $false
+ foreach ($folder in $path.Value.Split(";")) { if (Test-Path "$folder\$fileName") { $found = $true; break } }
+ Write-Output $found
+}
+
+function install_to
+{
+ param(
+ [Parameter(Position=0,Mandatory=$true)]
+ [string] $path = $null
+ )
+
+ if(!(test-path $path))
+ {
+ if([System.IO.Path]::IsPathRooted($path))
+ {
+ $drive_letter = [System.IO.Path]::GetPathRoot($path)
+ $directory_name = $path.Replace($drive_letter, "")
+ new-item -path $drive_letter -name $directory_name -itemtype directory
+ }
+ else
+ {
+ new-item -path . -name $path -itemtype directory
+ }
+ }
+
+ push-location $path -stackname 'chewie_nuget'
+}
+
+function chocolate
+{
+ [CmdletBinding()]
+ param (
+ [Parameter(Position=0,Mandatory=$true)]
+ [string] $name = $null,
+
+ [Parameter(Position=1,Mandatory=$false)]
+ [alias("v")]
+ [string] $version = "",
+
+ [Parameter(Position=2,Mandatory=$false)]
+ [alias("s")]
+ [string] $source = ""
+ )
+
+ $choco_install = $env:ChocolateyInstall
+
+ if($choco_install -eq $null -or (test-path $choco_install -ErrorAction SilentlyContinue) -eq $false){
+ Write-Host "you need to have chocolatey installed before you can use the chocolate commands"
+ return
+ }
+
+ $command = "chocolatey install $name"
+
+ if($version -ne "") { $command += " -v $version" }
+ if($source -eq "" -and $script:default_source -ne "") { $source = $script:default_source }
+ if($source -ne "") { $command += " -s $source" }
+
+ invoke-expression $command
+
+}
+
+function chew
+{
+ [CmdletBinding()]
+ param (
+ [Parameter(Position=0,Mandatory=$true)]
+ [string] $name = $null,
+
+ [Parameter(Position=1,Mandatory=$false)]
+ [alias("v")]
+ [string] $version = "",
+
+ [Parameter(Position=2,Mandatory=$false)]
+ [alias("s")]
+ [string] $source = ""
+ )
+
+ $nuGetIsInPath = (FileExistsInPath "NuGet.exe") -or (FileExistsInPath "NuGet.bat")
+ $command = ""
+ if($nuGetIsInPath)
+ {
+ $command += "NuGet install"
+ if($script:version_packages -ne $true){$command += " -x"}
+
+ } else { $command += "install-package" }
+ $command += " $name"
+
+ if($version -ne "") { $command += " -version $version" }
+ if($source -eq "" -and $script:default_source -ne "") { $source = $script:default_source }
+ if($source -ne "") { $command += " -source $source" }
+
+ invoke-expression $command
+}
+
+gc $pwd\.NugetFile | Foreach-Object { $block = [scriptblock]::Create($_.ToString()); % $block; }
+if((get-location -stackname 'chewie_nuget').count -gt 0) { pop-location -stackname 'chewie_nuget' }
View
4 src/Archetype.Tests/packages.config
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="NUnit" version="2.6.1" targetFramework="net40" />
-</packages>

0 comments on commit 48f2a84

Please sign in to comment.
Something went wrong with that request. Please try again.