admin 管理员组文章数量: 1087134
I'm trying to debug my updater on my app. I got the basic checkForUpdatesAndNotify working. However i am trying to add custom dialog boxes because the base dialog is kind of clunky. It shows com.electron for the name, and theres status of any thing and it just closes and eventually reopens. The issue I'm having is its not alerting me. So im trying to implement a electron-log so i can whats going on. However webstorm is telling me TS2339: Property transports does not exist on type (...params: any[]) => void
for the log.transports line. And its telling me TS2322: Type (...params: any[]) => void is not assignable to type Logger
for the autoUpdater.logger line.
Can someone please enlighten me on what i am doing wrong?
My logger code is this...
import { autoUpdater } from "electron-updater";
import { log } from "electron-log/node";
log.transports.file.level = "debug";
autoUpdater.logger = log;
autoUpdater.autoDownload = false;
My dialog code is this...
autoUpdater.checkForUpdates();
log(autoUpdater);
autoUpdater.on("checking-for-update", () => {
dialog.showMessageBox({
type: "info",
title: "Checking for Updates",
message: "Checking for updates...",
});
});
autoUpdater.on("update-available", () => {
dialog.showMessageBox(
{
// @ts-ignore
type: "info",
title: "Update Available",
message: "A new version of the app is available. Do you want to update now?",
buttons: ["Update", "No"],
},
(index: any) => {
if (index === 0) {
autoUpdater.downloadUpdate();
}
},
);
});
I'm trying to debug my updater on my app. I got the basic checkForUpdatesAndNotify working. However i am trying to add custom dialog boxes because the base dialog is kind of clunky. It shows com.electron for the name, and theres status of any thing and it just closes and eventually reopens. The issue I'm having is its not alerting me. So im trying to implement a electron-log so i can whats going on. However webstorm is telling me TS2339: Property transports does not exist on type (...params: any[]) => void
for the log.transports line. And its telling me TS2322: Type (...params: any[]) => void is not assignable to type Logger
for the autoUpdater.logger line.
Can someone please enlighten me on what i am doing wrong?
My logger code is this...
import { autoUpdater } from "electron-updater";
import { log } from "electron-log/node";
log.transports.file.level = "debug";
autoUpdater.logger = log;
autoUpdater.autoDownload = false;
My dialog code is this...
autoUpdater.checkForUpdates();
log(autoUpdater);
autoUpdater.on("checking-for-update", () => {
dialog.showMessageBox({
type: "info",
title: "Checking for Updates",
message: "Checking for updates...",
});
});
autoUpdater.on("update-available", () => {
dialog.showMessageBox(
{
// @ts-ignore
type: "info",
title: "Update Available",
message: "A new version of the app is available. Do you want to update now?",
buttons: ["Update", "No"],
},
(index: any) => {
if (index === 0) {
autoUpdater.downloadUpdate();
}
},
);
});
Share
Improve this question
asked Mar 27 at 17:23
Chris WilliamsonChris Williamson
812 silver badges9 bronze badges
1 Answer
Reset to default 1Through many hours of searching and finding different ways to test i have discovered that you can use catch to get any errors. Apparently the stuff that pulls up in google search is old. As for the dialog box its also not done like that anymore. For anyone wanting to know this is the updated code...
autoUpdater.checkForUpdates().catch((err)=>log(err));
autoUpdater.on("update-available", () => {
dialog
.showMessageBox({
type: "question",
title: "Update Available",
message: "A new version of the app is available. Do you want to update now?",
buttons: ["Update", "No"],
})
.then((response) => {
if (response.response === 0) {
autoUpdater.downloadUpdate().catch((err)=>log(err));
}
});
});
Hoping this helps someone. Maybe this is common knowledge and i didn't look in the right place.
本文标签: typescriptLogging electronupdater with electronlogStack Overflow
版权声明:本文标题:typescript - Logging electron-updater with electron-log - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744077124a2529558.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论