From 99ac3d6a4646a31502e369ce5074c8260ef22f6b Mon Sep 17 00:00:00 2001 From: yazninja Date: Tue, 9 May 2023 22:18:42 +0300 Subject: [PATCH] fix github themes recursive copy --- src/main/base/browserwindow.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/base/browserwindow.ts b/src/main/base/browserwindow.ts index 36544325..78d3b677 100644 --- a/src/main/base/browserwindow.ts +++ b/src/main/base/browserwindow.ts @@ -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"));