Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
js: handle empty progress delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Feb 27, 2024
1 parent d7c5f86 commit 4d5bb61
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
8 changes: 5 additions & 3 deletions for-js/Velopack.js
Original file line number Diff line number Diff line change
Expand Up @@ -1200,9 +1200,11 @@ class UpdateManager extends UpdateManagerSync {
async downloadUpdatesAsync(toDownload, progress) {
const command = this.getDownloadUpdatesCommand(toDownload);
await nativeStartProcessAsyncReadLine(command, (data) => {
const p = parseInt(data);
if (!isNaN(p) && p > 0) {
progress(p);
if (progress && progress instanceof Function) {
const p = parseInt(data);
if (!isNaN(p) && p > 0) {
progress(p);
}
}
});
}
Expand Down
8 changes: 5 additions & 3 deletions for-js/Velopack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1331,9 +1331,11 @@ export class UpdateManager extends UpdateManagerSync {
): Promise<void> {
const command: string[] = this.getDownloadUpdatesCommand(toDownload);
await nativeStartProcessAsyncReadLine(command, (data: string) => {
const p = parseInt(data);
if (!isNaN(p) && p > 0) {
progress(p);
if (progress && progress instanceof Function) {
const p = parseInt(data);
if (!isNaN(p) && p > 0) {
progress(p);
}
}
});
}
Expand Down
8 changes: 5 additions & 3 deletions src/include/ts_end.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ export class UpdateManager extends UpdateManagerSync {
public async downloadUpdatesAsync(toDownload: VelopackAsset, progress: (arg: number) => void): Promise<void> {
const command: string[] = this.getDownloadUpdatesCommand(toDownload);
await nativeStartProcessAsyncReadLine(command, (data: string) => {
const p = parseInt(data);
if (!isNaN(p) && p > 0) {
progress(p);
if (progress && progress instanceof Function) {
const p = parseInt(data);
if (!isNaN(p) && p > 0) {
progress(p);
}
}
});
}
Expand Down

0 comments on commit 4d5bb61

Please sign in to comment.