@timmy6942025/cli-timer 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +20 -2
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -480,6 +480,21 @@ function spawnOk(command, args, options) {
|
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
482
|
|
|
483
|
+
function terminalNotifierDelivered(groupId) {
|
|
484
|
+
try {
|
|
485
|
+
const listed = spawnSync("terminal-notifier", ["-list", groupId], { encoding: "utf8", stdio: "pipe" });
|
|
486
|
+
if (listed.error || listed.status !== 0) {
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
const output = String(listed.stdout || "");
|
|
490
|
+
return output.includes(groupId);
|
|
491
|
+
} catch (_error) {
|
|
492
|
+
return false;
|
|
493
|
+
} finally {
|
|
494
|
+
spawnOk("terminal-notifier", ["-remove", groupId]);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
483
498
|
function sendSystemNotification({ title, message }) {
|
|
484
499
|
const safeTitle = String(title || "").trim() || "Timer";
|
|
485
500
|
const safeMessage = String(message || "").trim();
|
|
@@ -490,8 +505,11 @@ function sendSystemNotification({ title, message }) {
|
|
|
490
505
|
|
|
491
506
|
try {
|
|
492
507
|
if (process.platform === "darwin") {
|
|
493
|
-
|
|
494
|
-
|
|
508
|
+
const groupId = `cli-timer-${Date.now()}-${Math.floor(Math.random() * 1e9)}`;
|
|
509
|
+
if (spawnOk("terminal-notifier", ["-title", safeTitle, "-message", safeMessage, "-group", groupId])) {
|
|
510
|
+
if (terminalNotifierDelivered(groupId)) {
|
|
511
|
+
return true;
|
|
512
|
+
}
|
|
495
513
|
}
|
|
496
514
|
const script = `display notification "${escapeAppleScriptString(safeMessage)}" with title "${escapeAppleScriptString(safeTitle)}"`;
|
|
497
515
|
if (spawnOk("osascript", ["-e", script])) {
|