mirror of
https://github.com/acedanger/dotfiles.git
synced 2025-12-05 22:30:13 -08:00
Refactor Install-CustomModules function to improve module installation logic
This commit is contained in:
@@ -7,10 +7,11 @@ function Install-CustomModules {
|
|||||||
)
|
)
|
||||||
# check if module is installed
|
# check if module is installed
|
||||||
$moduleInfo = Get-Module -ListAvailable -Name $ModuleName -ErrorAction SilentlyContinue
|
$moduleInfo = Get-Module -ListAvailable -Name $ModuleName -ErrorAction SilentlyContinue
|
||||||
if (-not $moduleInfo) {
|
if ($moduleInfo) { return }
|
||||||
Write-Host "${ModuleName} module not found." -ForegroundColor Red
|
|
||||||
Install-Module -Name $ModuleName -Scope CurrentUser
|
Write-Host "${ModuleName} module not found." -ForegroundColor Red
|
||||||
}
|
Install-Module -Name $ModuleName -Scope CurrentUser
|
||||||
|
|
||||||
Import-Module -Name $ModuleName
|
Import-Module -Name $ModuleName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ function Install-CustomModules {
|
|||||||
)
|
)
|
||||||
# check if module is installed
|
# check if module is installed
|
||||||
$moduleInfo = Get-Module -ListAvailable -Name $ModuleName -ErrorAction SilentlyContinue
|
$moduleInfo = Get-Module -ListAvailable -Name $ModuleName -ErrorAction SilentlyContinue
|
||||||
if (-not $moduleInfo) {
|
if ($moduleInfo) { return }
|
||||||
Write-Host "${ModuleName} module not found." -ForegroundColor Red
|
|
||||||
Install-Module -Name $ModuleName -Scope CurrentUser
|
Write-Host "${ModuleName} module not found." -ForegroundColor Red
|
||||||
}
|
Install-Module -Name $ModuleName -Scope CurrentUser
|
||||||
|
|
||||||
Import-Module -Name $ModuleName
|
Import-Module -Name $ModuleName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user