@@ -3,13 +3,13 @@ function Update-GitModule {
33    [CmdletBinding (HelpUri = ' https://github.com/iricigor/InstallModuleFromGit/blob/master/Docs/Update-GitModule.md'  )]
44
55    param  (
6-          
7-          
6+ 
7+ 
88        [Parameter (Mandatory , ValueFromPipelineByPropertyName , Position = 0 , ParameterSetName = ' ByUri'  )]
99        [string []]$ProjectUri , 
1010        #  https://github.com/dfinke/InstallModuleFromGitHub
1111        #  https://github.com/iricigor/FIFA2018
12-          
12+ 
1313        [Parameter (Mandatory , ParameterSetName = ' ByName'  )]
1414        [string []]$Name , 
1515
@@ -29,10 +29,10 @@ function Update-GitModule {
2929        }
3030
3131        if  ($env: AGENT_TEMPDIRECTORY ) {
32-             $tmpRoot  =  $env: AGENT_TEMPDIRECTORY      
32+             $tmpRoot  =  $env: AGENT_TEMPDIRECTORY 
3333        } else  {
3434            $tmpRoot  =  [System.IO.Path ]::GetTempPath()
35-         }         
35+         }
3636
3737        if  ($Name ) {$ProjectUri  =  ConvertTo-Uri  - Name $Name }
3838
@@ -51,7 +51,10 @@ function Update-GitModule {
5151            #  TODO: continue only after cleanup!
5252
5353            #  Check version, and if higher install it
54-             $AllModules  =  @ ((Get-Module  - Name $ModuleName  - ListAvailable), (Get-InstalledModule  - Name $ModuleName )) |  Select Name,  Version
54+             $AllModules  =  @ (
55+                 (Get-Module  - Name $ModuleName  - ListAvailable), 
56+                 (Get-InstalledModule  - Name $ModuleName  - ErrorAction SilentlyContinue)
57+             ) |  Select Name,  Version
5558            $LocalModuleInfo  =  $AllModules  |  Sort-Object  Version - Descending |  Select - First 1 
5659            if  (! $LocalModuleInfo ) {
5760                Write-Error  " $FunctionName  cannot find local module '$ModuleName '" 
@@ -62,7 +65,6 @@ function Update-GitModule {
6265            } else  {
6366                Install-ModuleInfo  - ModuleInfo $RemoteModuleInfo  - DestinationPath $DestinationPath  - Force:$Force 
6467            }
65-             
6668        }
6769    }
6870
0 commit comments