Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(core): Add scoop-shim helper #3438

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function Get-HelperPath {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[ValidateSet('7zip', 'Lessmsi', 'Innounp', 'Dark', 'Aria2')]
[ValidateSet('7zip', 'Lessmsi', 'Innounp', 'Dark', 'Aria2', 'Shim')]
[String]
$Helper
)
Expand All @@ -205,14 +205,15 @@ function Get-HelperPath {
'Innounp' { Get-AppFilePath 'innounp' 'innounp.exe' }
'Dark' { Get-AppFilePath 'dark' 'dark.exe' }
'Aria2' { Get-AppFilePath 'aria2' 'aria2c.exe' }
'Shim' { Get-AppFilePath 'scoop-shim' 'shim.exe' }
}
}

function Test-HelperInstalled {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[ValidateSet('7zip', 'Lessmsi', 'Innounp', 'Dark', 'Aria2')]
[ValidateSet('7zip', 'Lessmsi', 'Innounp', 'Dark', 'Aria2', 'Shim')]
[String]
$Helper
)
Expand Down Expand Up @@ -427,8 +428,11 @@ function shim($path, $global, $name, $arg) {
}

if($path -match '\.(exe|com)$') {
if(!(Test-HelperInstalled -Helper Shim)) {
scoop install 'main/scoop-shim'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manifest is missing binary. Is it intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, what would be the purpose of shimming the shim? 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use it then from anywhere and shim anything. Nice for users who want to shim custom executables.

Small workaround for #3303

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to avoid recursions 😁

It could just be copied from ~/scoop/apps/scoop-shim/current/shim.exe

}
# for programs with no awareness of any shell
Copy-Item "$(versiondir 'scoop' 'current')\supporting\shimexe\bin\shim.exe" "$shim.exe" -force
Copy-Item "$(versiondir 'scoop-shim' 'current')\shim.exe" "$shim.exe" -force
write-output "path = $resolved_path" | out-file "$shim.shim" -encoding utf8
if($arg) {
write-output "args = $arg" | out-file "$shim.shim" -encoding utf8 -append
Expand Down