Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
* master:
  (version) 0.11.3
  (version) 0.11.3-beta
  (maint) Prevent inclusion of snk file
  (#2336) Remove quotes from InstallLocation
  (#877) Set SourceType for packages parsed from config
  (#2289) Add acknowledgements and license files
  (#2289) Update Rhino.Licensing dependency
  (maint) Replace unversioned Rhino.Licensing dll
  (#2398) Restore PowerShell v2 support
  (#2412) Switch to output warning on failure

# Conflicts:
#	.uppercut
  • Loading branch information
gep13 committed Oct 27, 2021
2 parents 29e5390 + 22b7856 commit c0fbb14
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
28 changes: 17 additions & 11 deletions src/chocolatey.resources/helpers/chocolateyInstaller.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,24 @@ if (Test-Path $extensionsPath) {
Write-Debug "Importing '$licensedExtensionPath'"
Write-Debug "Loading 'chocolatey.licensed' extension"

# Attempt to import module via already-loaded assembly
$licensedAssembly = $currentAssemblies |
Where-Object { $_.GetName().Name -eq 'chocolatey.licensed' } |
Select-Object -First 1

if ($licensedAssembly) {
# It's already loaded, just import the existing assembly as a module for PowerShell to use
Import-Module $licensedAssembly
try {
# Attempt to import module via already-loaded assembly
$licensedAssembly = $currentAssemblies |
Where-Object { $_.GetName().Name -eq 'chocolatey.licensed' } |
Select-Object -First 1

if ($licensedAssembly) {
# It's already loaded, just import the existing assembly as a module for PowerShell to use
Import-Module $licensedAssembly
}
else {
# Fallback: load the extension DLL from the path directly.
Import-Module $licensedExtensionPath
}
}
else {
# Fallback: load the extension DLL from the path directly.
Import-Module $licensedExtensionPath
catch {
# Only write a warning if the Licensed extension failed to load in some way.
Write-Warning "Import failed for Chocolatey Licensed Extension. Error: '$_'"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ Start-ChocolateyProcessAsAdmin
}

$installerTypeLower = $fileType.ToLower()
if ($installerTypeLower -notin 'msi', 'exe', 'msu', 'msp') {
if ('msi', 'exe', 'msu', 'msp' -notcontains $installerTypeLower) {
Write-Warning "FileType '$fileType' is unrecognized, using 'exe' instead."
$fileType = 'exe'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ None

#ordering is important here, $user should override $machine...
$ScopeList = 'Process', 'Machine'
if ($userName -notin 'SYSTEM', "${env:COMPUTERNAME}`$") {
if ('SYSTEM', "${env:COMPUTERNAME}`$" -notcontains $userName) {
# but only if not running as the SYSTEM/machine in which case user can be ignored.
$ScopeList += 'User'
}
Expand Down

0 comments on commit c0fbb14

Please sign in to comment.