Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (chocolateyGH-414) Ensure choco pkg is known as installed
  (chocolateyGH-422) export cmdlets
  (doc)(chocolateyGH-424) Update legacy instructions
  • Loading branch information
ferventcoder committed Sep 25, 2015
2 parents 9c430c0 + b759fe7 commit 0350608
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 25 deletions.
45 changes: 29 additions & 16 deletions nuget/chocolatey/tools/chocolateysetup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ function Initialize-Chocolatey {
<#
.DESCRIPTION
This will initialize the Chocolatey tool by
a) setting up the "nugetPath" (the location where all chocolatey nuget packages will be installed)
b) Installs chocolatey into the "nugetPath"
a) setting up the "chocolateyPath" (the location where all chocolatey nuget packages will be installed)
b) Installs chocolatey into the "chocolateyPath"
c) Instals .net 4.0 if needed
d) Adds chocolaty to the PATH environment variable so you have access to the chocolatey|cinst commands.
.PARAMETER NuGetPath
Allows you to override the default path of (C:\Chocolatey\) by specifying a directory chocolaty will install nuget packages.
d) Adds Chocolatey to the PATH environment variable so you have access to the choco commands.
.PARAMETER ChocolateyPath
Allows you to override the default path of (C:\ProgramData\chocolatey\) by specifying a directory chocolatey will install nuget packages.
.EXAMPLE
C:\PS> Initialize-Chocolatey
Installs chocolatey into the default C:\Chocolatey\ directory.
Installs chocolatey into the default C:\ProgramData\Chocolatey\ directory.
.EXAMPLE
C:\PS> Initialize-Chocolatey -nugetPath "D:\ChocolateyInstalledNuGets\"
C:\PS> Initialize-Chocolatey -chocolateyPath "D:\ChocolateyInstalledNuGets\"
Installs chocolatey into the custom directory D:\ChocolateyInstalledNuGets\
Expand Down Expand Up @@ -311,16 +311,29 @@ param(
Write-Debug "Ensure-ChocolateyLibFiles"
$chocoPkgDirectory = Join-Path $chocolateyLibPath 'chocolatey'

if ( -not (Test-Path("$chocoPkgDirectory\chocolatey.nupkg")) ) {
Write-Output "Ensuring '$chocoPkgDirectory' exists."
Create-DirectoryIfNotExists $chocoPkgDirectory
Create-DirectoryIfNotExists $chocoPkgDirectory

$chocoPkg = Get-ChildItem "$thisScriptFolder/../../" | ?{$_.name -match "^chocolatey.*nupkg"} | Sort name -Descending | Select -First 1
if ($chocoPkg -ne '') { $chocoPkg = $chocoPkg.FullName }
"$tempDir\chocolatey.zip", "$chocoPkg" | % {
if ($_ -ne $null -and $_ -ne '') {
if (Test-Path $_) {
Copy-Item $_ "$chocoPkgDirectory\chocolatey.nupkg" -force -ErrorAction SilentlyContinue
if (!(Test-Path("$chocoPkgDirectory\chocolatey.nupkg"))) {
Write-Output "chocolatey.nupkg file not installed in lib.`n Attempting to locate it from bootstrapper."
$chocoZipFile = Join-Path $tempDir "chocolatey\chocInstall\chocolatey.zip"

Write-Debug "First the zip file at '$chocoZipFile'."
Write-Debug "Then from a neighboring chocolatey.*nupkg file '$thisScriptFolder/../../'."

if (Test-Path("$chocoZipFile")) {
Write-Debug "Copying '$chocoZipFile' to '$chocoPkgDirectory\chocolatey.nupkg'."
Copy-Item "$chocoZipFile" "$chocoPkgDirectory\chocolatey.nupkg" -Force -ErrorAction SilentlyContinue
}

if (!(Test-Path("$chocoPkgDirectory\chocolatey.nupkg"))) {
$chocoPkg = Get-ChildItem "$thisScriptFolder/../../" | ?{$_.name -match "^chocolatey.*nupkg" } | Sort name -Descending | Select -First 1
if ($chocoPkg -ne '') { $chocoPkg = $chocoPkg.FullName }
"$chocoZipFile", "$chocoPkg" | % {
if ($_ -ne $null -and $_ -ne '') {
if (Test-Path $_) {
Write-Debug "Copying '$_' to '$chocoPkgDirectory\chocolatey.nupkg'."
Copy-Item $_ "$chocoPkgDirectory\chocolatey.nupkg" -Force -ErrorAction SilentlyContinue
}
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/chocolatey.resources/helpers/chocolateyInstaller.psm1
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# limitations under the License.

$helpersPath = (Split-Path -parent $MyInvocation.MyCommand.Definition);

$DebugPreference = "SilentlyContinue"
Expand All @@ -35,10 +35,10 @@ $PSModuleAutoLoadingPreference = "All";
Write-Debug "Posh version is $($psversiontable.PsVersion.ToString())"

# grab functions from files
Get-Item $helpersPath\functions\*.ps1 |
Get-Item $helpersPath\functions\*.ps1 |
? { -not ($_.Name.Contains(".Tests.")) } |
% {
. $_.FullName;
% {
. $_.FullName;
#Export-ModuleMember -Function $_.BaseName
}

Expand All @@ -51,4 +51,4 @@ if(Test-Path($extensionsPath)) {
Get-ChildItem $extensionsPath -recurse -filter "*.dll" | Select -ExpandProperty FullName | % { Write-Debug "Importing `'$_`'"; Import-Module $_; }
}

Export-ModuleMember -Function * -Alias *
Export-ModuleMember -Function * -Alias * -Cmdlet *

0 comments on commit 0350608

Please sign in to comment.