Tucker McKnight
Use for..of loops instead of promises These wait for each other in a sequence, unliked a Promise.all(array.map), which executes everything all at once. Artifact steps whould be able to depend on the result of the previous one, so the need to go in sequence.
89 90 91 92 93 94 95 96
Promise.all(repoConfig.branchesToPull.map(async (branch) => {
return Promise.all(repoConfig.artifactSteps.map(async (artifactStep) => {
return exec(`cp -r ${tempDirRepoPath}/${artifactStep.copyFrom} ${directories.output}${eleventyConfig.getFilter("slugify")(repoName)}/branches/${eleventyConfig.getFilter("slugify")(branch)}/${artifactStep.copyTo}`)
}))
})).then(async () => {
// delete the temp dirs
await exec(`rm -r ${tempDir}`)
})
89 90 91 92 93 94 95 96
for (let branch of repoConfig.branchesToPull) {
for (let artifactStep of repoConfig.artifactSteps) {
await exec(`cp -r --remove-destination ${tempDirRepoPath}/${artifactStep.copyFrom} ${directories.output}${eleventyConfig.getFilter("slugify")(repoName)}/branches/${eleventyConfig.getFilter("slugify")(branch)}/${artifactStep.copyTo}`)
}
}
// delete the temp dirs
await exec(`rm -r ${tempDir}`)