diff --git a/components/handler.js b/components/handler.js index abcdf78..d182701 100644 --- a/components/handler.js +++ b/components/handler.js @@ -24,6 +24,13 @@ function downloadAsync (url, directory, name) { }); }); + _request.on('data', (data) => { + event.emit('download-status', { + "current": Math.round(fs.statSync(path.join(directory, name))["size"] / 10000), + "total": data.length + }) + }); + const file = fs.createWriteStream(path.join(directory, name)); _request.pipe(file); @@ -223,7 +230,7 @@ module.exports.makePackage = async function(versions, os) { module.exports.extractPackage = function(root, clientPackage) { return new Promise(async resolve => { if(clientPackage.startsWith('http')) { - await downloadAsync(clientPackage, root, "clientPackage.zip") + await downloadAsync(clientPackage, root, "clientPackage.zip"); clientPackage = path.join(root, "clientPackage.zip") } new zip(clientPackage).extractAllTo(root, true); diff --git a/package.json b/package.json index b3a449e..11c2867 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minecraft-launcher-core", - "version": "1.2.0", + "version": "1.2.1", "description": "Module that downloads Minecraft assets and runs Minecraft.", "main": "index.js", "dependencies": {