aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknown2018-06-16 11:39:15 +0100
committerUnknown2018-06-16 11:39:15 +0100
commitbf5f2eb8338e040ed811b1d3c5ed3dccdcce715c (patch)
treeedd45758c4a3bbc3bac897005906839cb45ec6e1
parentb5264f5c46211ebc5e45926d4cde31c167a1ba1b (diff)
fix a bug that broke multiple repos
-rw-r--r--pkg93.js78
1 files 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("<b><span style='color:#f0f'>GET</span></b> " + 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("<b><span style='color:#f00'>ERR</span></b> Fatal error while retriving package.json.");
- };
- xhr.onload = () => {
- try {
- console.log(xhr.responseText);
- var json = JSON.parse(xhr.responseText);
- cli.log("<b><span style='color:#0f0'>NAME</span></b> " + json.name);
- cli.log("<b><span style='color:#0f0'>MSG</span></b> " + json.msg);
- for (let item of json.packages) {
- try {
- config.pkglist.push(item + "@" + source);
- cli.log("<b><span style='color:#0f0'>OK</span></b> " + item + "@" + source);
- } catch (err) {
- cli.log("<b><span style='color:#f00'>ERR</span></b> " + err.message);
+ await new Promise(async (reso, reje) => {
+ try {
+ console.log(source);
+ cli.log("<b><span style='color:#f0f'>GET</span></b> " + 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("<b><span style='color:#f00'>ERR</span></b> Fatal error while retriving package.json.");
+ };
+ xhr.onload = () => {
+ try {
+ console.log(xhr.responseText);
+ var json = JSON.parse(xhr.responseText);
+ cli.log("<b><span style='color:#0f0'>NAME</span></b> " + json.name);
+ cli.log("<b><span style='color:#0f0'>MSG</span></b> " + json.msg);
+ for (let item of json.packages) {
+ try {
+ config.pkglist.push(item + "@" + source);
+ cli.log("<b><span style='color:#0f0'>OK</span></b> " + item + "@" + source);
+ } catch (err) {
+ cli.log("<b><span style='color:#f00'>ERR</span></b> " + err.message);
+ }
}
+ reso();
+ } catch (err) {
+ console.error(err);
+ cli.log("<b><span style='color:#f00'>ERR</span></b> " + err.message);
+ console.log(xhr.responseText);
+ reje();
}
- } catch (err) {
- console.error(err);
- cli.log("<b><span style='color:#f00'>ERR</span></b> " + err.message);
- console.log(xhr.responseText);
- rej();
- }
- };
- xhr.send();
- } catch (err) {
- cli.log("<b><span style='color:#f00'>ERR</span></b> " + err.message);
- } finally {
- delete window.xhr;
- }
+ };
+ xhr.send();
+ } catch (err) {
+ cli.log("<b><span style='color:#f00'>ERR</span></b> " + err.message);
+ rej();
+ }
+ });
}
localStorage[".pkg93/config.json"] = JSON.stringify(config);
res();