Skip to content

Commit 99b851c

Browse files
SiriosDevz-Fng
andauthored
grepwin: Fix portability (#17697)
Co-authored-by: z-Fng <54583083+z-Fng@users.noreply.github.com>
1 parent 4983ba4 commit 99b851c

1 file changed

Lines changed: 27 additions & 8 deletions

File tree

bucket/grepwin.json

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
"description": "Regular expression search and replace tool for Windows.",
44
"homepage": "https://tools.stefankueng.com/grepWin.html",
55
"license": "GPL-3.0-only",
6-
"notes": "Run '$dir\\install-context.reg' to add grepWin to right-click context menu.",
6+
"notes": [
7+
"To add grepWin to right-click context menu, run:",
8+
"reg import \"$dir\\install-context.reg\""
9+
],
710
"architecture": {
811
"64bit": {
912
"url": "https://github.com/stefankueng/grepWin/releases/download/2.1.12/grepWin-x64-2.1.12_portable.zip",
@@ -15,13 +18,14 @@
1518
}
1619
},
1720
"pre_install": [
18-
"Get-ChildItem \"$dir\\grepWin*.exe\" | Rename-Item -NewName 'grepWin.exe'",
21+
"Get-ChildItem \"$dir\\grepWin*.exe\" | Rename-Item -NewName 'grepWin_portable.exe'",
1922
"if (-not (Test-Path \"$persist_dir\\grepwin.ini\")) {",
2023
" Set-Content \"$dir\\grepwin.ini\" (@('[global]', '[Software\\grepWin\\History]') -join \"`r`n\") -Encoding ASCII",
2124
"}"
2225
],
2326
"post_install": [
24-
"$app_path = \"$dir\\grepWin.exe\".Replace('\\', '\\\\')",
27+
"# keep the 'portable' suffix to ensure it runs in portable mode.",
28+
"$app_path = \"$dir\\grepWin_portable.exe\".Replace('\\', '\\\\')",
2529
"'install-context.reg', 'uninstall-context.reg' | ForEach-Object {",
2630
" if (Test-Path \"$bucketsdir\\extras\\scripts\\grepwin\\$_\") {",
2731
" $content = Get-Content \"$bucketsdir\\extras\\scripts\\grepwin\\$_\"",
@@ -31,18 +35,33 @@
3135
" }",
3236
" }",
3337
" $content | Set-Content -Path \"$dir\\$_\" -Encoding ascii",
38+
"}",
39+
"# Workaround for https://github.com/ScoopInstaller/Extras/pull/17697 (Remove this workaround after 2027-01-01)",
40+
"if ($cmd -eq 'update') {",
41+
" $regPath = 'HKCU:\\Software\\Classes\\*\\shell\\grepWin\\command'",
42+
" if ($global) {",
43+
" $regPath = $regPath -replace '^HKCU', 'HKLM'",
44+
" }",
45+
" $regValue = Get-ItemProperty -LiteralPath $regPath -ErrorAction Ignore",
46+
" if ($regValue -and $regValue.'(default)' -match \"^$([regex]::Escape($(appdir $app $global)))\") {",
47+
" reg import \"$dir\\install-context.reg\" *> $null",
48+
" }",
3449
"}"
3550
],
36-
"bin": "grepWin.exe",
51+
"bin": [
52+
[
53+
"grepWin_portable.exe",
54+
"grepWin"
55+
]
56+
],
3757
"shortcuts": [
3858
[
39-
"grepWin.exe",
40-
"grepWin",
41-
"/portable"
59+
"grepWin_portable.exe",
60+
"grepWin"
4261
]
4362
],
4463
"persist": "grepwin.ini",
45-
"pre_uninstall": "if ($cmd -eq 'uninstall') { reg import \"$dir\\uninstall-context.reg\" }",
64+
"pre_uninstall": "if ($cmd -eq 'uninstall') { reg import \"$dir\\uninstall-context.reg\" *> $null }",
4665
"checkver": {
4766
"github": "https://github.com/stefankueng/grepWin"
4867
},

0 commit comments

Comments
 (0)