From bf5f2eb8338e040ed811b1d3c5ed3dccdcce715c Mon Sep 17 00:00:00 2001
From: Unknown
Date: Sat, 16 Jun 2018 11:39:15 +0100
Subject: fix a bug that broke multiple repos
---
pkg93.js | 78 +++++++++++++++++++++++++++++++++-------------------------------
1 file changed, 40 insertions(+), 38 deletions(-)
diff --git a/pkg93.js b/pkg93.js
index a73e908..2de828f 100644
--- a/pkg93.js
+++ b/pkg93.js
@@ -106,47 +106,49 @@ var pkg93 = {
cli = cli || {log: (i) => {$log(i);}};
var config = pkg93.getConfig();
config.pkglist = [];
- return new Promise((res, rej) => {
+ return new Promise(async (res, rej) => {
for (let source of config.repos) {
- try {
- console.log(source);
- cli.log("GET " + source + "/repo.json");
- var bardiv = cli.log(_abarpkg93uses(60, 0));
- var xhr = new XMLHttpRequest();
- xhr.open("GET", source + "/repo.json", true);
- xhr.onprogress = e => {
- bardiv.innerHTML = _abarpkg93uses(60, e.loaded / e.total);
- };
- xhr.onerror = () => {
- cli.log("ERR Fatal error while retriving package.json.");
- };
- xhr.onload = () => {
- try {
- console.log(xhr.responseText);
- var json = JSON.parse(xhr.responseText);
- cli.log("NAME " + json.name);
- cli.log("MSG " + json.msg);
- for (let item of json.packages) {
- try {
- config.pkglist.push(item + "@" + source);
- cli.log("OK " + item + "@" + source);
- } catch (err) {
- cli.log("ERR " + err.message);
+ await new Promise(async (reso, reje) => {
+ try {
+ console.log(source);
+ cli.log("GET " + source + "/repo.json");
+ var bardiv = cli.log(_abarpkg93uses(60, 0));
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", source + "/repo.json", true);
+ xhr.onprogress = e => {
+ bardiv.innerHTML = _abarpkg93uses(60, e.loaded / e.total);
+ };
+ xhr.onerror = () => {
+ cli.log("ERR Fatal error while retriving package.json.");
+ };
+ xhr.onload = () => {
+ try {
+ console.log(xhr.responseText);
+ var json = JSON.parse(xhr.responseText);
+ cli.log("NAME " + json.name);
+ cli.log("MSG " + json.msg);
+ for (let item of json.packages) {
+ try {
+ config.pkglist.push(item + "@" + source);
+ cli.log("OK " + item + "@" + source);
+ } catch (err) {
+ cli.log("ERR " + err.message);
+ }
}
+ reso();
+ } catch (err) {
+ console.error(err);
+ cli.log("ERR " + err.message);
+ console.log(xhr.responseText);
+ reje();
}
- } catch (err) {
- console.error(err);
- cli.log("ERR " + err.message);
- console.log(xhr.responseText);
- rej();
- }
- };
- xhr.send();
- } catch (err) {
- cli.log("ERR " + err.message);
- } finally {
- delete window.xhr;
- }
+ };
+ xhr.send();
+ } catch (err) {
+ cli.log("ERR " + err.message);
+ rej();
+ }
+ });
}
localStorage[".pkg93/config.json"] = JSON.stringify(config);
res();
--
cgit v1.2.3