Skip to content
Browse files

reducing the verbosity. Adding a debug command

  • Loading branch information...
1 parent f11d961 commit 2eec8417032c706075c7b872f926411129ac8530 @ferventcoder ferventcoder committed Apr 24, 2012
View
6 src/chocolatey.ps1
@@ -8,7 +8,8 @@
[alias("o","override","overrideArguments","notSilent")]
[switch] $overrideArgs = $false,
[switch] $force = $false,
- [alias("pre")][switch] $prerelease = $false
+ [alias("pre")][switch] $prerelease = $false,
+ [switch] $debug
)
# chocolatey
@@ -34,6 +35,9 @@ $nugetExe = Join-Path $nugetChocolateyPath 'nuget.exe'
$h1 = '====================================================='
$h2 = '-------------------------'
+$DebugPreference = "SilentlyContinue"
+if ($debug) {$DebugPreference = "Continue";}
+
# grab functions from files
Resolve-Path $nugetChocolateyPath\functions\*.ps1 |
? { -not ($_.ProviderPath.Contains(".Tests.")) } |
View
11 src/functions/Chocolatey-NuGet.ps1
@@ -16,17 +16,17 @@ param(
@"
$h1
-Chocolatey ($chocVer) is installing $packageName (from $srcArgs) to "$nugetLibPath"
+Chocolatey ($chocVer) is installing $packageName (from $srcArgs) to "$nugetLibPath". By installing you accept the license for the package you are installing (please run chocolatey /? for full license acceptance terms).
$h1
-Package License Acceptance Terms
-$h2
-Please run chocolatey /? for full license acceptance verbage. By installing you accept the license for the package you are installing...
-$h2
"@ | Write-Host
$nugetOutput = Run-NuGet $packageName $source $version
foreach ($line in $nugetOutput) {
+ if ($line -like "*already installed." -and $force -eq $false) {
+ Write-Host "$line - If you want to reinstall an existing package, please use the -force command."
+ Write-Host ""
+ }
if ($line -notlike "*not installed*" -and ($line -notlike "*already installed." -or $force -eq $true) -and $line -notlike "Attempting to resolve dependency*") {
$installedPackageName = ''
$installedPackageVersion = ''
@@ -63,7 +63,6 @@ $h2
if ($packageFolder -ne '') {
@"
$h2
-$h2
Chocolatey Runner ($($installedPackageName.ToUpper()))
$h2
"@ | Write-Host
View
6 src/functions/Chocolatey-RubyGem.ps1
@@ -9,12 +9,8 @@ param(
@"
$h1
-Chocolatey ($chocVer) is installing Ruby Gem `'$packageName`' (using RubyGems.org)
+Chocolatey ($chocVer) is installing Ruby Gem `'$packageName`' (using RubyGems.org). By installing you accept the license for the package you are installing (please run chocolatey /? for full license acceptance terms).
$h1
-Package License Acceptance Terms
-$h2
-Please run chocolatey /? for full license acceptance verbage. By installing you accept the license for the package you are installing...
-$h2
"@ | Write-Host
if ($($env:Path).ToLower().Contains("ruby") -eq $false) {
View
6 src/functions/Chocolatey-WebPI.ps1
@@ -8,12 +8,8 @@ param(
@"
$h1
-Chocolatey ($chocVer) is installing `'$packageName`' (using WebPI)
+Chocolatey ($chocVer) is installing `'$packageName`' (using WebPI). By installing you accept the license for the package you are installing (please run chocolatey /? for full license acceptance terms).
$h1
-Package License Acceptance Terms
-$h2
-Please run chocolatey /? for full license acceptance verbage. By installing you accept the license for the package you are installing...
-$h2
"@ | Write-Host
$chocoInstallLog = Join-Path $nugetChocolateyPath 'chocolateyWebPiInstall.log';
View
6 src/functions/Get-ChocolateyBins.ps1
@@ -5,12 +5,14 @@ param(
if ($packageFolder -notlike '') {
@"
$h2
-Executable Batch Links
+ Executable Links (*.exe)
$h2
+"@ | Write-Host
+@"
Looking for executables in folder: $packageFolder
Adding batch files for any executables found to a location on PATH. In other words the executable will be available from ANY command line/powershell prompt.
$h2
-"@ | Write-Host
+"@ | Write-Debug
$batchCreated = $false
try {
$files = get-childitem $packageFolder -include *.exe -recurse
View
8 src/functions/Run-ChocolateyPS1.ps1
@@ -7,12 +7,14 @@ param(
if ($packageFolder -notlike '') {
@"
$h2
-Chocolatey Installation (chocolateyinstall.ps1)
+ Chocolatey Installation (chocolateyinstall.ps1)
$h2
+"@ | Write-Host
+@"
Looking for chocolateyinstall.ps1 in folder $packageFolder
If chocolateyInstall.ps1 is found, it will be run.
$h2
-"@ | Write-Host
+"@ | Write-Debug
$ps1 = Get-ChildItem $packageFolder -recurse | ?{$_.name -match "chocolateyinstall.ps1"} | sort name -Descending | select -First 1
@@ -47,6 +49,8 @@ $h2
throw $errorContents
}
}
+ } else {
+ Write-Host "No chocolateyInstall.ps1 file found in `'$packageFolder`' or subfolders."
}
}
}
View
4 src/functions/Run-NuGet.ps1
@@ -8,7 +8,7 @@ param(
$h2
NuGet
$h2
-"@ | Write-Host
+"@ | Write-Debug
$srcArgs = "-Source `"$source`""
if ($source -like 'https://go.microsoft.com/fwlink/?LinkID=230477') {
@@ -30,7 +30,7 @@ $h2
$nugetOutput = Get-Content $logFile -Encoding Ascii
foreach ($line in $nugetOutput) {
- Write-Host $line
+ if ($line -ne $null) {Write-Debug $line;}
}
$errors = Get-Content $errorLogFile
if ($errors -ne '') {
View
8 tests/Chocolatey-NuGet.tests.ps1
@@ -10,19 +10,17 @@ Describe "When calling Chocolatey-NuGet normally" {
It "should call Chocolatey-NuGet" {
$script:chocolatey_nuget_was_called.should.be($true)
}
-
- It "should not call the Chocolatey-PackagesConfig function" {
- $script:chocolatey_packagesconfig_was_called.should.be($false)
+
+ It "should call Run-NuGet" {
+ $script:run_nuget_was_called.should.be($true)
}
-
It "should call Start-Process function to run NuGet.exe" {
#$script:start_process_was_called.should.be($true)
}
}
Describe "when calling Chocolatey-NuGet with packageName 'all'" {
-
Initialize-Variables
$script:exec_chocolatey_nuget_actual = $true
Chocolatey-NuGet 'all'
View
1 tests/_Common.ps1
@@ -16,5 +16,4 @@ Resolve-Path $here\functions\*.ps1 | % { . $_.ProviderPath }
Resolve-Path $here\helpers\*.ps1 | % { . $_.ProviderPath }
Import-Module $setup
-
Import-Module $initializeVariables
View
4 tests/_FunctionRenameActuals.ps1
@@ -1,4 +1,6 @@
-rename-item function:Chocolatey-Help Chocolatey-Help-Actual
+#credit to Aaron Lerch on helping me figure out how you can keep the real functions around
+
+rename-item function:Chocolatey-Help Chocolatey-Help-Actual
rename-item function:Chocolatey-Install Chocolatey-Install-Actual
rename-item function:Chocolatey-InstallAll Chocolatey-InstallAll-Actual
rename-item function:Chocolatey-InstallIfMissing Chocolatey-InstallIfMissing-Actual
View
18 tests/functions/Run-NuGet.ps1
@@ -4,14 +4,26 @@ param(
[string] $source,
[string] $version
)
- Setup -File 'chocolatey\chocolateyInstall\install.log' @"
- Successfully installed '$packageName 1.0'.
+
+$fileText = @"
+Successfully installed '$packageName 1.0'.
+"@
+if ($version -ne '') {
+ $fileText = @"
+Successfully installed '$packageName $version'.
"@
+ }
+
+ Setup -File 'chocolatey\chocolateyInstall\install.log' $fileText
+
$script:run_nuget_was_called = $true
$script:packageName = $packageName
$script:source = $source
$script:version = $version
- if ($script:exec_run_nuget_actual) { Run-NuGet-Actual @PSBoundParameters}
+ if ($script:exec_run_nuget_actual) { Run-NuGet-Actual @PSBoundParameters
+ } else {
+ return $fileText
+ }
}

0 comments on commit 2eec841

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