Created
August 22, 2018 13:31
-
-
Save sabicalija/378204c89f3ce6fc70f653aaa6f6c055 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetch = require("node-fetch"); | |
let api = "https://api.github.com/repos/asterics/AsTeRICS/"; | |
let raw = "https://raw.githubusercontent.com/asterics/AsTeRICS/"; | |
let path = "Documentation/ACS-Help/HTML/"; | |
let tags = "https://api.github.com/repos/asterics/AsTeRICS/tags/"; | |
let sections = ["Plugins", "ACS", "ARE"]; | |
let link = `${api}contents/${path}Plugins`; | |
async function asyncForEach(array, cb) { | |
for (let i = 0; i < array.length; i++) [await cb(array[i], i, array)]; | |
} | |
const getContent = async l => { | |
return await getS(l); | |
}; | |
const getS = async (url, data = []) => { | |
let response = await fetch(url); | |
let ret = await response.json(); | |
let hasChilds = false; | |
let n = []; | |
ret.forEach(v => { | |
if (v.type == "dir") hasChilds = true; | |
let c = { node: v, contents: [] }; | |
n.push(c); | |
}); | |
if (hasChilds) { | |
await asyncForEach(n, async v => { | |
if (v.node.type == "dir") { | |
let c = await getS(v.node.url); | |
v.contents = [...c]; | |
let ftw = 0; | |
} | |
}); | |
} | |
return n; | |
}; | |
console.log(link); | |
getContent(link).then(r => { | |
console.log(r); | |
}); |
Author
sabicalija
commented
Aug 22, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment