electron / fiddle-core

Run fiddles from anywhere, on any Electron release
MIT License
13 stars 16 forks source link

feat: add progress callback handler to installer #30

Closed aryanshridhar closed 2 years ago

aryanshridhar commented 2 years ago

This commit essentially adds the functionality for allowing users to pass a callback function to -

which is triggered when an electron binary is being downloaded.

Usage -

import { Installer, ProgressObject } from 'fiddle-core';
const installer = new Installer();

const callback = (progress: ProgressObject) => {
  const percent = progress.percent * 100;
  console.log(`Current download progress %: ${percent.toFixed(2)}`);
};

await installer.ensureDownloaded('12.0.15', callback);
// OR
await installer.install('12.0.15', callback);
aryanshridhar commented 2 years ago

(Opening a new pr with the support for downloading from a specific mirror as well along with this)