diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b5933ca2a..144ff603c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - **install:** Add separator at the end of notes, highlight suggestions ([#6418](https://github.com/ScoopInstaller/Scoop/issues/6418)) - **download|scoop-download:** Add GitHub issue prompt when the default downloader fails ([#6539](https://github.com/ScoopInstaller/Scoop/issues/6539)) - **download|scoop-config:** Allow disabling automatic fallback to the default downloader when Aria2c download fails ([#6538](https://github.com/ScoopInstaller/Scoop/issues/6538)) +- **lib** Allow `env_add_path` and `shortcuts` field to use variables ([#6616](https://github.com/ScoopInstaller/Scoop/issues/6616)) ### Bug Fixes diff --git a/lib/install.ps1 b/lib/install.ps1 index 78acdd252b..1d78415be2 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -59,8 +59,8 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru create_shims $manifest $dir $global $architecture create_startmenu_shortcuts $manifest $dir $global $architecture install_psmodule $manifest $dir $global - env_add_path $manifest $dir $global $architecture env_set $manifest $global $architecture + env_add_path $manifest $dir $global $architecture # persist data persist_data $manifest $original_dir $persist_dir @@ -317,7 +317,13 @@ function env_add_path($manifest, $dir, $global, $arch) { if (get_config USE_ISOLATED_PATH) { Add-Path -Path ('%' + $scoopPathEnvVar + '%') -Global:$global } - $path = $env_add_path.Where({ $_ }).ForEach({ Join-Path $dir $_ | Get-AbsolutePath }).Where({ is_in_dir $dir $_ }) + $path = $env_add_path.Where({ $_ }) | ForEach-Object { + if ($_ -like '$*'){ + $ExecutionContext.InvokeCommand.ExpandString($_) + }else{ + Join-Path $dir $_ | Get-AbsolutePath | Where-Object { is_in_dir $dir $_ } + } + } Add-Path -Path $path -TargetEnvVar $scoopPathEnvVar -Global:$global -Force } } @@ -326,7 +332,13 @@ function env_rm_path($manifest, $dir, $global, $arch) { $env_add_path = arch_specific 'env_add_path' $manifest $arch $dir = $dir.TrimEnd('\') if ($env_add_path) { - $path = $env_add_path.Where({ $_ }).ForEach({ Join-Path $dir $_ | Get-AbsolutePath }).Where({ is_in_dir $dir $_ }) + $path = $env_add_path.Where({ $_ }) | ForEach-Object { + if ($_ -like '$*'){ + $ExecutionContext.InvokeCommand.ExpandString($_) + }else{ + Join-Path $dir $_ | Get-AbsolutePath | Where-Object { is_in_dir $dir $_ } + } + } Remove-Path -Path $path -Global:$global # TODO: Remove after forced isolating Scoop path Remove-Path -Path $path -TargetEnvVar $scoopPathEnvVar -Global:$global } diff --git a/lib/shortcuts.ps1 b/lib/shortcuts.ps1 index edb6357480..f730aa97f5 100644 --- a/lib/shortcuts.ps1 +++ b/lib/shortcuts.ps1 @@ -2,7 +2,12 @@ function create_startmenu_shortcuts($manifest, $dir, $global, $arch) { $shortcuts = @(arch_specific 'shortcuts' $manifest $arch) $shortcuts | Where-Object { $_ -ne $null } | ForEach-Object { - $target = [System.IO.Path]::Combine($dir, $_.item(0)) + $target = $_.item(0) + if($target -like '$*'){ + $target = $ExecutionContext.InvokeCommand.ExpandString($target) + }else{ + $target = [System.IO.Path]::Combine($dir, $target) + } $target = New-Object System.IO.FileInfo($target) $name = $_.item(1) $arguments = '' @@ -11,7 +16,12 @@ function create_startmenu_shortcuts($manifest, $dir, $global, $arch) { $arguments = $_.item(2) } if ($_.length -ge 4) { - $icon = [System.IO.Path]::Combine($dir, $_.item(3)) + $icon = $_.item(3) + if($icon -like '$*'){ + $icon = $ExecutionContext.InvokeCommand.ExpandString($icon) + }else{ + $icon = [System.IO.Path]::Combine($dir, $icon) + } $icon = New-Object System.IO.FileInfo($icon) } $arguments = (substitute $arguments @{ '$dir' = $dir; '$original_dir' = $original_dir; '$persist_dir' = $persist_dir }) diff --git a/libexec/scoop-reset.ps1 b/libexec/scoop-reset.ps1 index 1dd000a373..72fb011c7e 100644 --- a/libexec/scoop-reset.ps1 +++ b/libexec/scoop-reset.ps1 @@ -83,8 +83,8 @@ $apps | ForEach-Object { # unset all potential old env before re-adding env_rm_path $manifest $dir $global $architecture env_rm $manifest $global $architecture - env_add_path $manifest $dir $global $architecture env_set $manifest $global $architecture + env_add_path $manifest $dir $global $architecture # unlink all potential old link before re-persisting unlink_persist_data $manifest $original_dir persist_data $manifest $original_dir $persist_dir