From 61d3201843183e2d212bfd22564c20b54b3b3291 Mon Sep 17 00:00:00 2001 From: Oj Date: Mon, 4 Apr 2022 15:45:37 +0100 Subject: [PATCH] [Updater > Module] Minor source cleanup --- src/updater/moduleUpdater.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/updater/moduleUpdater.js b/src/updater/moduleUpdater.js index 2f34b4f..5e3bc40 100644 --- a/src/updater/moduleUpdater.js +++ b/src/updater/moduleUpdater.js @@ -195,16 +195,12 @@ const downloadModule = async (name, ver) => { const path = join(downloadPath, name + '-' + ver + '.zip'); const stream = fs.createWriteStream(path); - stream.on('progress', ([cur, total]) => { - const progress = Math.min(100, Math.floor(100 * (cur / total))); - - events.emit('downloading-module-progress', { - name, - progress, - cur, - total - }); - }); + stream.on('progress', ([ cur, total ]) => events.emit('downloading-module-progress', { + name, + progress: Math.min(100, Math.floor(100 * (cur / total))), + cur, + total + })); log('Modules', 'Downloading', `${name}@${ver}`, 'from', url, 'to', path); @@ -304,11 +300,9 @@ const installModule = async (name, ver, path) => { if (!y.includes('inflating')) return; cur++; - const progress = Math.min(100, Math.floor(cur / total * 100)); - events.emit('installing-module-progress', { name, - progress, + progress: Math.min(100, Math.floor(cur / total * 100)), cur, total });