From 0b6001b70f7de6f6554ef9ce7006cff985447752 Mon Sep 17 00:00:00 2001 From: Oj Date: Sun, 7 Mar 2021 20:48:26 +0000 Subject: [PATCH] [Caching] Fix sub module support --- src/index.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index cb7edbb..36a6738 100644 --- a/src/index.js +++ b/src/index.js @@ -101,8 +101,19 @@ for (const parentRepo of ModuleRepos) { for (const repo of parentRepo.modules) { console.time(repo.slice(0, 2).join(' @ ')+`${repo[2] ? ` ${repo[2]}` : ''}`); + const name = repo[0]; + const cloneDir = `${clonesDir}/${name}`; + const moduleDir = repo[2] || ''; + if (previous.includes(repo)) { - const currentModule = currentRepoJson.modules.find((x) => x.github.repo === repo[0]) + let currentModule = currentRepoJson.modules.filter((x) => x.github.repo === repo[0]); + if (currentModule.length > 1) { + const manifest = JSON.parse(readFileSync(`${cloneDir}${moduleDir}/goosemodModule.json`)); + + currentModule = currentModule.find((x) => x.name === manifest.name); + } else { + currentModule = currentModule[0]; + } moduleJson.modules.push(currentModule); @@ -115,11 +126,6 @@ for (const parentRepo of ModuleRepos) { const githubInfo = await getGithubInfo(repo[0]); - const name = repo[0]; - const cloneDir = `${clonesDir}/${name}`; - - const moduleDir = repo[2] || ''; - // console.log(repo); const url = `https://github.com/${repo[0]}.git`; @@ -130,7 +136,7 @@ for (const parentRepo of ModuleRepos) { // resetDir(cloneDir); // rmSync(cloneDir, { recursive: true, force: true }); - if (existsSync(cloneDir)) rmSync(cloneDir, { recursive: true, force: true }); + // if (existsSync(cloneDir)) rmSync(cloneDir, { recursive: true, force: true }); await new Promise((res) => exec(`git clone ${url} ${cloneDir}`, res));