Download progress event

This commit is contained in:
Pierce 2019-01-28 17:26:04 -05:00
parent 2f0c3b3c44
commit a4a653d8fa
2 changed files with 9 additions and 2 deletions

View file

@ -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);

View file

@ -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": {