fix the download of client packages

This commit is contained in:
Pierce 2019-07-28 12:52:53 -04:00
parent b850909f5a
commit 001f52e150
4 changed files with 15 additions and 11 deletions

View file

@ -32,12 +32,14 @@ class MCLCore extends EventEmitter {
if(this.options.clientPackage) {
this.emit('debug', `[MCLC]: Extracting client package to ${this.options.root}`);
await packager.extractPackage(this.options.root, this.options.clientPackage);
await packager.extractPackage(this);
}
if(this.options.installer) {
// So the forge installer can run without breaking :)
fs.writeFileSync(path.join(this.options.root, 'launcher_profiles.json'), JSON.stringify({}, null, 4));
const profilePath = path.join(this.options.root, 'launcher_profiles.json');
if(!fs.existsSync(profilePath))
fs.writeFileSync(profilePath, JSON.stringify({}, null, 4));
await this.handler.runInstaller(this.options.installer)
}

View file

@ -1,14 +1,16 @@
const path = require('path');
const zip = require('adm-zip');
const shelljs = require('shelljs');
module.exports.extractPackage = function(root, clientPackage) {
module.exports.extractPackage = function(e) {
return new Promise(async resolve => {
if(clientPackage.startsWith('http')) {
await downloadAsync(clientPackage, root, "clientPackage.zip");
clientPackage = path.join(root, "clientPackage.zip")
if(e.options.clientPackage.startsWith('http')) {
await e.handler.downloadAsync(e.options.clientPackage, e.options.root, "clientPackage.zip");
e.options.clientPackage = path.join(e.options.root, "clientPackage.zip")
}
new zip(clientPackage).extractAllTo(root, true);
this.client.emit('package-extract', true);
new zip(e.options.clientPackage).extractAllTo(e.options.root, true);
e.emit('package-extract', true);
shelljs.rm(e.options.clientPackage);
resolve();
});
};
};