pimi-launcher-core/components/package.js

17 lines
637 B
JavaScript
Raw Normal View History

2019-05-23 01:28:48 +03:00
const path = require('path');
const zip = require('adm-zip');
2019-07-28 19:52:53 +03:00
const shelljs = require('shelljs');
2019-05-23 01:28:48 +03:00
2019-07-28 19:52:53 +03:00
module.exports.extractPackage = function(e) {
2019-05-23 01:28:48 +03:00
return new Promise(async resolve => {
2019-07-28 19:52:53 +03:00
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")
2019-05-23 01:28:48 +03:00
}
2019-07-28 19:52:53 +03:00
new zip(e.options.clientPackage).extractAllTo(e.options.root, true);
e.emit('package-extract', true);
shelljs.rm(e.options.clientPackage);
2019-05-23 01:28:48 +03:00
resolve();
});
2019-07-28 19:52:53 +03:00
};