fix(hooks): preserve WSL desktop notify success path

This commit is contained in:
Affaan Mustafa
2026-03-30 03:02:17 -04:00
parent 99ff568c0e
commit 2595c92983
2 changed files with 124 additions and 15 deletions

View File

@@ -71,7 +71,12 @@ function notifyWindows(pwshPath, title, body) {
const command = `Import-Module BurntToast; New-BurntToastNotification -Text '${safeTitle}', '${safeBody}'`;
const result = spawnSync(pwshPath, ['-Command', command],
{ stdio: ['ignore', 'pipe', 'pipe'], timeout: 5000 });
return result.status === 0;
if (result.error || result.status !== 0) {
const stderr = typeof result.stderr?.toString === 'function' ? result.stderr.toString().trim() : '';
log(`[DesktopNotify] BurntToast failed (exit ${result.status}): ${result.error ? result.error.message : stderr}`);
return false;
}
return true;
}
/**
@@ -108,20 +113,6 @@ function notifyMacOS(title, body) {
}
}
/**
* Send a Windows Toast notification via PowerShell BurntToast.
* Used when running under WSL to show notification on Windows desktop.
*/
function notifyWindows(pwshPath, title, body) {
const safeBody = body.replace(/'/g, "''");
const safeTitle = title.replace(/'/g, "''");
const command = `Import-Module BurntToast; New-BurntToastNotification -Text '${safeTitle}', '${safeBody}'`;
const result = spawnSync(pwshPath, ['-Command', command], { stdio: ['ignore', 'pipe', 'pipe'], timeout: 5000 });
if (result.error || result.status !== 0) {
log(`[DesktopNotify] BurntToast failed (exit ${result.status}): ${result.error ? result.error.message : result.stderr?.toString()}`);
}
}
/**
* Fast-path entry point for run-with-flags.js (avoids extra process spawn).
*/