mirror of
https://github.com/artegoser/pimi-launcher-core.git
synced 2024-11-22 12:16:21 +03:00
Download progress event
This commit is contained in:
parent
2f0c3b3c44
commit
a4a653d8fa
2 changed files with 9 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -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": {
|
||||
|
|
Loading…
Add table
Reference in a new issue