Skip to content

Commit 765ebe9

Browse files
committed
feat: forward Velopack hooks to main app and add --noLaunch flag
1 parent 7a9489c commit 765ebe9

3 files changed

Lines changed: 51 additions & 19 deletions

File tree

.github/workflows/dev-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ jobs:
6767
$notes = git log -n 5 --pretty=format:"* %s (%h)"
6868
"### Recent Changes (Dev Build):`n$notes" | Out-File -FilePath release_notes.md -Encoding utf8
6969
70-
- name: Velopack Pack
71-
run: |
72-
& "$HOME\.dotnet\tools\vpk.exe" pack --packId Hammer5Tools --packVersion ${{ steps.version.outputs.app_version }} --packDir Hammer5Tools --mainExe Hammer5Tools.exe --icon src/appicon.ico --channel dev --noPortable --releaseNotes release_notes.md
70+
- name: Velopack Pack
71+
run: |
72+
& "$HOME\.dotnet\tools\vpk.exe" pack --packId Hammer5Tools --packVersion ${{ steps.version.outputs.app_version }} --packDir Hammer5Tools --mainExe Hammer5Tools.exe --icon src/appicon.ico --channel dev --noPortable --releaseNotes release_notes.md --noLaunch
7373
7474
7575

.github/workflows/stable-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ jobs:
6767
if (-not $msg) { $msg = "Hammer 5 Tools Release ${{ github.ref_name }}" }
6868
$msg | Out-File -FilePath release_notes.md -Encoding utf8
6969
70-
- name: Velopack Pack
71-
run: |
72-
& "$HOME\.dotnet\tools\vpk.exe" pack --packId Hammer5Tools --packVersion ${{ steps.version.outputs.app_version }} --packDir Hammer5Tools --mainExe Hammer5Tools.exe --icon src/appicon.ico --channel stable --noPortable --releaseNotes release_notes.md
70+
- name: Velopack Pack
71+
run: |
72+
& "$HOME\.dotnet\tools\vpk.exe" pack --packId Hammer5Tools --packVersion ${{ steps.version.outputs.app_version }} --packDir Hammer5Tools --mainExe Hammer5Tools.exe --icon src/appicon.ico --channel stable --noPortable --releaseNotes release_notes.md --noLaunch
7373
7474
7575

launcher/main.cpp

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,52 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
4949
std::string command = "show";
5050
std::string editor_type = "smartprop";
5151

52-
for (int i = 1; i < argc; i++) {
53-
// Handle Velopack hooks by exiting immediately.
54-
// Logic moved to main application.
55-
if (wcscmp(argv[i], L"--squirrel-install") == 0 ||
56-
wcscmp(argv[i], L"--squirrel-updated") == 0 ||
57-
wcscmp(argv[i], L"--squirrel-uninstall") == 0 ||
58-
wcscmp(argv[i], L"--squirrel-obsoleted") == 0 ||
59-
wcscmp(argv[i], L"--velopack-install") == 0 ||
60-
wcscmp(argv[i], L"--velopack-updated") == 0 ||
61-
wcscmp(argv[i], L"--velopack-uninstall") == 0 ||
62-
wcscmp(argv[i], L"--velopack-obsoleted") == 0) {
63-
LocalFree(argv);
64-
return 0;
52+
// Check if this is a Velopack hook that needs to be forwarded to main app
53+
const wchar_t* HOOKS[] = {
54+
L"--velopack-install", L"--velopack-updated",
55+
L"--velopack-uninstall", L"--velopack-obsoleted", L"--velopack-obsolete",
56+
L"--squirrel-install", L"--squirrel-updated",
57+
L"--squirrel-uninstall", L"--squirrel-obsoleted", L"--squirrel-obsolete",
58+
nullptr
59+
};
60+
61+
bool is_hook = false;
62+
for (int i = 1; i < argc && !is_hook; i++) {
63+
for (int j = 0; HOOKS[j]; j++) {
64+
if (wcscmp(argv[i], HOOKS[j]) == 0) {
65+
is_hook = true;
66+
break;
67+
}
68+
}
69+
}
70+
71+
// If this is a hook, forward it to Hammer5Tools.exe and wait for completion
72+
if (is_hook) {
73+
wchar_t buf[MAX_PATH];
74+
GetModuleFileNameW(NULL, buf, MAX_PATH);
75+
fs::path app_exe = fs::path(buf).parent_path() / L"Hammer5Tools.exe";
76+
77+
if (fs::exists(app_exe)) {
78+
STARTUPINFOW si = { sizeof(si) };
79+
PROCESS_INFORMATION pi = {};
80+
std::wstring cmd = L"\"" + app_exe.wstring() + L"\" " + GetCommandLineW();
81+
std::vector<wchar_t> cmdBuf(cmd.begin(), cmd.end());
82+
cmdBuf.push_back(0);
83+
84+
if (CreateProcessW(NULL, cmdBuf.data(), NULL, NULL, FALSE,
85+
CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) {
86+
// Wait up to 30 seconds for the process to complete (backup/hook handling)
87+
WaitForSingleObject(pi.hProcess, 30000);
88+
CloseHandle(pi.hProcess);
89+
CloseHandle(pi.hThread);
90+
}
6591
}
92+
93+
LocalFree(argv);
94+
return 0;
95+
}
96+
97+
for (int i = 1; i < argc; i++) {
6698

6799
if (wcscmp(argv[i], L"--create-vmdl") == 0 && i + 1 < argc) {
68100
command = "create_vmdl";

0 commit comments

Comments
 (0)