token-stats-timer 1.0.3 → 1.0.4
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/notify.ts +16 -17
- package/package.json +1 -1
package/notify.ts
CHANGED
|
@@ -75,11 +75,6 @@ function truncate(s: string, max = 80): string {
|
|
|
75
75
|
return s.length > max ? s.slice(0, max) + "…" : s;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
function cwdName(): string {
|
|
79
|
-
const parts = process.cwd().split("/").filter(Boolean);
|
|
80
|
-
return parts.pop() || process.cwd();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
78
|
export function createNotifier(pi: ExtensionAPI): void {
|
|
84
79
|
let config: NotifyConfig = loadConfig();
|
|
85
80
|
|
|
@@ -147,18 +142,22 @@ export function createNotifier(pi: ExtensionAPI): void {
|
|
|
147
142
|
|
|
148
143
|
const dur = startMs !== undefined ? ` · ${formatDuration(durationMs)}` : "";
|
|
149
144
|
|
|
150
|
-
if (runFailed
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
145
|
+
if (runFailed) {
|
|
146
|
+
if (config.onFailure) {
|
|
147
|
+
notify(
|
|
148
|
+
"❌ pi 执行失败",
|
|
149
|
+
`耗时:${dur}\n${truncate(runErrorMsg || "未知错误")}`,
|
|
150
|
+
config.sound,
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
} else if (runAborted) {
|
|
154
|
+
if (config.onAbort) {
|
|
155
|
+
notify(
|
|
156
|
+
"⏹ pi 已中止",
|
|
157
|
+
`耗时:${dur}\n${truncate(runErrorMsg || "执行被中止")}`,
|
|
158
|
+
config.sound,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
162
161
|
} else if (config.onSuccess) {
|
|
163
162
|
notify(
|
|
164
163
|
"✅ pi 执行完成",
|