Get package from url

This commit is contained in:
Pierce 2019-01-13 20:31:17 -05:00
parent 2b6fa2a973
commit 2f0c3b3c44
2 changed files with 8 additions and 2 deletions

View file

@ -3,6 +3,7 @@ const shelljs = require('shelljs');
const path = require('path'); const path = require('path');
const request = require('request'); const request = require('request');
const zip = require('adm-zip'); const zip = require('adm-zip');
const event = require('./events');
function downloadAsync (url, directory, name) { function downloadAsync (url, directory, name) {
@ -220,8 +221,13 @@ module.exports.makePackage = async function(versions, os) {
}; };
module.exports.extractPackage = function(root, clientPackage) { module.exports.extractPackage = function(root, clientPackage) {
return new Promise(resolve => { return new Promise(async resolve => {
if(clientPackage.startsWith('http')) {
await downloadAsync(clientPackage, root, "clientPackage.zip")
clientPackage = path.join(root, "clientPackage.zip")
}
new zip(clientPackage).extractAllTo(root, true); new zip(clientPackage).extractAllTo(root, true);
event.emit('package-extract', true);
resolve(); resolve();
}); });
}; };

View file

@ -1,6 +1,6 @@
{ {
"name": "minecraft-launcher-core", "name": "minecraft-launcher-core",
"version": "1.1.0", "version": "1.2.0",
"description": "Module that downloads Minecraft assets and runs Minecraft.", "description": "Module that downloads Minecraft assets and runs Minecraft.",
"main": "index.js", "main": "index.js",
"dependencies": { "dependencies": {