Skip to content
Browse files

Fix for issue #12, only root module should be loaded after installation

  • Loading branch information...
1 parent 8483fcd commit 9ffcbdf74f46bf71290fc19580a9ad09599cac60 @chaliy committed
Showing with 18 additions and 9 deletions.
  1. +0 −1 DirectoryCandidates.txt
  2. +10 −8 PsGet/PsGet.psm1
  3. BIN TestModules/HelloWorldFolderWithChildModules.zip
  4. +8 −0 Tests.ps1
View
1 DirectoryCandidates.txt
@@ -1,5 +1,4 @@
VHDFunctions,http://poshcode.org/get/1451,VHD utilities
-pscx,http://pscx.codeplex.com/,PowerShell Community Extensions
PSClientManager,http://archive.msdn.microsoft.com/PSClientManager,PowerShell module to Add/Remove Windows 7 features
LINQ,http://www.josheinstein.com/blog/index.php/2010/02/linq-for-powershell/,LINQ for PowerShell https://github.com/fschwiet/linq-powershell
todo.txt,https://github.com/hartez/todo.txt-PowerShell/,Implementation of todo.txt CLI for PowerShell
View
18 PsGet/PsGet.psm1
@@ -92,9 +92,11 @@ Param(
Copy-Item $CandidateFilePath $TempModuleFolderPath
}
- ## Let’s try guessing module name
- if ($ModuleName -eq ""){
- $BestCandidateModule = (Get-ChildItem $TempModuleFolderPath -Filter "*.psm1" -Recurse | select -Index 0).FullName
+ # Let’s try guessing module name
+ if ($ModuleName -eq ""){
+ $BestCandidateModule = (Get-ChildItem $TempModuleFolderPath -Filter "*.psm1" -Recurse -File |
+ Sort-Object DirectoryName.Length -Desc |
+ Select-Object -Index 0).FullName
$ModuleName = [IO.Path]::GetFileNameWithoutExtension($BestCandidateModule)
}
@@ -394,21 +396,21 @@ Param(
[Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, Mandatory=$true, Position=0)]
$SourceFolderPath,
[Parameter(Mandatory=$true)]
- [String]$ModuleName,
+ [String]$ModuleName,
[Switch]$Global = $false,
[Switch]$DoNotImport = $false,
[Switch]$Startup = $false,
[Switch]$Force = $false
-)
+)
if (-not (CheckIfNeedInstallAndImportIfNot $ModuleName $Force $DoNotImport)){
return;
}
- ## Note: This assumes that your PSModulePath is unaltered
- ## Or at least, that it has the LOCAL path first and GLOBAL path second
+ # Note: This assumes that your PSModulePath is unaltered
+ # Or at least, that it has the LOCAL path first and GLOBAL path second
$PSModulePath = $Env:PSModulePath -split ";" | Select -Index ([int][bool]$Global)
- ## Make a folder for the module
+ # Make a folder for the module
$ModuleFolderPath = ([System.IO.Path]::Combine($PSModulePath, $ModuleName))
if ((Test-Path $ModuleFolderPath) -eq $false) {
View
BIN TestModules/HelloWorldFolderWithChildModules.zip
Binary file not shown.
View
8 Tests.ps1
@@ -43,6 +43,14 @@ install-module -ModuleUrl https://github.com/chaliy/psget/raw/master/TestModules
assert-moduleinstalled "HelloWorld"
drop-module "HelloWorld"
+write-host Should support zipped with child modules
+# The problem was with PSCX, they have many child modules
+# And PsGet was loading one of child module instead.
+# This test ensues that only main module is loaded
+install-module -ModulePath $here\TestModules\HelloWorldFolderWithChildModules.zip -Verbose
+assert-moduleinstalled "HelloWorld"
+drop-module "HelloWorld"
+
write-host Should support local PSM1 modules
install-module -ModulePath $here\TestModules\HelloWorld.psm1 -Verbose
assert-moduleinstalled "HelloWorld"

0 comments on commit 9ffcbdf

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