[Caching] Fix updating hash sometimes failing due to cwd bug

This commit is contained in:
Ducko 2021-03-08 19:12:41 +00:00 committed by フズキ
parent 0b6001b70f
commit 4268f099b5
No known key found for this signature in database
GPG Key ID: AD7750AB4625F1DD
1 changed files with 9 additions and 1 deletions

View File

@ -136,8 +136,16 @@ 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)) {
process.chdir(cloneDir);
const currentHash = await new Promise((res) => exec(`git rev-parse HEAD`, (err, stdout) => res(stdout.trim())));
if (currentHash !== repo[1]) rmSync(cloneDir, { recursive: true, force: true });
}
process.chdir(distDir); // Incase current wd is broken, in which case exec / git crashes
await new Promise((res) => exec(`git clone ${url} ${cloneDir}`, res));
process.chdir(cloneDir);