Skip to content

Commit

Permalink
Changed global install of PowerShell modules to $globaldir\Modules
Browse files Browse the repository at this point in the history
  • Loading branch information
gerardog committed Aug 22, 2023
1 parent 32f4350 commit 044d076
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
1 change: 1 addition & 0 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ function filesize($length) {
function basedir($global) { if($global) { return $globaldir } $scoopdir }
function appsdir($global) { "$(basedir $global)\apps" }
function shimdir($global) { "$(basedir $global)\shims" }
function modulesdir($global) { "$(basedir $global)\modules" }
function appdir($app, $global) { "$(appsdir $global)\$app" }
function versiondir($app, $version, $global) { "$(appdir $app $global)\$version" }

Expand Down
18 changes: 4 additions & 14 deletions lib/psmodules.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
$modulesdir = "$scoopdir\modules"
$globalmodulesdir = "$env:ProgramFiles\WindowsPowerShell\Modules" # https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_psmodulepath

function install_psmodule($manifest, $dir, $global) {
$psmodule = $manifest.psmodule
if (!$psmodule) { return }

if ($global) {
$targetdir = ensure $globalmodulesdir
} else {
$targetdir = ensure $modulesdir;
ensure_in_psmodulepath $modulesdir $global
}
$targetdir = ensure (modulesdir $global)

ensure_in_psmodulepath $targetdir $global

$module_name = $psmodule.name
if (!$module_name) {
Expand All @@ -37,11 +31,7 @@ function uninstall_psmodule($manifest, $dir, $global) {
$module_name = $psmodule.name
Write-Host "Uninstalling PowerShell module '$module_name'."

if ($global) {
$targetdir = ensure $globalmodulesdir
} else {
$targetdir = ensure $modulesdir;
}
$targetdir = modulesdir $global

$linkfrom = "$targetdir\$module_name"
if (Test-Path $linkfrom) {
Expand Down

0 comments on commit 044d076

Please sign in to comment.