fix github themes recursive copy

This commit is contained in:
yazninja 2023-05-09 22:18:42 +03:00
parent 8695bd55a7
commit 99ac3d6a46

View file

@ -932,12 +932,15 @@ export class BrowserWindow {
console.debug(`REPO ID: ${apiRepo.id}`);
// extract the files from the first folder in the zip response
let zip = new AdmZip(await response.buffer());
let entry = zip.getEntries()[0];
if (!existsSync(join(utils.getPath("themes"), "gh_" + apiRepo.id))) {
mkdirSync(join(utils.getPath("themes"), "gh_" + apiRepo.id));
}
console.log(join(utils.getPath("themes"), "gh_" + apiRepo.id));
zip.extractEntryTo(entry, join(utils.getPath("themes"), "gh_" + apiRepo.id), false, true);
zip.getEntries().forEach((entry) => {
if(entry.entryName.endsWith("/")) return
let subFolder = entry.entryName.split("/").slice(1, -1).join("/");
zip.extractEntryTo(entry, join(utils.getPath("themes"), "gh_" + apiRepo.id, "/", subFolder), false, true);
});
let commit = await utils.fetch(`https://api.github.com/repos/${repo}/commits`).then((res) => res.json());
console.debug(`COMMIT SHA: ${commit[0].sha}`);
let theme = JSON.parse(readFileSync(join(utils.getPath("themes"), "gh_" + apiRepo.id, "theme.json"), "utf8"));